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

missing packages still print out "use Pkg.add()" #28553

Closed
affans opened this issue Aug 9, 2018 · 7 comments
Closed

missing packages still print out "use Pkg.add()" #28553

affans opened this issue Aug 9, 2018 · 7 comments

Comments

@affans
Copy link
Contributor

affans commented Aug 9, 2018

See

julia> using StatsBase
ERROR: ArgumentError: Package StatsBase not found in current path:
- Run `Pkg.add("StatsBase")` to install the StatsBase package.

Stacktrace:
 [1] require(::Module, ::Symbol) at ./loading.jl:817
julia> Pkg.add("StatsBase")
ERROR: UndefVarError: Pkg not defined
Stacktrace:
 [1] top-level scope at none:0
julia> versioninfo()
Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)
@fredrikekre
Copy link
Member

You need to load Pkg first; import Pkg. I guess we can update the suggestion in the error message

@affans
Copy link
Contributor Author

affans commented Aug 9, 2018

Thanks. That loads Pkg3 right? I fixed the issue by ] and typing add StatsBase.

I agree a better error message will be more helpful for newcomers (and even some intermediate users like me).

If you don't pointing out where this can be done, I'll be happy to do a PR.

@fredrikekre
Copy link
Member

That loads Pkg3 right?

Yes, Pkg3 was renamed to Pkg.

I'll be happy to do a PR.

Sure, here you go!

diff --git a/base/loading.jl b/base/loading.jl
index 7feb1cdd26..f55f75498d 100644
--- a/base/loading.jl
+++ b/base/loading.jl
@@ -816,7 +816,7 @@ function require(into::Module, mod::Symbol)
         if where.uuid === nothing
             throw(ArgumentError("""
                 Package $mod not found in current path:
-                - Run `Pkg.add($(repr(String(mod))))` to install the $mod package.
+                - Run `import Pkg; Pkg.add($(repr(String(mod))))` to install the $mod package.
                 """))
         else
             s = """

@affans
Copy link
Contributor Author

affans commented Aug 10, 2018

Thanks, PR done. so for future reference loading.jl is mainly used for package managing code?

@StefanKarpinski
Copy link
Member

This is why I had Pkg exported by InteractiveUtils; we're going to keep getting this bug report.

@KristofferC
Copy link
Member

KristofferC commented Aug 14, 2018

It would be good if we could add this back but fix the previous two problems:

  • Not introduce a cycle in the stdlib dependencies
  • Be able to load another package called Pkg so we can still develop it.

@fredrikekre
Copy link
Member

Can we just put import Pkg in a default startup.jl file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants