Is there a short version of: `Pkg.TOML.parse(open("Project.toml"))["deps"] |> keys |> collect .|> Pkg.add`?

I was trying to add the required depedencies from a repo with a Project.toml file. I tried
activate/update/resolve etc. They did things… except seemingly add any packages. I finally used the
code snippet above to read the file and add the packages therein.

I’m obviously missing something.

Very confused.

I don’t really understand why you wold want to do this. You can just start Julia with --project in the repo or call Pkg.activate(...) with the path to the repo and then do Pkg.instantiate() and off you go.

1 Like

Sometimes I instantiate a project and nothing seems to happen, but it’s because I already have all of the dependencies installed (generally from another project with similar requirements). If you do using ... for one of the dependencies, does it work?

It’s an odd package… It’s a server written in julia and not destined for the REPL. There’s
a supervisord service that just has basically: /path/to/bin/julia /path/to/repo/startup.jl.

(So it’s running in the main ~/.julia/environments/v1.5/ environment).

As I said all my attempts with the REPL package manager failed. That little snippet did the trick (I guess it is using the package manger!) … but I don’t know why I couldn’t do it an “official” way.

The “official” way would be something like

/path/to/bin/julia --project=/path/to/repo /path/to/repo/startup.jl

where the top of startup.jl would have

using Pkg; Pkg.instantiate()

alternatively:

/path/to/bin/julia --project=/path/to/repo -e 'using Pkg; Pkg.instanttiate()'
/path/to/bin/julia --project=/path/to/repo /path/to/repo/startup.jl

This seem strange, why don’t you want to isolate the server environment?

2 Likes