-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for specifying shared named environments on Julia start #35354
Comments
It would be awesome if the |
diff --git a/base/initdefs.jl b/base/initdefs.jl
index 85a3d57..f90f5c5 100644
--- a/base/initdefs.jl
+++ b/base/initdefs.jl
@@ -217,7 +217,9 @@ function init_load_path()
HOME_PROJECT[] =
project === nothing ? nothing :
project == "" ? nothing :
- project == "@." ? current_project() : abspath(expanduser(project))
+ project == "@." ? current_project() :
+ startswith(project, '@') ? find_env_in_depot(project[2:end]) :
+ abspath(expanduser(project))
append!(empty!(LOAD_PATH), paths)
end
@@ -235,17 +237,7 @@ function load_path_expand(env::AbstractString)::Union{String, Nothing}
env = replace(env, '#' => VERSION.minor, count=1)
env = replace(env, '#' => VERSION.patch, count=1)
name = env[2:end]
- # look for named env in each depot
- for depot in DEPOT_PATH
- path = joinpath(depot, "environments", name)
- isdir(path) || continue
- for proj in project_names
- file = abspath(path, proj)
- isfile_casesensitive(file) && return file
- end
- end
- isempty(DEPOT_PATH) && return nothing
- return abspath(DEPOT_PATH[1], "environments", name, project_names[end])
+ return find_env_in_depot(name)
end
# otherwise, it's a path
path = abspath(env)
@@ -261,6 +253,20 @@ function load_path_expand(env::AbstractString)::Union{String, Nothing}
end
load_path_expand(::Nothing) = nothing
+# looks for named env in each depot
+function find_env_in_depot(name::String)
+ for depot in DEPOT_PATH
+ path = joinpath(depot, "environments", name)
+ isdir(path) || continue
+ for proj in project_names
+ file = abspath(path, proj)
+ isfile_casesensitive(file) && return file
+ end
+ end
+ isempty(DEPOT_PATH) && return nothing
+ return abspath(DEPOT_PATH[1], "environments", name, project_names[end])
+end
+
function active_project(search_load_path::Bool=true)
for project in (ACTIVE_PROJECT[], HOME_PROJECT[])
project == "@" && continue Will break people that have directories with |
Thanks, @fredrikekre ! |
In the same way that it breaks them in the REPL case, right? And they can always use |
I guess we can assume few (or no) people will use directory names starting with "@" :-) |
Yes, it would be good if we supported this consistently. |
Would @fredrikekre 's solution be acceptable? |
@fredrikekre , are you planning to make a PR? If you have your hands full, I can do it, but I don't want to claim credit for your solution. |
Go ahead. You can put me as co-author if you think it matters. |
Ok, I'll see that I get this in for v1.6. |
Sorry, kinda missed that v1.6 window (by a lot), due to overload ... |
Sorry this took so long, for such a tiny thing: #40025 |
To my knowledge, it's currently not possible to specify shared named environments via
JULIA_PROJECT
orjulia --project=...
without using the full path.It would be very useful to have an equivalent to
] activate --shared ...
- both for convenience, but also because the full path may be system-dependent, making things complicated in a heterogeneous environment, esp. when access to remote systems is involved.See also https://discourse.julialang.org/t/activating-a-shared-named-environment-via-julia-project/36975 .
The text was updated successfully, but these errors were encountered: