Skip to content

Commit e946960

Browse files
committed
Use home crate to determini cargo home
1 parent 02dffd4 commit e946960

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edition = "2018"
1212
bitcoincore-rpc = "0.13"
1313
tempfile = "3.1"
1414
log = "0.4"
15-
dirs-next = "2.0.0"
15+
home = "0.5.3" # use same ver in build-dep
1616

1717
[dev-dependencies]
1818
env_logger = "0.8"
@@ -22,6 +22,7 @@ ureq = "2.1"
2222
bitcoin_hashes = "0.9"
2323
flate2 = "1.0"
2424
tar = "0.4"
25+
home = "0.5.3"
2526

2627
[features]
2728
"0_21_1" = []

build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ fn main() {
3636
}
3737
let download_filename = download_filename();
3838
let expected_hash = get_expected_sha256(&download_filename).unwrap();
39-
let bitcoin_exe_home = format!("{}/bitcoin", std::env::var("CARGO_HOME").unwrap());
39+
let bitcoin_exe_home = format!(
40+
"{}/bitcoin",
41+
home::cargo_home()
42+
.expect("cannot determine CARGO_HOME")
43+
.display()
44+
);
4045
let existing_filename: PathBuf =
4146
format!("{}/bitcoin-{}/bin/bitcoind", &bitcoin_exe_home, VERSION).into();
4247

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ pub fn downloaded_exe_path() -> Option<String> {
258258
// CARGO_HOME surely available only in `build.rs` here we need to get from home_dir
259259
if versions::HAS_FEATURE {
260260
Some(format!(
261-
"{}/.cargo/bitcoin/bitcoin-{}/bin/bitcoind",
262-
dirs_next::home_dir()?.display(),
261+
"{}/bitcoin/bitcoin-{}/bin/bitcoind",
262+
home::cargo_home().ok()?.display(),
263263
versions::VERSION
264264
))
265265
} else {

0 commit comments

Comments
 (0)