wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

Support custom cargo build dirs on MacOS.

Open aldhsu opened this issue 1 year ago • 3 comments

Loving wezterm! I was attempting to add new lua hooks and ran into this problem on MacOs.

Expected

Clean build succeeds on MacOS

Actual

Fails to build.

 Caused by:
      No such file or directory (os error 2)
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

aldhsu avatar Aug 03 '24 18:08 aldhsu

Thanks, but this shouldn't be needed if you follow the https://wezfurlong.org/wezterm/install/source.html instructions. What's different about your environment/setup that results in you needing this?

wez avatar Aug 03 '24 22:08 wez

Ah I see the problem. I just blindly made the folder without looking at what it's doing. I should have read the error more closely.

I use a custom CARGO_TARGET_DIR in ~/.cargo/.config.toml:

[build]
target-dir = "/Users/ahsu/.cargo/builds/"

This is so deps are shared.

Might just be my configuration but I tried cargo build -vv --target-dir=target which forces the target dir over other config and printing out the "CARGO_TARGET_DIR" env var in the build script. "CARGO_TARGET_DIR" seems to always be empty? This comment https://github.com/rust-lang/cargo/issues/9661#issuecomment-1769481293 seems to suggest that not passing "CARGO_TARGET_DIR" from Cargo to build scripts is intentional currently.

A user can set it themselves though eg. CARGO_TARGET_DIR=target cargo build -vv but this will not come from cargo.toml by default.

The script currently always falls back to the default "target" on any systems building with a custom Cargo target directory.

A general solution would be to walk back from "OUT_DIR" which is passed into the build script. I'm not sure I know enough to suggest a good solution but if the above will suffice I can amend the PR.

aldhsu avatar Aug 04 '24 10:08 aldhsu

I've updated the PR to use OUT_DIR.

aldhsu avatar Aug 06 '24 10:08 aldhsu

Can you rebase this PR so that I can tell the CI to run? Thanks!

wez avatar Feb 09 '25 20:02 wez

No problems! Done.

aldhsu avatar Feb 10 '25 00:02 aldhsu