Skip to content

Commit

Permalink
install --sudo destination path must exist to be canonicalized (#1352)
Browse files Browse the repository at this point in the history
`fs::canonicalize` calls `realpath` which requires the dest path to
exist. It doesn't when installing the extension for the first time (and
a new version of the extension for subsequent times). So...best we can
[1] do is trust that @eeeebbbbrrrr 's canonicalization works. 🚀

[1]: https://stackoverflow.com/questions/68231306/stdfscanonicalize-for-files-that-dont-exist
  • Loading branch information
levkk authored Oct 25, 2023
1 parent e4b9a7c commit 04351c2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cargo-pgrx/src/command/sudo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ impl CommandExecute for SudoInstall {
eprintln!("Using sudo to copy extension files from {}", outdir.display().cyan());
for src in output_files {
let src = src.canonicalize()?;
let dest = make_absolute(src.strip_prefix(&outdir)?).canonicalize()?;
let dest_abs = make_absolute(src.strip_prefix(&outdir)?);
let dest = match dest_abs.canonicalize() {
Ok(path) => path,
Err(_) => dest_abs,
};

// we're about to run `sudo` to copy some files, one at a time
let mut command = Command::new("sudo"); // NB: If we ever support Windows...
Expand Down

0 comments on commit 04351c2

Please sign in to comment.