Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Compiler/Runtime improvements
Command-line option changes
---------------------------

* The bundled depots are now always appended to `DEPOT_PATH` when `JULIA_DEPOT_PATH` is set,
removing the need for a trailing `:` or `;`. Set `JULIA_DEPOT_PATH_BUNDLED=false` to disable
this behavior.
* The option `--sysimage-native-code=no` has been deprecated.
* The `JULIA_CPU_TARGET` environment variable now supports a `sysimage` keyword to match (or extend) the CPU target used to build the current system image ([#58970]).
* The `--code-coverage=all` option now automatically throws away sysimage caches so that code coverage can be accurately measured on methods within the sysimage. It is thrown away after startup (and after startup.jl), before any user code is executed ([#59234])
Expand Down
10 changes: 8 additions & 2 deletions base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ function init_depot_path()
# explicitly setting JULIA_DEPOT_PATH to the empty string means using no depot
isempty(str) && return

# otherwise, populate the depot path with the entries in JULIA_DEPOT_PATH,
# expanding empty strings to the bundled depot
pushfirst_default = true
bundled_added = false
for (i, path) in enumerate(eachsplit(str, Sys.iswindows() ? ';' : ':'))
if isempty(path)
# empty entry triggers bundled depot append for backwards compatibility
append_bundled_depot_path!(DEPOT_PATH)
bundled_added = true
else
path = expanduser(path)
path in DEPOT_PATH || push!(DEPOT_PATH, path)
Expand All @@ -131,6 +132,11 @@ function init_depot_path()
if pushfirst_default
pushfirst!(DEPOT_PATH, joinpath(homedir(), ".julia"))
end

# always append bundled depots unless explicitly disabled or already added via empty entry
if !bundled_added && get_bool_env("JULIA_DEPOT_PATH_BUNDLED", true) === true
append_bundled_depot_path!(DEPOT_PATH)
end
else
push!(DEPOT_PATH, joinpath(homedir(), ".julia"))
append_bundled_depot_path!(DEPOT_PATH)
Expand Down
31 changes: 20 additions & 11 deletions doc/src/manual/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,20 @@ as Julia's code loading mechanisms, look for package registries, installed packa
environments, repo clones, cached compiled package images, configuration files, and the default
location of the REPL's history file.

When [`JULIA_DEPOT_PATH`](@ref JULIA_DEPOT_PATH) is set, the bundled depots (containing resources
shipped with Julia, like cache files, artifacts, etc.) are always appended to `DEPOT_PATH`,
unless [`JULIA_DEPOT_PATH_BUNDLED`](@ref JULIA_DEPOT_PATH_BUNDLED) is set to `false`.
For example, to switch the user depot to `/foo/bar`:
```sh
export JULIA_DEPOT_PATH="/foo/bar"
```
All package operations, like cloning registries or installing packages, will now write to
`/foo/bar`, and the bundled resources will still be available.

Unlike the shell `PATH` variable but similar to [`JULIA_LOAD_PATH`](@ref JULIA_LOAD_PATH),
empty entries in [`JULIA_DEPOT_PATH`](@ref JULIA_DEPOT_PATH) have special behavior:
- At the end, it is expanded to the default value of `DEPOT_PATH`, *excluding* the user depot.
- At the start, it is expanded to the default value of `DEPOT_PATH`, *including* the user depot.
This allows easy overriding of the user depot, while still retaining access to resources that
are bundled with Julia, like cache files, artifacts, etc. For example, to switch the user depot
to `/foo/bar` use a trailing `:`
```sh
export JULIA_DEPOT_PATH="/foo/bar:"
```
All package operations, like cloning registries or installing packages, will now write to
`/foo/bar`, but since the empty entry is expanded to the default system depot, any bundled
resources will still be available. If you really only want to use the depot at `/foo/bar`,
and not load any bundled resources, simply set the environment variable to `/foo/bar`
without the trailing colon.

To append a depot at the end of the full default list, including the default user depot, use a
leading `:`
Expand Down Expand Up @@ -180,6 +179,16 @@ it to the string `:`.
directly modify the `DEPOT_PATH` array, which is populated from the environment
variable.

### [`JULIA_DEPOT_PATH_BUNDLED`](@id JULIA_DEPOT_PATH_BUNDLED)

Controls whether the bundled depots (containing resources shipped with Julia) are
automatically appended to [`DEPOT_PATH`](@ref) when [`JULIA_DEPOT_PATH`](@ref JULIA_DEPOT_PATH)
is set. By default, bundled depots are always included. Set to a falsy value
(e.g., `false`, `no`, or `0`) to disable this behavior:
```sh
export JULIA_DEPOT_PATH_BUNDLED=false
```

### [`JULIA_HISTORY`](@id JULIA_HISTORY)

The absolute path `REPL.find_hist_file()` of the REPL's history file. If
Expand Down
10 changes: 10 additions & 0 deletions test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -841,10 +841,12 @@ end
tmp = "/this/does/not/exist"
default = joinpath(homedir(), ".julia")
bundled = Base.append_bundled_depot_path!(String[])
# With the new behavior, bundled depots are always appended unless JULIA_DEPOT_PATH_BUNDLED=false
cases = Dict{Any,Vector{String}}(
nothing => [default; bundled],
"" => [],
"$s" => [default; bundled],
"$tmp" => [tmp; bundled], # bundled depots now always appended
"$tmp$s" => [tmp; bundled],
"$s$tmp" => [default; bundled; tmp],
)
Expand All @@ -855,6 +857,14 @@ end
cmd = pipeline(cmd; stdout, stderr)
@test success(cmd)
end
# Test JULIA_DEPOT_PATH_BUNDLED=false disables bundled depot appending
for bundled_val in ["false", "0", "no"]
script = "DEPOT_PATH == $(repr([tmp])) || error(\"actual depot \" * join(DEPOT_PATH,':') * \" does not match expected depot \" * join($(repr([tmp])), ':'))"
cmd = `$(Base.julia_cmd()) --startup-file=no -e $script`
cmd = addenv(cmd, "JULIA_DEPOT_PATH" => tmp, "JULIA_DEPOT_PATH_BUNDLED" => bundled_val)
cmd = pipeline(cmd; stdout, stderr)
@test success(cmd)
end
end

@testset "Issue #25719" begin
Expand Down