hive: Use absolute paths for non-flake hives

Fixes #107.
This commit is contained in:
Zhaofeng Li 2022-07-04 14:05:50 -07:00
parent fbf25faa24
commit b8bdf5824c
2 changed files with 4 additions and 10 deletions

View file

@ -93,7 +93,7 @@ impl HivePath {
}
}
Ok(Self::Legacy(path.to_owned()))
Ok(Self::Legacy(path.canonicalize()?))
}
fn context_dir(&self) -> Option<PathBuf> {

View file

@ -221,11 +221,13 @@ pub async fn hive_from_args(args: &ArgMatches) -> ColmenaResult<Hive> {
}
_ => {
let path = args.value_of("config").expect("The config arg should exist").to_owned();
let fpath = canonicalize_cli_path(&path);
let fpath = PathBuf::from(&path);
if !fpath.exists() && path.contains(':') {
// Treat as flake URI
let flake = Flake::from_uri(path).await?;
log::info!("Using flake: {}", flake.uri());
let hive_path = HivePath::Flake(flake);
let mut hive = Hive::new(hive_path)?;
@ -276,14 +278,6 @@ The list is comma-separated and globs are supported. To match tags, prepend the
.takes_value(true))
}
fn canonicalize_cli_path(path: &str) -> PathBuf {
if !path.starts_with('/') {
format!("./{}", path).into()
} else {
path.into()
}
}
pub async fn capture_stream<R>(mut stream: BufReader<R>, job: Option<JobHandle>, stderr: bool) -> ColmenaResult<String>
where R: AsyncRead + Unpin
{