-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
using X operates relative to the working directory #9079
Comments
I realize this was talked about elsewhere, but can you add a pointer and some more context? |
If it's been discussed before then I missed that. It just came up for a new user on the Julia-LT chat room – they were trying out some Forio tutorial code which worked when using Julia from the REPL, but not in Juno, causing some confusion. We could make this work, but since it doesn't seem to be particularly idiomatic (and is easily replaced by |
If there's no downside, it seems desirable to be able to organize tests without thinking "my package uses Images, so I better not name this file 'color.jl'" -- bad example, but sometimes that's exactly how you'd want to organize your tests. It's also just a little confusing, and if there are good reasons to replace Color, I'd imagine it would be better for an already-loaded Color module to be picked up (right now, 'test/color.jl' is favored over an already-loaded Color module). |
This wasted a few hours of time debugging for @jiahao @alanedelman and me. And some more for @rohitvarkey yesterday. It would be nice if someone with a mac looks into fixing this. |
This issue report is lacking any kind of test case, making it hard to (1) know what you're concerned about and (2) test it on different platforms (since there seems to be some suspicion it's OSX-specific). Just to show how ambiguous this report is, here's a test-case that appears to fit the wording used in the issue report but which comes to the opposite conclusion: julia> pwd()
"/home/tim/Documents"
julia> LOAD_PATH
3-element Array{Union{UTF8String,ASCIIString},1}:
"/home/tim/src/julia/usr/local/share/julia/site/v0.4"
"/home/tim/src/julia/usr/share/julia/site/v0.4"
"/home/tim/juliafunc"
julia> edit("/home/tim/juliafunc/TestModule.jl") # create a module that just prints "blah" when loaded
julia> using TestModule
blah Moreover, |
shell> cd test
julia> include("test.jl")
success I think it's reasonably intuitive that this works, even though julia> include("test/test.jl")
ERROR: could not open file C:\Users\mikej_000\Downloads\juno-windows64\test.jl
in include at boot.jl:245
in include_from_node1 at loading.jl:128 But then it's completely surprising that this doesn't work. |
So, should it look first in the current working directory, or in the directory where the file containing the using was loaded? (I can see pros and cons to both approaches, but I think @one-more-minute is correct, that it really should be looking in the directory where the file containing the |
Here are the steps I took to reproduce this bug: On Julia julia> Pkg.generate("Temp", "MIT")
INFO: Initializing Temp repo: /Users/rohitvarkey/.julia/v0.3/Temp
INFO: Generating LICENSE.md
INFO: Generating README.md
INFO: Generating src/Temp.jl
INFO: Generating test/runtests.jl
INFO: Generating .travis.yml
INFO: Generating .gitignore
INFO: Committing Temp generated files
julia> edit("Temp.jl")
# this is the module definition
module Temp
println("Loading module")
end # module
Create #temp.jl:
println("Loading file...") Run this in a julia REPL under shell> cd /tmp/
julia> using Temp
Loading file...
Warning: requiring "Temp" did not define a corresponding module. But if I run julia> using Temp
Loading module |
That looks like ok behavior to me; it's just searching the current directory first. My understanding of the bug is this: if file a.jl does |
But crucially, It doesn't seem hugely unlikely that you might have e.g. a Seems much clearer for people to explicitly write |
|
Could including |
Oh, I guess then this is more surprising on OS X, because filenames are And this is why I can't have a file called On Tue, Jul 14, 2015, 8:49 PM Jeff Bezanson [email protected]
|
@jakebolewski But why would you want to look in In other words – what value do you expect |
Well, in linux, you wouldnt be able to have a file called "examples/Compose.jl" for the same reason. OSX does have a case insensitive file system by default, so that's the behaviour you will get. I don't think Julia should compensate for that. The productivity loss due to issues like this, lay on the hands of Apple :) |
This seems fine to me now.
you mean there is a mode where it's not case sensitive? :o
I can settle for that. |
You can format a HFS+ partition to be case sensitive, but it is not the default. |
that would make a good, although sneaky, make install step |
Many OS X apps (for a long time everything by Adobe) can't handle case-sensitive file systems. |
This should definitely be changed. The exact behavior of |
This change broke Gadfly (possibly on OSX only, due to case insensitivity). Gadfly has a source file Rolling back to the commit prior to 189a043 restores working Gadfly. |
No, that shouldn't be necessary. It's technically possible to change a registry setting and use Cygwin in a case-sensitive mode on Windows if you want, but very few people do that. Case-insensitivity is stupid and annoying, but until it goes away as a default setting we need to test for it and be robust to it. As one example, having multiple files with names that differ only in case in the same folder of a package can cause a package repo to always be dirty when checked out in git, so that package will get stuck in a state where it won't update correctly from then on. This kind of thing is a portability red flag that we need to keep a close eye out for. |
I don't think we should be focussing too much about OSX and case sensitive file systems when analysing this issue. Yes, |
@tkelman We aren't using Windows at all, using the case-sensitive sparsebundle on the Mac is simply to avoid issues between the host OS (where we do our editting, etc.) and our Linux VMs. |
@ScottPJones I get the impression when you say "we" you're talking about your company and coworkers. That is completely and utterly irrelevant here. When I say "we" I'm talking about the Julia community as a whole, across all platforms that are currently supported. Documentation isn't an acceptable fix for this, we need to walk back on this change. We certainly can't keep things as they are right now for a release. |
@tkelman I felt it was relevant, as an example of a way of avoid at least the extra problems caused by using case-insensitive file systems. As I said to aviks, I do think this is a big deal, and needs to be fixed for all cases, not just partially patch up the issue for the default on OS X and Windows. |
Also, I don't think that just removing the cwd or the source file location really fixes this either. |
It's unintuitive to me that this would be characterized as putting all package files in a single global namespace. Technically, it does the exact opposite of that --- looking in the source file directory means all packages can have a file with the same name without conflicts. Anyway, maybe the solution is #4600: have |
well, yes, maybe that's too strong a term technically, but now you cannot have a local file that is named the same as a module+file anywhere in LOAD_PATH, as all the issues linked above show. The previous behaviour did have its issues, and the fix seemed logical in making things more consistent. But somehow the earlier behaviour seemed much more intuitive. Am I just rationalising learnt behaviour? |
I'm fairly certain the reason the old behavior |
As a new user, I didn't think the old behavior worked (on OSX): #7256. At least not when working on packages (as opposed to general projects). |
+1 |
So #12340 didn't fix the the package filename collisions causing freezes for |
Would it fix the issue to have the source directory as a fallback to |
I wouldn't mind syntactic distinction between the two with the leading |
I think there's value in allowing where to find external code to be controlled by the system configuration (build tool arguments, environment variables, etc...) and not in the syntax of the actual code text. But it might be nice to have a parallel |
I think the idea is for |
Meaning the local directory the current module was found in, unless at REPL? |
Yes. In the REPL the current directory is where you would look. |
Sounds very good to me. |
After using this for a while, I find |
Plan:
|
i.e.
using X
will loadX.jl
and the moduleX
, but only from the current working directory, as opposed to the current file path asinclude
does.The text was updated successfully, but these errors were encountered: