Skip to content

Commit f8e7121

Browse files
committed
feat: add @temp to the DEFAULT_LOAD_PATH
1 parent 75a85a6 commit f8e7121

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

base/initdefs.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ end
122122
# entries starting with `@` are named environments:
123123
# - the first three `#`s in a named environment are replaced with version numbers
124124
# - `@stdlib` is a special name for the standard library and expands to its path
125+
# - `@temp` expands to a temporary directory path
125126

126127
# if you want a current env setup, use direnv and
127128
# have your .envrc do something like this:
@@ -131,21 +132,23 @@ end
131132
# this will inherit an existing JULIA_LOAD_PATH value or if there is none, leave
132133
# a trailing empty entry in JULIA_LOAD_PATH which will be replaced with defaults.
133134

134-
const DEFAULT_LOAD_PATH = ["@", "@v#.#", "@stdlib"]
135+
const DEFAULT_LOAD_PATH = ["@", "@temp", "@v#.#", "@stdlib"]
135136

136137
"""
137138
LOAD_PATH
138139
139140
An array of paths for `using` and `import` statements to consider as project
140141
environments or package directories when loading code. It is populated based on
141142
the [`JULIA_LOAD_PATH`](@ref JULIA_LOAD_PATH) environment variable if set;
142-
otherwise it defaults to `["@", "@v#.#", "@stdlib"]`. Entries starting with `@`
143+
otherwise it defaults to `["@", "@temp", "@v#.#", "@stdlib"]`. Entries starting with `@`
143144
have special meanings:
144145
145146
- `@` refers to the "current active environment", the initial value of which is
146147
initially determined by the [`JULIA_PROJECT`](@ref JULIA_PROJECT) environment
147148
variable or the `--project` command-line option.
148149
150+
- `@temp` expands to a temporary directory.
151+
149152
- `@stdlib` expands to the absolute path of the current Julia installation's
150153
standard library directory.
151154

test/loading.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ end
683683

684684
# Base.active_project when version directory exist in depot, but contains no project file
685685
mktempdir() do dir
686-
vdir = Base.DEFAULT_LOAD_PATH[2]
686+
vdir = Base.DEFAULT_LOAD_PATH[3]
687687
vdir = replace(vdir, "#" => VERSION.major, count = 1)
688688
vdir = replace(vdir, "#" => VERSION.minor, count = 1)
689689
vdir = replace(vdir, "#" => VERSION.patch, count = 1)
@@ -699,6 +699,10 @@ mktempdir() do dir
699699
@test success(cmd)
700700
end
701701

702+
@testset "`@temp` in `DEFAULT_LOAD_PATH`" begin
703+
@test tempdir() == Base.load_path_expand(Base.DEFAULT_LOAD_PATH[2])[1:lastindex(tempdir())]
704+
end
705+
702706
@testset "expansion of JULIA_LOAD_PATH" begin
703707
s = Sys.iswindows() ? ';' : ':'
704708
tmp = "/this/does/not/exist"

0 commit comments

Comments
 (0)