Usability tweak for Pkg

I find myself very often doing something like this:

(v1.0) pkg> up
  Updating ........................

(v1.0) pkg> using MyPkg
ERROR: expected command. instead got [using]

I propose that using (and possibly some other keywords) switch back to the julia> prompt before executing.

1 Like

I think this is too much DWIM.

(Tangentially related: https://github.com/JuliaLang/julia/issues/27555 )

2 Likes

I guess @mauro3 is right.

But I also walked into this trap a couple of times. In my case I (mis)use using SomePackage to precompile a particular package, a functionality that the pkg REPL mode should probably have. However, there is only precompile which precompiles all packages. Since we are about to have status SomePackage maybe we should also add precompile SomePackage.

UPDATE: See https://github.com/JuliaLang/Pkg.jl/issues/888

I do this constantly. I think maybe that switching back to the julia> prompt but not executing might be a good idea.

(v1.0) pkg> using MyPkg

julia> using MyPkg

That way the user can just hit Enter one more time to do what s/he meant, and it avoids behavior that might be surprising to some.

I find myself doing this a lot too but I have a different solution in mind for the issue: when someone does using X in an interactive environment and X has not been added, prompt them interactively if they want to add X (and if there is more than one thing named X which one they want).

4 Likes

Command completion in the repl switches automagically

 julia> activ [up key]
pkg> usin [up key] 
julia>

It’s not “automagic”: history includes what mode each command was entered in. If you had entered julia> activate(something) most recently then that’s what you’d get.

1 Like