Skip to content

Commit 8db6fdd

Browse files
authored
Improve environments section (#144)
* slight consistency improvements * mention how to create environments explicitly * explicit recommendation to use project-specific, local environments
1 parent 48ada30 commit 8db6fdd

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

writing/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,13 @@ println("hello world")
346346

347347
## Environments
348348

349-
\tldr{Activate a local environment for each project with `]activate path`. Its details are stored in `Project.toml` and `Manifest.toml`.}
349+
\tldr{Activate a local environment for each project with `]activate path`. Its details are stored in `path/Project.toml` and `path/Manifest.toml`.}
350350

351351
As we have seen, Pkg.jl is the Julia equivalent of `pip` or `conda` for Python.
352352
It lets you [install packages](https://pkgdocs.julialang.org/v1/managing-packages/) and [manage environments](https://pkgdocs.julialang.org/v1/environments/) (collections of packages with specific versions).
353353

354354
You can activate an environment from the Pkg REPL by specifying its path `]activate somepath`.
355+
You create new environments simply by activating a path that does not contain an environment. The necessary files are created automatically once you `]add` packages.
355356
Typically, you would do `]activate .` to activate the environment in the current directory.
356357
Another option is to directly start Julia inside an environment, with the command line option `julia --project=somepath`.
357358

@@ -360,9 +361,10 @@ Once in an environment, the packages you `]add` will be listed in two files `som
360361
* `Project.toml` contains general project information (name of the package, unique id, authors) and direct dependencies with version bounds.
361362
* `Manifest.toml` contains the exact versions of all direct and indirect dependencies
362363

363-
If you haven't entered any local project, packages will be installed in the default environment, called `@v1.X` after the active version of Julia (note the `@` before the name).
364+
If you haven't activated any local project, packages will be installed in the default environment, called `@v1.X` after the active version of Julia (note the `@` before the name).
364365
Packages installed that way are available no matter which local environment is active, because of "environment [stacking](https://docs.julialang.org/en/v1/manual/code-loading/#Environment-stacks)".
365-
It is recommended to keep the default environment very light to avoid dependencies conflicts. It should contain only essential development tools.
366+
It is recommended to keep the default environment very light to avoid dependency conflicts. It should contain only essential development tools.
367+
Create a separate local environment for each of your projects to contain the dependencies specific to that project.
366368

367369
\vscode{
368370

0 commit comments

Comments
 (0)