Automatically install packages used in script

For some time now we can do using Package and julia will prompt the installation of the package.

Wouldn’t it be nice to have a command-line option that does that, like:

julia --project -pkginstall=[no(default)/yes/prompt] script.jl

?

It feels sort of awkward having to either have a separate script (with Pkg.add(...)) or an interactive section to run the script for the first time only.

5 Likes

Nice maybe, but I’d still prefer to ship the script with a manifest to get well-defined versions.

1 Like

I think that’s orhogonal. The automatic installation could have an instantiate option for if there is a manifest file available (and could be the default in that case).

Couldnt you just store project + manifest as strings in the script like Pluto does ? On start they could be unpacked into ~/.julia/environments and activated.

1 Like

That could be an interesting feature to have, maybe, but would clutter a lot the script. But would be useful for distributing reproducible scripts.

I had comparable requirements to yours. See below links.