Suggest installing un-installed packages

Maybe I’m just lazy and a bit averse to error messages but

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

wouldn’t it be nice to ask the user whether they want to try to install it with a simple y/n ?

julia> using SomePackageThatIDontHave
INFO: Package SomePackageThatIDontHave not found in current path:
- do you want to try to install it? [y/n]
y
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
  Updating `~/.julia/environments/v1.4/Project.toml`
...

(apologies if this has already been suggested somewhere else)

1 Like

Ref https://github.com/JuliaLang/julia/pull/26469.

Let’s make it happen for 1.4!

7 Likes

thanks! so much good stuff yet to be merged…

I actually had this working in an early prototype of Pkg3 but all the other code loading stuff was so tricky to get right that I ended up not doing this part in the final version.

FWIW, It was added in https://github.com/JuliaLang/Pkg.jl/pull/24.

3 Likes