Stream: helpdesk (published)

Topic: How to create temporary environments?


view this post on Zulip Júlio Hoffimann (Jan 20 2021 at 11:17):

What is the command line option to create temporary environments in Julia v1.6 again?

The julia --help didn't help with this.

view this post on Zulip Simeon Schaub (Jan 20 2021 at 11:19):

You can use ] activate --temp from inside Julia for this.

view this post on Zulip Fredrik Ekre (Jan 20 2021 at 12:37):

If you want a command line option you can use julia --project=$(mktemp -d). I use that 100 times every day.

view this post on Zulip Júlio Hoffimann (Jan 20 2021 at 12:52):

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.

view this post on Zulip Kevin Bonham (Jan 20 2021 at 14:32):

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

view this post on Zulip Kevin Bonham (Jan 20 2021 at 14:34):

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

view this post on Zulip Fredrik Ekre (Jan 20 2021 at 14:51):

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.

view this post on Zulip Fredrik Ekre (Jan 20 2021 at 14:52):

$ 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"]

view this post on Zulip Benjamin Lungwitz (Jan 20 2021 at 15:10):

The standard pattern in Pluto (where you do not have access to Pkg REPL mode) is

using Pkg
Pkg.activate(mktempdir())
Pkg.add("MyRequirement")

view this post on Zulip Júlio Hoffimann (Jan 20 2021 at 15:15):

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