Skip to content

Commit

Permalink
fix: properly handle just accepting a config file, without directory
Browse files Browse the repository at this point in the history
Closes #836
  • Loading branch information
ctron committed Aug 2, 2024
1 parent d0841fc commit ba7dc84
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/config/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ pub async fn load(path: Option<PathBuf>) -> Result<(Configuration, PathBuf)> {
match path {
// if we have a file, load it
Some(path) if path.is_file() => {
// Canonicalize the path to the configuration, so that we get a proper parent.
// Otherwise, we might end up with a parent of '', which won't work later on.
let path = path.canonicalize().with_context(|| {
format!(
"unable to canonicalize path to configuration: '{}'",
path.display()
)
})?;
let Some(cwd) = path.parent() else {
bail!("unable to get parent directory of '{}'", path.display());
};
Expand Down

0 comments on commit ba7dc84

Please sign in to comment.