Skip to content

Commit

Permalink
CLI: better support config dir lookup on Windows
Browse files Browse the repository at this point in the history
There's an issue with `home_dir()` in the rust stdlib for Windows
currently. A fix is coming in Rust 1.86. In the meantime let's use what
cargo uses.
  • Loading branch information
svix-onelson committed Dec 23, 2024
1 parent d4ed432 commit 2261987
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 10 additions & 0 deletions svix-cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions svix-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ concolor-clap = "0.1.0"
dialoguer = "0.11.0"
figment = { version = "0.10.19", features = ["toml", "env"] }
futures-util = "0.3.31"
home = "0.5.11"
http = "1.2.0"
# Reduce compile times for idna (we don't need the fastest possible impl of UTS 46)
# As per https://github.com/hsivonen/idna_adapter?tab=readme-ov-file#opting-to-use-unicode-rs
Expand Down
6 changes: 3 additions & 3 deletions svix-cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ fn get_folder() -> Result<PathBuf> {
let pb = match config_path {
Ok(path) => PathBuf::from(path),
Err(_e) => {
// FIXME: home_dir() can give incorrect results on Windows. Docs recommend "use a crate instead"
#[allow(deprecated)]
std::env::home_dir().ok_or_else(|| anyhow::anyhow!("unable to find config path"))?
// N.b. per <https://github.com/rust-lang/cargo/blob/master/crates/home/README.md> the
// stdlib should be fixed as of Rust 1.86.
home::home_dir().ok_or_else(|| anyhow::anyhow!("unable to find config path"))?
}
};
Ok(pb.join(".config").join("svix"))
Expand Down

0 comments on commit 2261987

Please sign in to comment.