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

wasm-pack do not find the correct target/ folder #496

Closed
eivbsmed opened this issue Jan 15, 2019 · 3 comments
Closed

wasm-pack do not find the correct target/ folder #496

eivbsmed opened this issue Jan 15, 2019 · 3 comments

Comments

@eivbsmed
Copy link

🐛 Bug description

wasm-pack do not find the correct target/ folder when using a root level Cargo.toml to define a multi crate work space

🤔 Expected Behavior

It should find the files where the work space put the. In the target folder on the root level.

👟 Steps to reproduce

Set up a workspace whit multiple crates. One of them having a wasm target. Try to compile

  [1/9] Checking `rustc` version...
  [2/9] Checking crate configuration...
  [3/9] Adding WASM target...
  info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date
  [4/9] Compiling to WASM...
     Compiling id_generator v0.1.0 (<redacted>/id_generator)
      Finished release [optimized] target(s) in 0.27s
  [5/9] Creating a pkg directory...
  [6/9] Writing a package.json...
   [INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
  [7/9] Copying over your README...
  :-) [WARN]: origin crate has no README
  wasm-bindgen 0.2.31 (b04f60cf2)
  [8/9] wasm-bindgen already installed...
  [9/9] Running WASM-bindgen...
  error: failed to read `target/wasm32-unknown-unknown/release/id_generator.wasm`
|       caused by: No such file or directory (os error 2)
Running the wasm-bindgen CLI
Caused by: Process exited with exit code: 1: `wasm-bindgen` did not exit successfully.

stdout:

stderr:

error: failed to read `target/wasm32-unknown-unknown/release/id_generator.wasm`
        caused by: No such file or directory (os error 2)

The file can be found at ../target/wasm32-unknown-unknown/release/id_generator.wasm

🌍 Your environment

Include the relevant details of your environment.
wasm-pack version: 0.5.1
rustc version: 1.31.1 (b6c32da9b 2018-12-18)

@ashleygwilliams
Copy link
Member

if you install wasm-pack from master today it will now support workspaces! i'm working super hard to get the release out today (there's been a few set backs...) but this should be released and fixed for you soon!

closing, as this is fixed on master

@eivbsmed
Copy link
Author

Thank you :-) I'll test it tomorrow

@kaimast
Copy link

kaimast commented Nov 18, 2021

Did you test this with custom values for CARGO_TARGET_DIR?

I'm trying to work around rust-lang/cargo#8716 by setting a different target directory.
However, when setting the target dir to something like build, wasm-pack generates binaries in the crate's folder, not the top-level workspace folder.
As a result it fails to generate the final package, with an error like the one below:

error: failed to read `/home/kai/dev/simba/build/wasm32-unknown-unknown/debug/simba_wasm.wasm`

Caused by:
    0: failed to read `/home/kai/dev/simba/build/wasm32-unknown-unknown/debug/simba_wasm.wasm`
    1: No such file or directory (os error 2)
Error: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit status: 1

  full command: "/home/kai/.cache/.wasm-pack/wasm-bindgen-e63eccbd87203048/wasm-bindgen" "/home/kai/dev/simba/build/wasm32-unknown-unknown/debug/simba_wasm.wasm" "--out-dir" "./simba-wasm/pkg" "--typescript" "--target" "web" "--debug"

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