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

CARGO_MANIFEST_DIR does not point to a real directory #422

Open
marctrem opened this issue Jun 24, 2021 · 2 comments
Open

CARGO_MANIFEST_DIR does not point to a real directory #422

marctrem opened this issue Jun 24, 2021 · 2 comments

Comments

@marctrem
Copy link

Summary: I think that the environment variable, CARGO_MANIFEST_DIR, might be set to a wrong value.

Depending on the latest wasm-bindgen leads to a failing build. The problem seems to be that CARGO_MANIFEST_DIR does not point to a directory.

I verified by modifying the build.rs and listing the contents of CARGO_MANIFEST_DIR – I'm greeted by ENOENT.

The value of CARGO_MANIFEST_DIR is :
home/myuser/.cache/bazel/_bazel_myuser/016369211d582554423d7c843e54e025/sandbox/linux-sandbox/213/execroot/reponame/third_party/cargo/vendor/wasm-bindgen-shared-0.2.74

The working directory when executing that build.rs is:
/home/myuser/.cache/bazel/_bazel_myuser/016369211d582554423d7c843e54e025/sandbox/linux-sandbox/226/execroot/reponame/bazel-out/k8-opt-exec-2B5CBBC6/bin/third_party/cargo/vendor/wasm-bindgen-shared-0.2.74/wasm_bindgen_shared_build_script_script_.runfiles/monor/third_party/cargo/vendor/wasm-bindgen-shared-0.2.74

I can get the build to succeed when changing the build.rs this way.

Can you confirm or refute that it's working as intended?

Thank you!

@briansmith
Copy link

I can get the build to succeed when changing the build.rs this way.

The Cargo documentation on environment variables in build scripts was recently updated to make it clear that you need to use std::env::var* and not env! to access these environment variables in build scripts, and you need to use env! and not std::env::var* to access these environment variables outside build scripts. Further, the build script documentation says:

In addition to environment variables, the build script’s current directory is the source directory of the build script’s package.

So, your proposed change is correct. If you changed that code to use std::env::var_os("CARGO_MANIFEST_DIR") instead of env! then I would expect it to also be correct.

@jfirebaugh
Copy link

This was fixed in wasm-bindgen 0.2.76: rustwasm/wasm-bindgen#2657

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

3 participants