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

refactor: disable julia startup file for julia package update #983

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,11 @@
# and the update will be installed system-wide, i.e., available to all users.
# (default: false)
# use_sudo = false

[julia]
# If enabled, Topgrade invokes julia with the --startup-file=yes CLI option.
#
# This may be desirable to avoid loading outdated packages with "using" directives
# in the startup file which would cause the update run to fail.
# (default: true)
# startup_file = true
16 changes: 16 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ pub struct Lensfun {
use_sudo: Option<bool>,
}

#[derive(Deserialize, Default, Debug, Merge)]
pub struct JuliaConfig {
Laura7089 marked this conversation as resolved.
Show resolved Hide resolved
startup_file: Option<bool>,
}

#[derive(Deserialize, Default, Debug, Merge)]
#[serde(deny_unknown_fields)]
/// Configuration file
Expand Down Expand Up @@ -518,6 +523,9 @@ pub struct ConfigFile {

#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
lensfun: Option<Lensfun>,

#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
julia: Option<JuliaConfig>,
}

fn config_directory() -> PathBuf {
Expand Down Expand Up @@ -1632,6 +1640,14 @@ impl Config {
.and_then(|lensfun| lensfun.use_sudo)
.unwrap_or(false)
}

pub fn julia_use_startup_file(&self) -> bool {
self.config_file
.julia
.as_ref()
.and_then(|julia| julia.startup_file)
.unwrap_or(true)
}
}

#[cfg(test)]
Expand Down
13 changes: 9 additions & 4 deletions src/steps/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,10 +908,15 @@ pub fn update_julia_packages(ctx: &ExecutionContext) -> Result<()> {

print_separator(t!("Julia Packages"));

ctx.run_type()
.execute(julia)
.args(["-e", "using Pkg; Pkg.update()"])
.status_checked()
let mut executor = ctx.run_type().execute(julia);

executor.arg(if ctx.config().julia_use_startup_file() {
"--startup-file=yes"
} else {
"--startup-file=no"
});

executor.args(["-e", "using Pkg; Pkg.update()"]).status_checked()
}

pub fn run_helm_repo_update(ctx: &ExecutionContext) -> Result<()> {
Expand Down