Skip to content
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

make julialauncher have saner error messages for channels and versions #767

24 changes: 21 additions & 3 deletions src/bin/julialauncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,27 @@ fn get_julia_path_from_channel(
.installed_channels
.get(channel)
.ok_or_else(|| match juliaup_channel_source {
JuliaupChannelSource::CmdLine => UserError { msg: format!("ERROR: Invalid Juliaup channel `{}` at command line.", channel).to_string() }.into(),
JuliaupChannelSource::EnvVar => UserError { msg: format!("ERROR: Invalid Juliaup channel `{}` in environment variable JULIAUP_CHANNEL.", channel).to_string() }.into(),
JuliaupChannelSource::Override => UserError { msg: format!("ERROR: Invalid Juliaup channel `{}` in directory override.", channel).to_string() }.into(),
JuliaupChannelSource::CmdLine => {
if versions_db.available_channels.contains_key(channel) {
UserError { msg: format!("`{}` is not installed. Please run `juliaup add {}` to install channel or version.", channel, channel) }
} else {
UserError { msg: format!("ERROR: Invalid Juliaup channel `{}`. Please run `juliaup list` to get a list of valid channels and versions.", channel) }
}
}.into(),
JuliaupChannelSource::EnvVar=> {
if versions_db.available_channels.contains_key(channel) {
UserError { msg: format!("`{}` for environment variable JULIAUP_CHANNEL is not installed. Please run `juliaup add {}` to install channel or version.", channel, channel) }
} else {
UserError { msg: format!("ERROR: Invalid Juliaup channel `{}` in environment variable JULIAUP_CHANNEL. Please run `juliaup list` to get a list of valid channels and versions.", channel) }
}
}.into(),
JuliaupChannelSource::Override=> {
if versions_db.available_channels.contains_key(channel) {
UserError { msg: format!("`{}` for directory override is not installed. Please run `juliaup add {}` to install channel or version.", channel, channel) }
} else {
UserError { msg: format!("ERROR: Invalid Juliaup channel `{}` in directory override. Please run `juliaup list` to get a list of valid channels and versions.", channel) }
}
}.into(),
JuliaupChannelSource::Default => anyhow!("The Juliaup configuration is in an inconsistent state, the currently configured default channel `{}` is not installed.", channel)
})?;

Expand Down
6 changes: 3 additions & 3 deletions tests/channel_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn channel_selection() {
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.assert()
.failure()
.stderr("ERROR: Invalid Juliaup channel `1.8.6` at command line.\n");
.stderr("ERROR: Invalid Juliaup channel `1.8.6`. Please run `juliaup list` to get a list of valid channels and versions.\n");

Command::cargo_bin("julialauncher")
.unwrap()
Expand All @@ -111,7 +111,7 @@ fn channel_selection() {
.assert()
.failure()
.stderr(
"ERROR: Invalid Juliaup channel `1.7.4` in environment variable JULIAUP_CHANNEL.\n",
"ERROR: Invalid Juliaup channel `1.7.4` in environment variable JULIAUP_CHANNEL. Please run `juliaup list` to get a list of valid channels and versions.\n",
);

Command::cargo_bin("julialauncher")
Expand All @@ -124,5 +124,5 @@ fn channel_selection() {
.env("JULIAUP_CHANNEL", "1.7.4")
.assert()
.failure()
.stderr("ERROR: Invalid Juliaup channel `1.8.6` at command line.\n");
.stderr("ERROR: Invalid Juliaup channel `1.8.6`. Please run `juliaup list` to get a list of valid channels and versions.\n");
}
Loading