Skip to content

Commit

Permalink
Rollup merge of rust-lang#73350 - nodakai:install-rs-support-nonexist…
Browse files Browse the repository at this point in the history
…ent-prefix, r=Mark-Simulacrum

bootstrap/install.rs: support a nonexistent `prefix` in `x.py install`

PR rust-lang#49778 introduced fs::canonicalize() which fails for a nonexistent path.
This is a surprise for someone used to GNU Autotools' configure which can create any necessary intermediate directories in prefix.

This change makes it run fs::create_dir_all() before canonicalize().
  • Loading branch information
Manishearth authored Jun 16, 2020
2 parents 8f9c002 + 8e7606f commit 0dc6c4f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ fn install_sh(
let libdir_default = PathBuf::from("lib");
let mandir_default = datadir_default.join("man");
let prefix = builder.config.prefix.as_ref().map_or(prefix_default, |p| {
fs::canonicalize(p).unwrap_or_else(|_| panic!("could not canonicalize {}", p.display()))
fs::create_dir_all(p)
.unwrap_or_else(|err| panic!("could not create {}: {}", p.display(), err));
fs::canonicalize(p)
.unwrap_or_else(|err| panic!("could not canonicalize {}: {}", p.display(), err))
});
let sysconfdir = builder.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default);
let datadir = builder.config.datadir.as_ref().unwrap_or(&datadir_default);
Expand Down

0 comments on commit 0dc6c4f

Please sign in to comment.