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

Can't locate downloaded binary after repository is moved #77

Closed
MaxFangX opened this issue Jul 30, 2022 · 1 comment
Closed

Can't locate downloaded binary after repository is moved #77

MaxFangX opened this issue Jul 30, 2022 · 1 comment

Comments

@MaxFangX
Copy link

MaxFangX commented Jul 30, 2022

For some reason, after I moved the location of my repository which uses bitcoind in its dev-dependencies, downloaded_exe_path() continues returning the old path. Everything from target/... onwards is correct - I've verified that there is indeed a bitcoind binary in that location - but the path to the repo seems to remain constant even across system restarts.

How to reproduce

Platform: macOS
Rust version: nightly-2022-06-27-x86_64-apple-darwin
bitcoind crate version: 0.26.1

Have this in Cargo.toml:

[dev-dependencies]
bitcoind = { version = "0.26", features = [ "22_0" ] }

Ensure that OUT_DIR is not set in env vars

echo $OUT_DIR

Have this test:

#[cfg(test)]
mod test {
    fn bitcoind_fails() {
        let conf = Conf::default();
        let exe_path = bitcoind::downloaded_exe_path()
            .expect("Didn't specify bitcoind version in feature flags");

        // This prints
        // [node/src/command/test/mod.rs:72] &exe_path = "<path_to_OLD_repo_location>/target/debug/build/bitcoind-65c3b20abafd4893/out/bitcoin/bitcoin-22.0/bin/bitcoind"
        // Aside from the path to the repo, everything else is correct
        dbg!(&exe_path);

        // This causes the code not to compile
        // let out_dir = std::env!("OUT_DIR");
        // This panics
        // let out_dir = std::env::var_os("OUT_DIR").unwrap();

        // This panics when running from new repository location
        let bitcoind = BitcoinD::with_conf(exe_path, &conf)
            .expect("Failed to init bitcoind");
    }
}

Run the test (should pass)

Move the repository, e.g. from $HOME/dev/myrepo to $HOME/dev/bitcoin/myrepo

Rerun the test (should fail)

What I've tried, but which still produce the same error

  • cargo clean
  • rm -rf <path_to_repo>/target
  • rm -rf ~/.cargo/registry
  • rm -rf ~/.cargo/git
  • cargo cache -e
  • Cloning the repo to a new location on the same computer
  • Even restarting my computer

Workarounds which prevent the panic (but which don't solve the problem)

  • Downgrading to 0_21_0 in Cargo.toml: bitcoind = { version = "0.26", features = [ "0_21_0" ] }
  • Specifying bitcoind using a relative path bitcoind = { path = "../../../github/bitcoind", version = "0.26", features = [ "22_0" ] }
  • Moving the repo back to its original location

Any idea what could be going on?

@MaxFangX
Copy link
Author

I have no idea what the cause was, but nuking the whole repository and recloning it (to the same, new location) appears to have fixed it. Maybe there was some magic git caching going on, idk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant