elves / elvish

Powerful scripting language & versatile interactive shell
https://elv.sh/
BSD 2-Clause "Simplified" License
5.67k stars 300 forks source link

Building and running elvish on MSYS2 + Windows 10 mangles paths #1050

Open krader1961 opened 4 years ago

krader1961 commented 4 years ago

This is going to be a problem for anyone trying to use elvish under Windows 10 + MSYS2:

$ ./elvish.exe -c 'put $args' x /x/y
▶ [x X:/y]

This came to my attention because of a golang-nuts mailing list discussion thread that I commented on: https://groups.google.com/forum/#!topic/golang-nuts/Z2LY7mKIzO0. See also

http://www.mingw.org/wiki/Posix_path_conversion

https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line

https://github.com/msys2/MSYS2-packages/issues/84

I confirmed that using the env var workaround "fixes" this problem:

$ ./elvish.exe -c 'put $args' x /x/y
▶ [x X:/y]
$ MSYS2_ARG_CONV_EXCL="*" ./elvish.exe -c 'put $args' x /x/y
▶ [x /x/y]

Obviously that isn't a practical solution. If the Go community doesn't come up with a solution generally applicable to all Go programs it might be necessary for Elvish to implement its own solution.

krader1961 commented 4 years ago

Note that using the MSYS2 mktemp program produces output that assumes elvish is linked against the MSYS2 DLLs. For example, /tmp/tmp.uV8LueyETl which, for elvish, is really C:/msys64/tmp/tmp.uV8LueyETl. I noticed this because @zzamboni's "alias" module uses mktemp which results in this startup error:

Exception: failed to open file /tmp/tmp.uV8LueyETl: open /tmp/tmp.uV8LueyETl: The s
ystem cannot find the path specified.
Traceback:
  C:\Users\krade\.elvish\lib/github.com/zzamboni/elvish-modules/alias.elv, line 18:
      echo 'aliases['$name'] = $'$name'~' > $-tmpfile
  C:\Users\krade\.elvish\lib/github.com/zzamboni/elvish-modules/alias.elv, line 92:
          -load-alias $name $file
  C:\Users\krade\.elvish\lib/github.com/zzamboni/elvish-modules/alias.elv, line 97:
    init
  C:\Users\krade\.elvish\rc.elv, line 34:
    use github.com/zzamboni/elvish-modules/alias

Note that I really don't care if elvish works on Windows. I'm only reporting these issues because there seems to be an implicit goal to support Windows as well as UNIX like platforms.