What is the command line option to create temporary environments in Julia v1.6 again?
The julia --help
didn't help with this.
You can use ] activate --temp
from inside Julia for this.
If you want a command line option you can use julia --project=$(mktemp -d)
. I use that 100 times every day.
Perhaps a special symbol would make sense? We already have --project=@.
as a special case even though it is not documented properly in the julia --help
.
BTW, what is the meaning of --project=@.
again? I know we can create global environments with --project=@myenv
.
I think @.
is like "this directory or any parent, recursive." so if you do it in a subfolder of a project, assuming that subfolder doesn't have it's own Project.toml
, it will find the parent project
But somehow it falls back to .julia/environments/{VERSION}
if there aren't any parents. Something about LOAD_PATH
or something that I've never really bothered to look into
It doesn't fall back to .julia/environments/{VERSION}
if it doesn't find anything, it is just that .julia/environments/{VERSION}
is the second entry in LOAD_PATH
and since the first entry is empty you will see the second one.
$ julia -E 'Base.load_path()'
["/home/fredrik/.julia/environments/v1.6/Project.toml", "/opt/julia/julia-1.6/share/julia/stdlib/v1.6"]
$ julia --project=. -E 'Base.load_path()'
["/tmp/tmp.PHh4X0AE7V/Project.toml", "/home/fredrik/.julia/environments/v1.6/Project.toml", "/opt/julia/julia-1.6/share/julia/stdlib/v1.6"]
The standard pattern in Pluto (where you do not have access to Pkg REPL mode) is
using Pkg
Pkg.activate(mktempdir())
Pkg.add("MyRequirement")
Do you think it would be a good idea to document these behaviors of the option --project better in the --help output ?
Last updated: Nov 06 2024 at 04:40 UTC