Skip to content

Commit

Permalink
Support shared named environments during startup (#40025)
Browse files Browse the repository at this point in the history
* Support shared named envs during startup

* Improved handling of named envs during startup

Co-authored-by: Jameson Nash <[email protected]>

* Improve tests for --project and JULIA_PROJECT

* Add news item about shared env support at startup

Co-authored-by: Jameson Nash <[email protected]>
  • Loading branch information
oschulz and vtjnash committed Mar 24, 2021
1 parent 08006c4 commit 10ab32f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Compiler/Runtime improvements
Command-line option changes
---------------------------

* The Julia `--project` option and the `JULIA_PROJECT` environment variable now support selecting shared environments like `.julia/environments/myenv` the same way the package management console does: use `julia --project=@myenv` resp. `export JULIA_PROJECT="@myenv"` ([#40025]).


Multi-threading changes
-----------------------
Expand Down
2 changes: 1 addition & 1 deletion base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ function init_active_project()
ACTIVE_PROJECT[] =
project === nothing ? nothing :
project == "" ? nothing :
project == "@." ? current_project() : abspath(expanduser(project))
startswith(project, "@") ? load_path_expand(project) : abspath(expanduser(project))
end

## load path expansion: turn LOAD_PATH entries into concrete paths ##
Expand Down
13 changes: 10 additions & 3 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,16 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`

# ~ expansion in --project and JULIA_PROJECT
if !Sys.iswindows()
expanded = abspath(expanduser("~/foo"))
@test occursin(expanded, readchomp(`$exename --project='~/foo' -E 'Base.active_project()'`))
@test occursin(expanded, readchomp(setenv(`$exename -E 'Base.active_project()'`, "JULIA_PROJECT" => "~/foo", "HOME" => homedir())))
let expanded = abspath(expanduser("~/foo/Project.toml"))
@test expanded == readchomp(`$exename --project='~/foo' -e 'println(Base.active_project())'`)
@test expanded == readchomp(setenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "~/foo", "HOME" => homedir()))
end
end

# handling of @projectname in --project and JULIA_PROJECT
let expanded = abspath(Base.load_path_expand("@foo"))
@test expanded == readchomp(`$exename --project='@foo' -e 'println(Base.active_project())'`)
@test expanded == readchomp(setenv(`$exename -e 'println(Base.active_project())'`, "JULIA_PROJECT" => "@foo", "HOME" => homedir()))
end

# --quiet, --banner
Expand Down

0 comments on commit 10ab32f

Please sign in to comment.