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

Trunk fails to run if given a custom config file without path #836

Closed
fiadliel opened this issue Aug 2, 2024 · 1 comment
Closed

Trunk fails to run if given a custom config file without path #836

fiadliel opened this issue Aug 2, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@fiadliel
Copy link

fiadliel commented Aug 2, 2024

Platform: MacOS
Version: Rev 32837ee of https://github.com/trunk-rs/trunk#328378ee

Trunk fails to run if given a custom config file without path.

$ trunk serve --config Trunk.test.toml
2024-08-02T06:04:50.980015Z  INFO 🚀 Starting trunk 0.21.0-alpha.4
2024-08-02T06:04:50.981228Z ERROR unable to canonicalize ''

This looks like an unfortunate interaction between PathBuf::parent and fs::canonicalize. It seems that given a bare filename, PathBuf::parent returns Some("") (empty string). However, fs::canonicalize does not consider this to represent the current working directory. Looking at the implementation, it is basically just a call to realpath in libc. And the POSIX specification for realpath says that passing an empty string should result in an error.

trunk does run with trunk serve --config $(pwd)/Trunk.test.toml or even trunk serve --config ./Trunk.test.toml.

References:

let Some(cwd) = path.parent() else {

.canonicalize()

https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.parent
https://doc.rust-lang.org/std/fs/fn.canonicalize.html
https://github.com/rust-lang/rust/blob/051478957371ee0084a7c0913941d2a8c4757bb9/library/std/src/sys/pal/unix/fs.rs#L1814
https://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html

@ctron ctron added the bug Something isn't working label Aug 2, 2024
@ctron
Copy link
Collaborator

ctron commented Aug 2, 2024

Interesting. It also works if you have a relative directory path upfront, like I use for testing examples/foo/Trunk.toml. Or just the directory: foo (which defaults to Trunk.toml).

@ctron ctron self-assigned this Aug 2, 2024
ctron added a commit to ctron/trunk that referenced this issue Aug 2, 2024
@ctron ctron closed this as completed in ba7dc84 Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants