Skip to content

Commit

Permalink
Merge pull request #1014 from JuliaLang/check-permissions-during-install
Browse files Browse the repository at this point in the history
Check file permissions before installing
  • Loading branch information
davidanthoff authored Aug 21, 2024
2 parents 2592249 + ca4c600 commit 17d9def
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/bin/juliainstaller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,43 @@ pub fn main() -> Result<()> {
return Ok(());
}

if install_choices.modifypath {
// Now check whether we have the necessary permissions for all the files
// we want to modify.

let paths = find_shell_scripts_to_be_modified(false)?;

let mut failed_paths: Vec<PathBuf> = Vec::<PathBuf>::new();

for cur_path in paths {
let file_result = std::fs::OpenOptions::new()
.read(true)
.write(true)
.open(&cur_path);

if file_result.is_err() {
failed_paths.push(cur_path.clone());
}
}

if failed_paths.len() > 0 {
println!("Juliaup needs to modify a number of existing files on your");
println!("system, but is unable to edit some of these files. Most likely");
println!("this is caused by incorrect permissions on these files. The");
println!("following files could not be edited:");
for cur_path in failed_paths {
println!(" {}", cur_path.display());
}
println!("You can find more help with this problem at");
println!(
" https://github.com/JuliaLang/juliaup/wiki/Permission-problems-during-setup"
);
println!();

return Ok(());
}
}

let juliaupselfbin = install_choices.install_location.join("bin");

trace!("Set juliaupselfbin to `{:?}`", juliaupselfbin);
Expand Down

0 comments on commit 17d9def

Please sign in to comment.