Skip to content

Feature request: activate environment on top of current stack #1245

@nickrobinson251

Description

@nickrobinson251

Sometimes it is useful to create a new environment stacked on the current environment
(where the current environment is not the "base" v1.x environment)

e.g. Have both "Level1" and "Level2" packages available by doing something like this

(v1.1) pkg> activate Level1
[ Info: activating new environment at ~/Level1.

(Level1) pkg> add Example
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
  Updating `~/Level1/Project.toml`
  [7876af07] + Example v0.5.1
  Updating `~/Level1/Manifest.toml`
  [7876af07] + Example v0.5.1
  ...

(Level1) pkg> activate Level2
[ Info: activating new environment at ~/Level2.

julia> using Example
ERROR: ArgumentError: Package Example not found in current path:
- Run `import Pkg; Pkg.add("Example")` to install the Example package.

Stacktrace:
 [1] require(::Module, ::Symbol) at ./loading.jl:823

julia> LOAD_PATH
3-element Array{String,1}:
 "@"
 "@v#.#"
 "@stdlib"

^ This doesn't stack Level2 on Level1

The workaround is to pushfirst!(LOAD_PATH, "path/to/Level1") (Thanks @fredrikekre for pointing this out).

e.g.

julia> pushfirst!(Base.LOAD_PATH, "/Users/nick/Level1")
6-element Array{String,1}:
 "/Users/nick/Level1"
 "@"
 "@v#.#"
 "@stdlib"

(Level2) pkg> status
    Status `~/Level2/Project.toml`
  (empty environment)

julia> using Example
[ Info: Precompiling Example [7876af07-990d-54b4-ab0e-23690620f79a]

Perhaps this can be an argument to activate? e.g. activate --stack Level2, to first add the current environment to the LOAD_PATH before activating the new one?

(I think this has some relation to #1233 ...and maybe #621)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions