Have import look in pkg dir before working directory #11636
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently
import Foo
will first look in the working directory for an appropriately named file before trying to load a package calledFoo
. This PR reverses that precedence. I don't know if that's the optimal solution, or what the all the consequences might be, but I hope I can provoke some thought about this.There are various problems that the current behavior can cause. All of them are not obvious failures, and can be difficult, especially for new users to debug. Here's an example:
Markdown.jl
import Markdown
julia Markdown.jl
This is especially egregious on case-insensitive file systems, where the file might be named
markdown.jl
, or ifimport Markdown
doesn't appear directly in that file, but something it imports. Furthermore, it's easy to break working code just by accidentally introducing files named the wrong things (e.g.images.jl
,distributions.jl
) in the same working directory. Once more command line tools are written in Julia, this behavior could be a security risk as well, at least as long as there's no way to disable it.Our current behavior is similar to Python's, but I don't think this is a Python feature that's worth emulating. It has been raised before as a python issue (a decade ago), but dismissed because it would break too many things to change.
It also comes up periodically here as well, for example: #9079