Weird cygwin path mess

Julia is run in a cygwin window. It is

julia> versioninfo()
Julia Version 1.3.0-rc4.1
Commit 8c4656b97a (2019-10-15 14:08 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-4650U CPU @ 1.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, haswell)

Consider the following. Using the Julia function to change into a folder doesn’t work. The shell-mode CD doesn’t work either. The shell-mode listing of the folder works. Using a relative path works.

julia> cd("/cygdrive/c/Users/PK/Documents/work/advanced-finite-element-analysis-of-solids")
ERROR: IOError: chdir /cygdrive/c/Users/PK/Documents/work/advanced-finite-element-analysis-of-solids: no such file or directory (ENOENT)
Stacktrace:
 [1] uv_error at .\libuv.jl:97 [inlined]
 [2] cd(::String) at .\file.jl:84
 [3] top-level scope at REPL[1]:1

shell> cd /cygdrive/c/Users/PK/Documents/work/advanced-finite-element-analysis-of-solids
ERROR: IOError: chdir /cygdrive/c/Users/PK/Documents/work/advanced-finite-element-analysis-of-solids: no such file or directory (ENOENT)
Stacktrace:
 [1] uv_error at .\libuv.jl:97 [inlined]
 [2] cd(::String) at .\file.jl:84
 [3] repl_cmd(::Cmd, ::REPL.Terminals.TTYTerminal) at .\client.jl:61
 [4] top-level scope at REPL[1]:0

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

shell> pwd
/cygdrive/c/Users/PK/Documents/work

julia> cd("./advanced-finite-element-analysis-of-solids\\")

shell> pwd
/cygdrive/c/Users/PK/Documents/work/advanced-finite-element-analysis-of-solids

julia>

Where does this come from, and how to fix it?

It is documented here:

https://cygwin.com/cygwin-ug-net/using.html#using-pathnames

Cf

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

If you are asking in relation to

https://github.com/tpapp/julia-repl/issues/74

I may be able to figure out a workaround in julia-repl.

2 Likes

The Julia executable is still a native Windows build, so needs backslash for the path and Windows like drive letters:

julia> cd("/cygdrive/c/Users/oheil/Local Settings/Application Data/")
ERROR: IOError: chdir /cygdrive/c/Users/oheil/Local Settings/Application Data/: no such file or directory (ENOENT)
Stacktrace:
 [1] uv_error at .\libuv.jl:90 [inlined]
 [2] cd(::String) at .\file.jl:76
 [3] top-level scope at REPL[3]:1

but

julia> cd(raw"c:\Users\oheil\Local Settings\Application Data")

julia> pwd()
"c:\\Users\\oheil\\Local Settings\\Application Data"

You can help yourself with e.g. quick and dirty:

cd(replace(replace("/cygdrive/c/Users/oheil/Local Settings/Application Data","/" => "\\"),"\\cygdrive\\c" => "c:"))

but beware, a trailing / at the end of the path is not allowed with this simple example.
I wouldn’t call it a mess, but yes, it is sometimes annoying.

True, this is easy to fix by hand (https://github.com/tpapp/julia-repl/issues/74#issuecomment-557484567), but what is needed for a reasonable workflow in Emacs is either for Julia or for julia-repl to sort this out automatically (read without user intervention). Thanks to a fantastically responsive author (@Tamas_Papp; :grinning: ), perhaps the latter will materialize!

Yes, there is now

https://github.com/tpapp/julia-repl/pull/76

and feedback would be welcome.

3 Likes