seeker_after_truth
seeker_after_truth

Reputation: 497

Installing Julia packages using a .toml file?

I am totally new to Julia!

I would like to install a large number of packages for a project I'm joining.

The project comes with a "Project.toml" file

It seems like there should be a nice way to install all the packages I need for the project, perhaps using the Project.toml file

However, I have not yet found any site that indicates how I might be able to do this.

Could anyone please let me know if what I am doing is possible, and if so, point me to a reference that would show how?

Upvotes: 13

Views: 7755

Answers (3)

Antonello
Antonello

Reputation: 6431

The other answers went already to the point, but I want to add another important aspect.

If this project comes "only" with a Project.toml file, you will be able to install "sone version" of these packages, eventualy the Project.toml may also give you a range of versions known to work with the project you have been given.

But if this project comes also with a Manifest.toml file you will be able to recreate on your pc the exact environment, will all the exact versions of all dependent packages recursivelly, of the guy that passed you the project, using the ways desctibed in detail in the other answers (e.g. ] activate [folder]; instantiate).

Upvotes: 0

Koops
Koops

Reputation: 543

How to install julia packages from a Project.toml

First, you will have navigate to the folder containing your Project.toml.

cd ../your-folder-containing-the-project.toml-file

in your terminal:

julia --project=.

]

instantiate

or

julia --project=. -e 'using Pkg; Pkg.instantiate()

Upvotes: 3

Anshul Singhvi
Anshul Singhvi

Reputation: 1742

If your Project.toml is located in a folder, like myproject/Project.toml, you can simply start Julia with julia --project=/path/to/myproject, and it will automatically detect the Project.toml file in myproject.

The first time you activate this project, in the REPL, you can switch to Pkg mode by typing ], and type the command instantiate. This will cause the package manager to download and install all of the packages listed in Project.toml and their dependencies.

Another way to switch between projects during interactive use is to run activate /path/to/myproject in Pkg-mode in the REPL.

Upvotes: 16

Related Questions