-
Notifications
You must be signed in to change notification settings - Fork 91
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
Centralize where paths are discovered #915
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,13 +289,11 @@ | |
return Ok(()); | ||
} | ||
|
||
// TODO At some point we could put this behind a conditional compile, we know | ||
// that we don't ship a bundled version for some platforms. | ||
let full_version_string_of_bundled_version = get_bundled_julia_version(); | ||
let my_own_path = std::env::current_exe()?; | ||
let path_of_bundled_version = my_own_path | ||
.parent() | ||
.unwrap() // unwrap OK because we can't get a path that does not have a parent | ||
let path_of_bundled_version = &paths | ||
.juliaupselfexecfolder | ||
.join("BundledJulia"); | ||
|
||
let child_target_foldername = format!("julia-{}", fullversion); | ||
|
@@ -575,8 +573,8 @@ | |
Ok(()) | ||
} | ||
|
||
pub fn remove_symlink(symlink_name: &String) -> Result<()> { | ||
let symlink_path = get_bin_dir() | ||
pub fn remove_symlink(symlink_name: &String, paths: &GlobalPaths) -> Result<()> { | ||
let symlink_path = get_bin_dir(paths) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment (second half): #886 (comment) If the Also, using the somewhat arbitrary |
||
.with_context(|| "Failed to retrieve binary directory while trying to remove a symlink.")? | ||
.join(symlink_name); | ||
|
||
|
@@ -597,7 +595,7 @@ | |
symlink_name: &String, | ||
paths: &GlobalPaths, | ||
) -> Result<()> { | ||
let symlink_folder = get_bin_dir() | ||
Check failure on line 598 in src/operations.rs
|
||
.with_context(|| "Failed to retrieve binary directory while trying to create a symlink.")?; | ||
|
||
let symlink_path = symlink_folder.join(symlink_name); | ||
|
@@ -707,15 +705,10 @@ | |
} | ||
|
||
#[cfg(feature = "selfupdate")] | ||
pub fn install_background_selfupdate(interval: i64) -> Result<()> { | ||
pub fn install_background_selfupdate(interval: i64, paths: &GlobalPaths) -> Result<()> { | ||
use itertools::Itertools; | ||
use std::process::Stdio; | ||
|
||
let own_exe_path = std::env::current_exe() | ||
.with_context(|| "Could not determine the path of the running exe.")?; | ||
|
||
let my_own_path = own_exe_path.to_str().unwrap(); | ||
|
||
match std::env::var("WSL_DISTRO_NAME") { | ||
// This is the WSL case, where we schedule a Windows task to do the update | ||
Ok(val) => { | ||
|
@@ -728,10 +721,10 @@ | |
&interval.to_string(), | ||
"/tn", | ||
&format!("Juliaup self update for WSL {} distribution", val), | ||
"/f", | ||
"/it", | ||
"/tr", | ||
&format!("wsl --distribution {} {} self update", val, my_own_path), | ||
&format!("wsl --distribution {} {} self update", val, &paths.juliaupselfexec), | ||
]) | ||
.output() | ||
.with_context(|| "Failed to create new Windows task for juliaup.")?; | ||
|
@@ -748,7 +741,7 @@ | |
.chain([ | ||
&format!( | ||
"*/{} * * * * {} 4c79c12db1d34bbbab1f6c6f838f423f", | ||
interval, my_own_path | ||
interval, &paths.juliaupselfexec | ||
), | ||
"", | ||
]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I don't really understand why we are doing this, i.e. why we start with the path to the binary, then take the parent, and then reconstruct the path to the binary here. BUT, that is how the code was before, and I'm nervous about changing it... And this might have been related to deal with some symbolic links stuff that I don't fully understand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I struggle to see the point of it as well. The only scenario I can think of for the reason of that, is that in windows
current_exe
doesn't return (maybe it didn't in the past?) the.exe
suffix.Dealing with symbolic links should be handled by
.canonicalize()
now anyway.