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

Have import look in pkg dir before working directory #11636

Closed
wants to merge 1 commit into from

Conversation

dcjones
Copy link
Contributor

@dcjones dcjones commented Jun 9, 2015

Currently import Foo will first look in the working directory for an appropriately named file before trying to load a package called Foo. 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:

  1. Make a named Markdown.jl
  2. Have it import Markdown
  3. Run julia Markdown.jl
  4. Julia hangs forever.

This is especially egregious on case-insensitive file systems, where the file might be named markdown.jl, or if import 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

@JeffBezanson
Copy link
Member

Partly related: #4600

@yuyichao
Copy link
Contributor

yuyichao commented Jun 9, 2015

Shouldn't this (looking in working directory) only be done for REPL?

@jiahao
Copy link
Member

jiahao commented Jul 14, 2015

bump

Given that #9079 has been the source of several insidious bugs, I'd like to propose fixing this for 0.4.0.

@timholy
Copy link
Member

timholy commented Jul 14, 2015

I'm in favor.

@jiahao jiahao added breaking This change will break code needs decision A decision on this change is needed labels Jul 15, 2015
@JeffBezanson
Copy link
Member

superseded by discussion in #9079.

@tkelman tkelman deleted the dcjones/require branch March 22, 2016 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code needs decision A decision on this change is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants