Skip to content

Commit 7635b12

Browse files
StefanKarpinskisimeonschaub
authored andcommitted
active project: get rid of the concept of a home project (JuliaLang#36434)
This makes doing `julia --project` equivalent to activating the project that the current directory is in at Julia startup. What this means is that if you do `pkg> activate` instead of taking you back to whatever project was initially active, it will make it as if you had never activated a project in the first place.
1 parent fb2e8b6 commit 7635b12

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

NEWS.md

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ Compiler/Runtime improvements
2424
Command-line option changes
2525
---------------------------
2626

27+
* There is no longer a concept of "home project": starting `julia --project=dir`
28+
is now exactly equivalent to starting `julia` and then doing `pkg> activate
29+
$dir` and `julia --project` is exactly equivalent to doing that where
30+
`dir = Base.current_project()`. In particular, this means that if you do
31+
`pkg> activate` after starting `julia` with the `--project` option (or with
32+
`JULIA_PROJECT` set) it will take you to the default active project, which is
33+
`@v1.5` unless you have modified `LOAD_PATH`. ([#36434])
2734

2835
Multi-threading changes
2936
-----------------------

base/Base.jl

+1
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ function __init__()
399399
# initialize loading
400400
init_depot_path()
401401
init_load_path()
402+
init_active_project()
402403
nothing
403404
end
404405

base/initdefs.jl

+8-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function init_depot_path()
101101
end
102102
end
103103

104-
## LOAD_PATH, HOME_PROJECT & ACTIVE_PROJECT ##
104+
## LOAD_PATH & ACTIVE_PROJECT ##
105105

106106
# JULIA_LOAD_PATH: split on `:` (or `;` on Windows)
107107
# first empty entry is replaced with DEFAULT_LOAD_PATH, the rest are skipped
@@ -155,6 +155,7 @@ See also:
155155
[Code Loading](@ref Code-Loading).
156156
"""
157157
const LOAD_PATH = copy(DEFAULT_LOAD_PATH)
158+
# HOME_PROJECT is no longer used, here just to avoid breaking things
158159
const HOME_PROJECT = Ref{Union{String,Nothing}}(nothing)
159160
const ACTIVE_PROJECT = Ref{Union{String,Nothing}}(nothing)
160161

@@ -211,14 +212,17 @@ function init_load_path()
211212
paths = filter!(env -> env !== nothing,
212213
[env == "@." ? current_project() : env for env in DEFAULT_LOAD_PATH])
213214
end
215+
append!(empty!(LOAD_PATH), paths)
216+
end
217+
218+
function init_active_project()
214219
project = (JLOptions().project != C_NULL ?
215220
unsafe_string(Base.JLOptions().project) :
216221
get(ENV, "JULIA_PROJECT", nothing))
217-
HOME_PROJECT[] =
222+
ACTIVE_PROJECT[] =
218223
project === nothing ? nothing :
219224
project == "" ? nothing :
220225
project == "@." ? current_project() : abspath(expanduser(project))
221-
append!(empty!(LOAD_PATH), paths)
222226
end
223227

224228
## load path expansion: turn LOAD_PATH entries into concrete paths ##
@@ -262,7 +266,7 @@ end
262266
load_path_expand(::Nothing) = nothing
263267

264268
function active_project(search_load_path::Bool=true)
265-
for project in (ACTIVE_PROJECT[], HOME_PROJECT[])
269+
for project in (ACTIVE_PROJECT[],)
266270
project == "@" && continue
267271
project = load_path_expand(project)
268272
project === nothing && continue

base/loading.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ function load_path_setup_code(load_path::Bool=true)
11941194
code *= """
11951195
append!(empty!(Base.LOAD_PATH), $(repr(load_path)))
11961196
ENV["JULIA_LOAD_PATH"] = $(repr(join(load_path, Sys.iswindows() ? ';' : ':')))
1197-
Base.HOME_PROJECT[] = Base.ACTIVE_PROJECT[] = nothing
1197+
Base.ACTIVE_PROJECT[] = nothing
11981198
"""
11991199
end
12001200
return code
@@ -1206,7 +1206,7 @@ function include_package_for_output(input::String, depot_path::Vector{String}, d
12061206
append!(empty!(Base.DL_LOAD_PATH), dl_load_path)
12071207
append!(empty!(Base.LOAD_PATH), load_path)
12081208
ENV["JULIA_LOAD_PATH"] = join(load_path, Sys.iswindows() ? ';' : ':')
1209-
Base.HOME_PROJECT[] = Base.ACTIVE_PROJECT[] = nothing
1209+
Base.ACTIVE_PROJECT[] = nothing
12101210
Base._track_dependencies[] = true
12111211
append!(empty!(Base._concrete_dependencies), concrete_deps)
12121212

stdlib/InteractiveUtils/src/InteractiveUtils.jl

-3
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,9 @@ function report_bug(kind)
365365
mktempdir() do tmp
366366
old_load_path = copy(LOAD_PATH)
367367
push!(empty!(LOAD_PATH), joinpath(tmp, "Project.toml"))
368-
old_home_project = Base.HOME_PROJECT[]
369-
Base.HOME_PROJECT[] = nothing
370368
Pkg.add(Pkg.PackageSpec(BugReportingId.name, BugReportingId.uuid))
371369
BugReporting = Base.require(BugReportingId)
372370
append!(empty!(LOAD_PATH), old_load_path)
373-
Base.HOME_PROJECT[] = old_home_project
374371
end
375372
end
376373
else

test/loading.jl

-3
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,10 @@ end
183183

184184
saved_load_path = copy(LOAD_PATH)
185185
saved_depot_path = copy(DEPOT_PATH)
186-
saved_home_project = Base.HOME_PROJECT[]
187186
saved_active_project = Base.ACTIVE_PROJECT[]
188187

189188
push!(empty!(LOAD_PATH), "project")
190189
push!(empty!(DEPOT_PATH), "depot")
191-
Base.HOME_PROJECT[] = nothing
192190
Base.ACTIVE_PROJECT[] = nothing
193191

194192
@test load_path() == [abspath("project","Project.toml")]
@@ -667,7 +665,6 @@ end
667665

668666
append!(empty!(LOAD_PATH), saved_load_path)
669667
append!(empty!(DEPOT_PATH), saved_depot_path)
670-
Base.HOME_PROJECT[] = saved_home_project
671668
Base.ACTIVE_PROJECT[] = saved_active_project
672669

673670
# issue #28190

0 commit comments

Comments
 (0)