tpapp / julia-repl

Run an inferior Julia REPL in a terminal inside Emacs
Other
170 stars 35 forks source link

cygwin: path of `include`d files incorrect #74

Closed PetrKryslUCSD closed 4 years ago

PetrKryslUCSD commented 4 years ago

Cygwin Emacs 26: The following error is found when includeing a buffer.

include("/home/PK/thread_buffers.jl");
ERROR: could not open file \home\PK\thread_buffers.jl
Stacktrace:
 [1] include at .\boot.jl:328 [inlined]
 [2] include_relative(::Module, ::String) at .\loading.jl:1105
 [3] include(::Module, ::String) at .\Base.jl:31
 [4] include(::String) at .\client.jl:432
 [5] top-level scope at REPL[23]:1

Manually typing in include("/cygwin64/home/PK/thread_buffers.jl") succeeds.

PetrKryslUCSD commented 4 years ago

Same thing for C-c C-p (change to the folder of the current buffer).

PetrKryslUCSD commented 4 years ago

Here is another example, this time accessing a folder on the Windows file system. The file is included with the key binding C-c C-b from the source file:

julia> include("/cygdrive/c/Users/PK/Documents/work/advanced-finite-element-analysis-of-solids/thread_buffers.jl")
ERROR: could not open file \cygdrive\c\Users\PK\Documents\work\advanced-finite-element-analysis-of-solids\thread_buffers.jl
Stacktrace:
 [1] include at .\boot.jl:328 [inlined]
 [2] include_relative(::Module, ::String) at .\loading.jl:1105
 [3] include(::Module, ::String) at .\Base.jl:31
 [4] include(::String) at .\client.jl:432
 [5] top-level scope at REPL[6]:1

shell> ls /cygdrive/c/Users/PK/Documents/work/advanced-finite-element-analysis-of-solids/thread_buffers.jl
/cygdrive/c/Users/PK/Documents/work/advanced-finite-element-analysis-of-solids/thread_buffers.jl

The buffer file name is apparently

buffer-file-name is a variable defined in ‘C source code’.
Its value is
"/cygdrive/c/Users/PK/Documents/work/advanced-finite-element-analysis-of-solids/thread_buffers.jl"
Local in buffer thread_buffers.jl; global value is nil

So it seems the name is deduced correctly, but the file cannot be included for some reason.

EDIT: It appears to be a Julia thing. The Julia run in the cygwin terminal is the Windows Julia. Evidently it doesn't know how to handle the path.

PetrKryslUCSD commented 4 years ago

It seems that absolute paths are a problem for Julia running under cygwin. Would be difficult to change the mechanism in julia-repl to run the includes with relative pathnames?

tpapp commented 4 years ago

cf https://github.com/JuliaLang/julia/issues/24128

A workaround I can imagine on the julia-repl side is a simple rewriting rule that replaces "/cygdrive/c/" with C:/ or something like that. This should be quite easy to implement, but I need some help from you about the details.

Specifically, it would be nice to have a few examples of

  1. M-x (buffer-file-name)
  2. and the corresponding path that works in include in Julia
PetrKryslUCSD commented 4 years ago

Here are the results of an experiment I did. The files were included using C-c C-b for the cases that failed (and faithfully represented the buffer-file-name variable). The cases that succeeded were run by recalling the previous command line in the terminal and tweaking it.

First a file located in the cygwin folder structure: This fails julia> include("/home/PK/thread_buffers.jl");

This works julia> include("c:/cygwin64/home/PK/thread_buffers.jl");

Now for a file located in the Windows folder structure: This fails julia> include("/cygdrive/c/Users/PK/Documents/work/advanced-finite-element-analysis-of-solids/another.jl");

This works julia> include("c:/Users/PK/Documents/work/advanced-finite-element-analysis-of-solids/another.jl");

Thank you for your help. Much appreciated. I used to use Emacs, and I would like to return to it. (Even though Sublime Text is a pleasure to work with. It is simply not as easy to extend or customize as Emacs.)

tpapp commented 4 years ago

Thanks, so in these examples the "this fails" path comes from (buffer-file-name), and the "this works" is what you rewrite it to make it work?

PetrKryslUCSD commented 4 years ago

Thanks, so in these examples the "this fails" path comes from (buffer-file-name), and the "this works" is what you rewrite it to make it work?

That is correct.

tpapp commented 4 years ago

(reopening, this will be closed by #76 which is not yet merged)