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

Drive mismatch exception #5123

Closed
afreedma opened this issue Dec 13, 2013 · 23 comments
Closed

Drive mismatch exception #5123

afreedma opened this issue Dec 13, 2013 · 23 comments
Labels
bug Indicates an unexpected problem or unintended behavior system:windows Affects only Windows
Milestone

Comments

@afreedma
Copy link

On launch Julia throws the following error:

ErrorException("drive mismatch: C:\julia-05c6461b55 \\vulcan\home$\u100012\AppData\julia")

Looking at julia/base/path.jl, joinpath(a, b) appears to assume that a and b will both be C:\ or UNC style so doesn't account for a mixed case.

@StefanKarpinski
Copy link
Sponsor Member

Maybe this should just let the later drive win. When I wrote this code, I wasn't sure what to do in this case, so I just played it safe and made it an error.

@Keno
Copy link
Member

Keno commented Dec 13, 2013

I think that's the correct way to go.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 15, 2013

Presumably this should behave the same as linux, so the last absolute path should win.

@StefanKarpinski
Copy link
Sponsor Member

I'm pretty sure it already does that on all UNIX flavors. I just wasn't sure about drives.

@StefanKarpinski
Copy link
Sponsor Member

Ok, so I'm considering just removing this line but it seems like this error should never have happened in the first place since the second path should be considered absolute. I think that in the case of mixed drives where the paths are relative an error really is the only reasonable thing to do. What should joinpath("A:foo","B:bar") be? Is that on drive A or drive B?

@StefanKarpinski
Copy link
Sponsor Member

Ah, ok. How about this teensy little change:

diff --git a/base/path.jl b/base/path.jl
index 627689f..7ccbe93 100644
--- a/base/path.jl
+++ b/base/path.jl
@@ -12,7 +12,7 @@ end
 @windows_only begin
     const path_separator    = "\\"
     const path_separator_re = r"[/\\]+"
-    const path_absolute_re  = r"^(?:\w+:)[/\\]"
+    const path_absolute_re  = r"^(?:\w+:)?[/\\]"
     const path_directory_re = r"(?:^|[/\\])\.{0,2}$"
     const path_dir_splitter = r"^(.*?)([/\\]+)([^/\\]*)$"
     const path_ext_splitter = r"^((?:.*[/\\])?(?:\.|[^/\\\.])[^/\\]*?)(\.[^/\\\.]*|)$"

I think that may have been what I originally intended but I'm not sure what should be considered absolute on Windows. cc: @loladiro, @vtjnash, @karbarcca for guidance.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 18, 2013

It's absolute if it starts with \ or if the second character is a colon and the first is A-Za-z

"[A-Za-z]:|\\" (with two backslashes in the regex)

Although sometimes / is accepted as a valid path separated, traditionally it is treated as an invalid token

@StefanKarpinski
Copy link
Sponsor Member

Ok, can you just fix the regex then?

@toivoh
Copy link
Contributor

toivoh commented Dec 18, 2013

I'm quite sure that you need a backslash/slash for an absolute path on windows. E.g. A:dir means dir relative to the current directory on A:. Or at least it used to in dos :)

@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 18, 2013

Oops, yes that's right. I thought c: specified the root of the drive, however?

@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 19, 2013

OK, now that i'm at a computer I can look up the definitive resource: http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx

DOS chokes on / in a path because it tries to interpret the path as an argument flag. The Windows API will always convert / to \.

so it seems a path is absolute if it matches r"^(?:\w+:)?[/\\]", as suggested by Stefan, it is relative if it starts with r"(\w)+:[^/\\]" and your current drive is \1, and otherwise it is relative?

They devote an entire section explaining how useful it is that windows can use a different path for every drive to save you effort.

More fun facts from that help site: If you end a file name with a . or name it NUL (with any extension) you'll confuse your computer and make windows explorer cry. However, if you prefix your access to the filesystem with \\?\ it'll disable processing of the path, so you can name your files . or .., and / won't get converted into path separators, so you can use it too. Also, it will disable the code that verifies that your files don't exceed the maximum path length (260 characters).

@StefanKarpinski
Copy link
Sponsor Member

why does this operating system exist?

@JeffBezanson
Copy link
Sponsor Member

Won't be long before nobody knows what a "drive" is :)

@StefanKarpinski
Copy link
Sponsor Member

Sure they will. They're those weird letters at the beginnings of Windows paths.

@jiahao
Copy link
Member

jiahao commented Dec 19, 2013

su thread

@StefanKarpinski
Copy link
Sponsor Member

Love it.

tknopp pushed a commit to tknopp/julia that referenced this issue Jan 13, 2014
@bart6114
Copy link

Am I correct that this fix is not in v0.2.1? I keep getting this drive mismatch error. The v0.3-prerelease is working though. However, I would like to use Julia Studio and this doesn't work with the v0.3 release yet. Anyway I can get v0.2.1 working?

@ivarne
Copy link
Sponsor Member

ivarne commented Mar 28, 2014

Yes, this fix is not in the 0.2 branch. The main developers have only backported a few fixes to the release branch, and the community has not picked up the ball and contributed Pull Requests. I intend to help backport fixes for the 0.3 release branch once 0.3 gets released.

ivarne pushed a commit to ivarne/julia that referenced this issue Mar 28, 2014
@cmundi
Copy link
Contributor

cmundi commented Mar 29, 2014

StefanKarpinski commented 3 months ago:

why does this operating system exist?

It's an operating system? I thought it was a text adventure. No wonder I haven't seen the Wumpus in years!

@bart6114
Copy link

Thanks!

In the meantime, should copying the new path.jl to the /share/julia/base folder fix this? I copied the referenced version (const path_absolute_re = r"^(?:\w+:)?[/\\]") to this folder but I keep getting the same error:

ErrorException("drive mismatch: C:\julia\julia-e44b593905 \\toaster\home15\jsmeet5\uzlsystem\AppData\julia")

@ivarne
Copy link
Sponsor Member

ivarne commented Mar 29, 2014

Copying the fix is just half of the process. You will also need to regenerate the cache, but unfortunately I don't know how to do that for 0.2 when you are not compiling from source. To speed up the process of starting Julia, she parses the base library and caches the parsed AST in the sys.ji file (in 0.3 she caches the compiled machine code for even faster startup).

Grepping revieals a contrib/windows/prepare-julia-env.bat file that might help, but someone with access to windows will have to tell you if that is still relevant.

@tkelman
Copy link
Contributor

tkelman commented Mar 29, 2014

Delete or move sys.ji out of the way then running prepare-julia-env.bat will regenerate the system image, at least with recent 0.3. Probably also with 0.2.

@bart6114
Copy link

Thanks, worked like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior system:windows Affects only Windows
Projects
None yet
Development

No branches or pull requests