Is the flag --project expected to activate/instantiate?

I run julia as julia --project=., and I get
So it looks like just using this command line flag did not cause activate/instantiate to run. Is that expected?

activate and instantiate are two separate operations.

Doing julia --project=/foo/bar is roughly equivalent to starting Julia with julia and then doing import Pkg; Pkg.activate("/foo/bar").

Starting Julia with julia --project=/foo/bar does not do an instantiate; you need to do the import Pkg; Pkg.instantiate() yourself. This is the expected behavior.


So it is not possible to do both with a single command line flag? I think that is a missed opportunity. Usually when I have a freshly downloaded project, it will require both, as far as I understand? So then I have to start julia and do “using package, package activate, package update”?

You can do julia --project and then ] up. So a little bit simpler.

(if you are in the directory there’s no need for the ="." in --project=".")

You could also create a shortcut for:

% julia --project -i -e "import Pkg; Pkg.update()"

if you need that very often.

If you are working interactively at the REPL, you can make these instructions a bit more concise by using the Pkg REPL mode.

So you’d have two options.

Option 1: Start Julia with julia --project and do the following:

] instantiate

Option 2: Start Julia with julia and do the following:

] activate .
] instantiate

I think the ship has probably sailed on changing the behavior of julia --project=/foo/bat.

If we really want to have a way of doing the instantiating with a command-line flag, we could add a new command-line flag named --instantiate.

And then julia --project=/foo-bar --instantiate would be equivalent to starting Julia with julia --project=/foo/bar and then doing import Pkg; Pkg.instantiate().

I’m not sure if this saves a whole lot of time (or typing).

1 Like

Also, note that Pkg.instantiate() and Pkg.update() are two very different operations. If you’ve just cloned a fresh Julia project that includes a Manifest.toml, and you want to instantiate the same environment as the author of that project, then you want to do Pkg.instantiate().

Pkg.update() may modify the manifest, and thus you won’t have the same setup as the author of the project.

1 Like

In this thread I am thinking of running on HPC via SLURM.