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

Check file permissions before installing #1014

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Changes from all 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
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());
}
}
kdheepak marked this conversation as resolved.
Show resolved Hide resolved

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