You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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).
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.
This looks like an unfortunate interaction between
PathBuf::parent
andfs::canonicalize
. It seems that given a bare filename,PathBuf::parent
returnsSome("")
(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 torealpath
in libc. And the POSIX specification forrealpath
says that passing an empty string should result in an error.trunk does run with
trunk serve --config $(pwd)/Trunk.test.toml
or eventrunk serve --config ./Trunk.test.toml
.References:
trunk/src/config/models/mod.rs
Line 122 in 328378e
trunk/src/config/rt/core.rs
Line 26 in 328378e
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
The text was updated successfully, but these errors were encountered: