# Julia environments list

**URL:** <https://discourse.julialang.org/t/julia-environments-list/37774>\
**Category:** New to Julia\
**Created:** [April 17, 2020, 5:39pm UTC](https://discourse.julialang.org/t/julia-environments-list/37774 "2020-04-17T17:39:27Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [November 23, 2022, 10:23pm UTC](https://discourse.julialang.org/t/julia-environments-list/37774/6 "2022-11-23T22:23:18Z")

</div>

here is my function to select and activate a user defined Julia-environment:

```julia
function select_Pkg_environment(_environment::String="")
    curr_dir = pwd()
    env_dir = joinpath(Pkg.envdir(), string("v", VERSION)[1:end-2])
    # env_dir = Pkg.envdir()
    dir_list = readdir(env_dir, join= false)
    dir_list_full = readdir(env_dir, join= true)
    env_list = []
    for i_ = eachindex(dir_list)
        if isdir(dir_list_full[i_]) 
            # println(dir_list[i_])
            push!(env_list, dir_list[i_]) 
        end
    end
    if isempty(_environment)
        if isempty(env_list)
            println("No additional environments found!")
        else
            println("---- Number of available environments: ", length(env_list), " ----")
            for i_ = eachindex(env_list)
                println(i_, ".) ",env_list[i_])
            end
            println("------------------------------------------------")
        end
    else
        if any(occursin.(_environment, string.(env_list)))
            if splitpath(Base.active_project())[end-1] != _environment
                cd(env_dir)
                Pkg.activate(_environment)
                cd(curr_dir)
                println("current dir: ", pwd())
            else
                @info(string("Environment \"", _environment, "\" is already loaded!"))
            end
        else
            @warn(string("Julia Pkg-environment: \"", _environment, "\" not found!"))
            @info("Call function without argument to list available environments.")
        end
    end
    return env_list
end

```

The strange thing is, that the command:

```julia
Pkg.activate("MyEnvironment")

```

opens a new user defined environment, if it is not yet known in a subfolder of `Pkg.envdir()`.  
And establishes the two environment files `Project.toml` & `Manifest.toml` in a sub-directory  
with the name of the user defined environment as soon as a package is added via: `Pkg.add("PackageName")`.  
But the next time I give the identical command: `Pkg.activate("MyEnvironment")`  
Pkg wants to establish a new environment definition directory at the current directory `pwd()`.  
Is this a bug or a feature?

---

_[View the full topic](https://discourse.julialang.org/t/julia-environments-list/37774)._
