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

Topiary panics with -vv when the configuration is not a regular file #823

Open
Xophmeister opened this issue Jan 3, 2025 · 0 comments
Open

Comments

@Xophmeister
Copy link
Member

When Topiary's logging attempts to output the name of the configuration file -- with -vv (or higher) -- and the configuration file is not a regular file, then it panics. Here:

Self::File(path) => {
// We only stringify the path when we know it exists, so the call to `canonicalize`
// is safe to unwrap. (All bets are off, if called from elsewhere.)
write!(f, "{}", path.canonicalize().unwrap().to_string_lossy())
}

By "not a regular file" I mean, for example, via process substitution:

$ topiary config -vvC <(cat topiary-config/languages.ncl)
[2025-01-03T16:52:08Z INFO  topiary_config::source] Could not find configuration file: /home/chris/.config/topiary. Defaulting to built-in configuration.
thread 'main' panicked at topiary-config/src/source.rs:129:53:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Using process substitution like this is a good way to create a quick-and-dirty self-contained wrapper script. While this is not something that should be encouraged, Topiary shouldn't crash in this case (or, at least, the error message should be more instructive).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant