Skip to content

Commit 945eb57

Browse files
authored
Merge pull request #661 from JuliaLang/juliaup-home-env-var
Use JULIAUP_DEPOT_PATH instead of JULIA_DEPOT_PATH
2 parents 8953675 + fc9fa6f commit 945eb57

11 files changed

+82
-33
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ The Julia launcher `julia` automatically determines which specific version of Ju
139139

140140
The channel is used in the order listed above, using the first available option.
141141

142+
## Path used by Juliaup
143+
144+
Juliaup will by default use the Julia depot at `~/.julia` to store Julia versions and configuration files. This can be changed by setting
145+
the `JULIAUP_DEPOT_PATH` environment variable. Caution: Previous versions of Juliaup used the content of the environment variable
146+
`JULIA_DEPOT_PATH` to locate Juliaup files, the current version changed this behavior and no longer depends on `JULIA_DEPOT_PATH`.
147+
142148
## Juliaup server
143149

144150
Juliaup by default downloads julia binary tarballs from the official server "https://julialang-s3.julialang.org".

src/global_paths.rs

+11-33
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,21 @@ pub struct GlobalPaths {
1717
}
1818

1919
fn get_juliaup_home_path() -> Result<PathBuf> {
20-
let entry_sep = if std::env::consts::OS == "windows" {
21-
';'
22-
} else {
23-
':'
24-
};
25-
26-
match std::env::var("JULIA_DEPOT_PATH") {
20+
match std::env::var("JULIAUP_DEPOT_PATH") {
2721
Ok(val) => {
28-
// Note: Docs on JULIA_DEPOT_PATH states that if it exists but is empty, it should
29-
// be interpreted as an empty array. This code instead interprets it as a 1-element
30-
// array of the default path.
31-
// We interpret it differently, because while Julia may work without a DEPOT_PATH,
32-
// Juliaup does not currently, since it must check for new versions.
33-
let mut paths = Vec::<PathBuf>::new();
34-
for segment in val.split(entry_sep) {
35-
// Empty segments resolve to the default first value of
36-
// DEPOT_PATH
37-
let segment_path = if segment.is_empty() {
38-
get_default_juliaup_home_path()?
39-
} else {
40-
PathBuf::from(segment.to_string())
41-
};
42-
paths.push(segment_path);
43-
}
22+
let val = val.trim();
23+
24+
if val.is_empty() {
25+
return get_default_juliaup_home_path();
26+
} else {
27+
let path = PathBuf::from(val);
4428

45-
// First, we try to find any directory which already is initialized by
46-
// Juliaup.
47-
for path in paths.iter() {
48-
let subpath = path.join("juliaup").join("juliaup.json");
49-
if subpath.is_file() {
50-
return Ok(path.join("juliaup"));
29+
if !path.is_absolute() {
30+
return Err(anyhow!("The current value of '{}' for the environment variable JULIAUP_DEPOT_PATH is not an absolute path.", val));
31+
} else {
32+
return Ok(PathBuf::from(val).join("juliaup"));
5133
}
5234
}
53-
// If such a file does not exist, we pick the first segment in JULIA_DEPOT_PATH.
54-
// This is guaranteed to be nonempty due to the properties of str::split.
55-
let first_path = paths.iter().next().unwrap();
56-
return Ok(first_path.join("juliaup"));
5735
}
5836
Err(_) => return get_default_juliaup_home_path(),
5937
}

tests/channel_selection.rs

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn channel_selection() {
99
.arg("add")
1010
.arg("1.6.7")
1111
.env("JULIA_DEPOT_PATH", depot_dir.path())
12+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
1213
.assert()
1314
.success()
1415
.stdout("");
@@ -18,6 +19,7 @@ fn channel_selection() {
1819
.arg("add")
1920
.arg("1.7.3")
2021
.env("JULIA_DEPOT_PATH", depot_dir.path())
22+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
2123
.assert()
2224
.success()
2325
.stdout("");
@@ -27,6 +29,7 @@ fn channel_selection() {
2729
.arg("add")
2830
.arg("1.8.5")
2931
.env("JULIA_DEPOT_PATH", depot_dir.path())
32+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
3033
.assert()
3134
.success()
3235
.stdout("");
@@ -36,6 +39,7 @@ fn channel_selection() {
3639
.arg("default")
3740
.arg("1.6.7")
3841
.env("JULIA_DEPOT_PATH", depot_dir.path())
42+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
3943
.assert()
4044
.success()
4145
.stdout("");
@@ -45,6 +49,7 @@ fn channel_selection() {
4549
.arg("-e")
4650
.arg("print(VERSION)")
4751
.env("JULIA_DEPOT_PATH", depot_dir.path())
52+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
4853
.assert()
4954
.success()
5055
.stdout("1.6.7");
@@ -55,6 +60,7 @@ fn channel_selection() {
5560
.arg("-e")
5661
.arg("print(VERSION)")
5762
.env("JULIA_DEPOT_PATH", depot_dir.path())
63+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
5864
.assert()
5965
.success()
6066
.stdout("1.8.5");
@@ -64,6 +70,7 @@ fn channel_selection() {
6470
.arg("-e")
6571
.arg("print(VERSION)")
6672
.env("JULIA_DEPOT_PATH", depot_dir.path())
73+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
6774
.env("JULIAUP_CHANNEL", "1.7.3")
6875
.assert()
6976
.success()
@@ -75,6 +82,7 @@ fn channel_selection() {
7582
.arg("-e")
7683
.arg("print(VERSION)")
7784
.env("JULIA_DEPOT_PATH", depot_dir.path())
85+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
7886
.env("JULIAUP_CHANNEL", "1.7.3")
7987
.assert()
8088
.success()
@@ -88,6 +96,7 @@ fn channel_selection() {
8896
.arg("-e")
8997
.arg("print(VERSION)")
9098
.env("JULIA_DEPOT_PATH", depot_dir.path())
99+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
91100
.assert()
92101
.failure()
93102
.stderr("ERROR: Invalid Juliaup channel `1.8.6` at command line.\n");
@@ -97,6 +106,7 @@ fn channel_selection() {
97106
.arg("-e")
98107
.arg("print(VERSION)")
99108
.env("JULIA_DEPOT_PATH", depot_dir.path())
109+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
100110
.env("JULIAUP_CHANNEL", "1.7.4")
101111
.assert()
102112
.failure()
@@ -110,6 +120,7 @@ fn channel_selection() {
110120
.arg("-e")
111121
.arg("print(VERSION)")
112122
.env("JULIA_DEPOT_PATH", depot_dir.path())
123+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
113124
.env("JULIAUP_CHANNEL", "1.7.4")
114125
.assert()
115126
.failure()

tests/command_add.rs

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn command_add() {
99
.arg("add")
1010
.arg("1.6.4")
1111
.env("JULIA_DEPOT_PATH", depot_dir.path())
12+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
1213
.assert()
1314
.success()
1415
.stdout("");
@@ -19,6 +20,7 @@ fn command_add() {
1920
.arg("-e")
2021
.arg("print(VERSION)")
2122
.env("JULIA_DEPOT_PATH", depot_dir.path())
23+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
2224
.assert()
2325
.success()
2426
.stdout("1.6.4");

tests/command_default.rs

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn command_default() {
99
.arg("add")
1010
.arg("1.6.0")
1111
.env("JULIA_DEPOT_PATH", depot_dir.path())
12+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
1213
.assert()
1314
.success()
1415
.stdout("");
@@ -18,6 +19,7 @@ fn command_default() {
1819
.arg("default")
1920
.arg("1.6.0")
2021
.env("JULIA_DEPOT_PATH", depot_dir.path())
22+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
2123
.assert()
2224
.success()
2325
.stdout("");
@@ -27,6 +29,7 @@ fn command_default() {
2729
.arg("-e")
2830
.arg("print(VERSION)")
2931
.env("JULIA_DEPOT_PATH", depot_dir.path())
32+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
3033
.assert()
3134
.success()
3235
.stdout("1.6.0");

tests/command_initial_setup_from_launcher_test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn command_initial_setup() {
1515
.unwrap()
1616
.arg("46029ef5-0b73-4a71-bff3-d0d05de42aac")
1717
.env("JULIA_DEPOT_PATH", depot_dir.path())
18+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
1819
.assert()
1920
.success()
2021
.stdout("");

tests/command_list_test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ fn command_list() {
1212
.unwrap()
1313
.arg("list")
1414
.env("JULIA_DEPOT_PATH", depot_dir.path())
15+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
1516
.assert()
1617
.success()
1718
.stdout(predicate::str::starts_with(" Channel").and(predicate::str::contains("release")));
@@ -20,6 +21,7 @@ fn command_list() {
2021
.unwrap()
2122
.arg("ls")
2223
.env("JULIA_DEPOT_PATH", depot_dir.path())
24+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
2325
.assert()
2426
.success()
2527
.stdout(predicate::str::starts_with(" Channel").and(predicate::str::contains("release")));

0 commit comments

Comments
 (0)