diff --git a/Cargo.lock b/Cargo.lock index 45007448614bcd..9693bff233b8ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7573,6 +7573,7 @@ dependencies = [ "assert_matches", "chrono", "clap 2.33.3", + "dirs-next", "rpassword", "solana-clock", "solana-cluster-type", @@ -7603,6 +7604,7 @@ dependencies = [ "assert_matches", "chrono", "clap 3.2.23", + "dirs-next", "rpassword", "solana-clock", "solana-cluster-type", diff --git a/clap-utils/Cargo.toml b/clap-utils/Cargo.toml index a0e9f610816e4a..29e86304ba686c 100644 --- a/clap-utils/Cargo.toml +++ b/clap-utils/Cargo.toml @@ -18,6 +18,7 @@ name = "solana_clap_utils" [dependencies] chrono = { workspace = true, features = ["default"] } clap = "2.33.0" +dirs-next = { workspace = true } rpassword = { workspace = true } solana-clock = { workspace = true } solana-cluster-type = { workspace = true } diff --git a/clap-utils/src/keypair.rs b/clap-utils/src/keypair.rs index 421d1a2df2ebe7..2501cb27acd236 100644 --- a/clap-utils/src/keypair.rs +++ b/clap-utils/src/keypair.rs @@ -175,10 +175,17 @@ impl DefaultSigner { } }) .map_err(|_| { + // Use the system default path in the error message instead of the configured path + let default_path = dirs_next::home_dir() + .map(|mut path| { + path.extend([".config", "solana", "id.json"]); + path.to_str().unwrap_or(&self.path).to_string() + }) + .unwrap_or_else(|| self.path.clone()); std::io::Error::other(format!( "No default signer found, run \"solana-keygen new -o {}\" to create a new \ one", - self.path + default_path )) })?; *self.is_path_checked.borrow_mut() = true; diff --git a/clap-v3-utils/Cargo.toml b/clap-v3-utils/Cargo.toml index 68e6c44ba6379b..81f20d5315181b 100644 --- a/clap-v3-utils/Cargo.toml +++ b/clap-v3-utils/Cargo.toml @@ -22,6 +22,7 @@ elgamal = ["dep:solana-zk-sdk"] [dependencies] chrono = { workspace = true, features = ["default"] } clap = { version = "3.2.23", features = ["cargo"] } +dirs-next = { workspace = true } rpassword = { workspace = true } solana-clock = { workspace = true } solana-cluster-type = { workspace = true } diff --git a/clap-v3-utils/src/keypair.rs b/clap-v3-utils/src/keypair.rs index 4022775b88ea7d..c82089f0c069db 100644 --- a/clap-v3-utils/src/keypair.rs +++ b/clap-v3-utils/src/keypair.rs @@ -171,10 +171,17 @@ impl DefaultSigner { } }) .map_err(|_| { + // Use the system default path in the error message instead of the configured path + let default_path = dirs_next::home_dir() + .map(|mut path| { + path.extend([".config", "solana", "id.json"]); + path.to_str().unwrap_or(&self.path).to_string() + }) + .unwrap_or_else(|| self.path.clone()); std::io::Error::other(format!( "No default signer found, run \"solana-keygen new -o {}\" to create a new \ one", - self.path + default_path )) })?; *self.is_path_checked.borrow_mut() = true; diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index b7a95166192011..434473d98c9eeb 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -6057,6 +6057,7 @@ version = "3.1.0" dependencies = [ "chrono", "clap", + "dirs-next", "rpassword", "solana-clock", "solana-cluster-type",