Sending code to REPL automatically installs packages without prompt

Hi all,

So my REPL workflow involves sending code to the Julia REPL to be evaluated into the running environment. This is in contrast to typing code into the REPL manually.

Unfortunately if there’s an import SomePackage statement (or using) contained in the sent code, the Julia REPL will automatically download, install, and compile any missing packages without prompt.

There is supposed to be a prompt, but the prompt was designed so that a newline is interpreted as yes, and for yes to be the default selection. Because import statements are often followed by newlines in code, evaluating sent code will skip right through the prompt to download, install and compile any missing packages.

First, I don’t think it’s a good idea to have yes be the default answer to installation and compilation of arbitrary libraries, let alone newline.

But second, while sending a code block is an “interactive” action, the evaluation of a code block itself should not be. Any imports of missing packages should fail with errors under those conditions. Is there some way to modulate the behaviour of the REPL so that it does not expect user prompts while evaluating blocks of code?

Thanks!

In case anyone else is interested, my current workaround is to have the following inside my ~/.julia/config/startup.jl file:

import Pkg

empty!(Pkg.REPL.install_packages_hooks)

With the above configured, any import or using statement of a missing package will result in an error, with no prompt to install.

A more robust solution at the tooling level might be to wrap sent code with some middleware that unsets the hooks before evaluation, and resets the hooks after.