Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit() fails on Windows if the editor path contains slashes #9331

Closed
wdobbie opened this issue Dec 12, 2014 · 7 comments
Closed

edit() fails on Windows if the editor path contains slashes #9331

wdobbie opened this issue Dec 12, 2014 · 7 comments
Labels
system:windows Affects only Windows

Comments

@wdobbie
Copy link

wdobbie commented Dec 12, 2014

julia> ENV["JULIA_EDITOR"] = "c:/windows/system32/notepad.exe"
"c:/windows/system32/notepad.exe"

julia> edit(println)
ERROR: could not spawn `c:windowssystem32notepad.exe 'C:\Users\Will\AppData\Local\Julia-0.4.0-dev\bin\../share\julia\base\string.jl'`: no such file or directory (ENOENT)
 in _jl_spawn at process.jl:216 (repeats 2 times)

The problem seems to be that edit() calls shell_parse() in string.jl which splits the string at backslash characters. Using forward slashes as above doesn't work because realpath() is called on it first, which converts them to backslashes. Example:

julia> s = "c:/windows/system32/notepad.exe"
"c:/windows/system32/notepad.exe"

julia> realpath(s)
"c:\\windows\\system32\\notepad.exe"

julia> Base.shell_split(ans)
1-element Array{AbstractString,1}:
 "c:windowssystem32notepad.exe"
@tkelman
Copy link
Contributor

tkelman commented Dec 12, 2014

what's your versioninfo()? cc @dhoegh has made some changes to this code recently

@dhoegh
Copy link
Contributor

dhoegh commented Dec 13, 2014

@wdobbie does it work if your path is escaped like: "c:\windows\system32\notepad.exe" ? My changes should not affect this behavior and I have not used this, but I could probably fix it, but I do not have time in the next week.
@wdobbie if you would contribute with a fix it would be nice. The 'shell_parse' should not effect a path when it uses front slashes.

@tkelman tkelman added the system:windows Affects only Windows label Dec 13, 2014
@vtjnash
Copy link
Member

vtjnash commented Dec 13, 2014

shell_parse is fine. the issue is that here

run(`$(shell_split(edpath)) $file`)
we aren't calling it on the original environment variable input as we probably should be doing (it looks like this may be an issue for subl / atom also)

@ivarne
Copy link
Member

ivarne commented Dec 13, 2014

@dhoegh I updated your escaped path to have quadruple forward slashes, because markdown uses \ to escape characters and with double \ you need to type four slashes in the source.

@wdobbie
Copy link
Author

wdobbie commented Dec 13, 2014

@tkelman my versioninfo() is

Julia Version 0.4.0-dev+2070
Commit f2b5a11 (2014-12-11 10:19 UTC)
Platform Info:
  System: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-5820K CPU @ 3.30GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

@dhoegh It fails with both forward and back slashes. I would suggest a fix but I couldn't understand the intent behind shell_parse splitting on backslash characters. It seems the function is intended to split a command line string into tokens while taking into account quoted strings, but I don't understand why it treats backslash as a token separator. Example:

julia> Base.shell_parse("/path/to/file arg1 arg2")
(:((("/path/to/file",),("arg1",),("arg2",))),0:-1)

julia> Base.shell_parse("\\path\\to\\file arg1 arg2")
(:((("path","to","file"),("arg1",),("arg2",))),0:-1)

I'm new to Julia and haven't figured out how to modify files in Base and have Julia see the changes, but it seems this could be fixed by removing the following part of shell_parse (this would break whatever depends on backslash separating tokens):

            elseif !in_single_quotes
                if done(s,k)
                    error("dangling backslash")
                end
                update_arg(s[i:j-1]); i = k
                c, k = next(s,k)
            end

Is there a way I can force Julia to reload the cached Base files?

@tkelman
Copy link
Contributor

tkelman commented Dec 14, 2014

@wdobbie I'm guessing you're working from a nightly binary download, not a source build? The way to update files in base and have Julia see them is by deleting or renaming the file lib/julia/sys.ji, then running bin/prepare-julia-env.bat. This is subject to be replaced pretty soon with a Julia script that will work the same way on all platforms, but for now the bat file is the way to do it on Windows.

@nolta
Copy link
Member

nolta commented Sep 22, 2015

Should be fixed by #13032, but please reopen if it isn't.

@nolta nolta closed this as completed Sep 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:windows Affects only Windows
Projects
None yet
Development

No branches or pull requests

6 participants