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

Npm package for version 0.10.0 does not work at all on Windows #1038

Closed
Pauan opened this issue Jul 22, 2021 · 17 comments
Closed

Npm package for version 0.10.0 does not work at all on Windows #1038

Pauan opened this issue Jul 22, 2021 · 17 comments

Comments

@Pauan
Copy link
Contributor

Pauan commented Jul 22, 2021

🐛 Bug description

Version 0.10.0 of the npm package is completely broken on Windows.

Previous versions of wasm-pack worked correctly.

It also works correctly on Linux, this is a Windows-only regression.

This completely breaks the Rollup plugin (on Windows).

🤔 Expected Behavior

It should work correctly.

👟 Steps to reproduce

  1. Create a simple package which uses the wasm-pack npm library:
{
    "dependencies": {
        "wasm-pack": "^0.10.0"
    },
    "scripts": {
        "build": "wasm-pack build"
    }
}
  1. Run yarn install
  2. Run yarn build

You will see the following error:

yarn run v1.22.10
warning package.json: No license field
$ wasm-pack build
You must install wasm-pack before you can run it
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The important line is this:

You must install wasm-pack before you can run it

It seems that version 0.10.0 is not installing wasm-pack automatically (like how it should). Perhaps this is a regression in binary-install?

🌍 Your environment

Include the relevant details of your environment.
wasm-pack version: 0.10.0
rustc version: 1.55.0-nightly (32c9b7b09 2021-07-21)

@janpio
Copy link

janpio commented Aug 6, 2021

I can confirm this problem.

@celsobonutti
Copy link

Same thing happening here, on archlinux

@Keavon
Copy link

Keavon commented Aug 27, 2021

Any updates? Still stuck on 0.9.1 with the security vulnerability until this is solved.

@Keavon
Copy link

Keavon commented Aug 27, 2021

It looks like this issue is a duplicate of #1026 (so maybe this one should be closed). There is some more discussion about possible workarounds and causes in that issue (something about Perl, strangely?).

Pinging @amrbashir @mztikk @Rizary @Boslx @janpio @celsobonutti @TimoWilhelm who all gave their 👍 to this issue, you might also want to 👍 #1026.

@Pauan
Copy link
Contributor Author

Pauan commented Aug 27, 2021

@Keavon It's not a duplicate. This issue is about the npm package (which uses precompiled binaries). That issue is about compiling wasm-pack from source.

@Keavon
Copy link

Keavon commented Aug 27, 2021

@Pauan Ah, thanks for clarifying! I would assume that this issue is due to that issue, at least? Regardless, since that one at least has a workaround, this one should be a higher priority.

@drager mentioned in #1024 that he added wasm-pack-init.exe, is that related? Does the missing precompiled binary get downloaded from the wasm-pack website or is it built into the npm distributable (that might thus need a new point release to update)?

@Pauan
Copy link
Contributor Author

Pauan commented Aug 27, 2021

@Keavon I don't think it's related at all.

The wasm-pack binary is downloaded from here.

@Keavon
Copy link

Keavon commented Aug 27, 2021

The wasm-pack binary is downloaded from here.

@Pauan Sorry for my confusion, do you mean the npm package, during installation, downloads from that link on GitHub, specifically wasm-pack-init.exe? If so, does that mean the wasm-pack-init.exe executable was successfully compiled (it says it's 5.58 MB in size) but the actual code fails to install it correctly on our Windows systems? I just want to understand the problem, and I'm only using npm not installing binaries directly.

Based on your better understanding of the problem than me, can you think of some steps forward that we as a community could take to debugging this and submitting a PR?

@Pauan
Copy link
Contributor Author

Pauan commented Aug 27, 2021

Yes, it downloads the package from the releases page. This is the code which does that.

It does not download the wasm-pack-init.exe, it downloads the .tar.gz (which contains the actual wasm-pack binary).

It correctly installs the node_modules/.bin/wasm-pack and node_modules/.bin/wasm-pack.cmd files.

It also correctly installs the node_modules/wasm-pack/run.js and node_modules/wasm-pack/binary.js files.

All of that works identically to version 0.9.1, so it seems the problem is something in binary-install.

The error is caused by this code in binary-install. That code didn't exist in version 0.9.1.

I don't know why that is failing, but that's as far as my investigation went.

@drager
Copy link
Member

drager commented Sep 1, 2021

Unfortunately I don't run Windows myself, so quite hard for me to debug this... But I'll see if I can get a VM with Windows running and try. I installed wasm-pack 0.10.0 via yarn and that works fine on macOS and Linux.

@celsobonutti You said it didn't work on arch linux, however, is this the same issue or some other issue?

@Keavon
Copy link

Keavon commented Sep 1, 2021

@drager I'd be happy to jump on a Discord call with you and we can pair debug it on my Windows machine if you're interested.

@drager
Copy link
Member

drager commented Sep 1, 2021

@drager I'd be happy to jump on a Discord call with you and we can pair debug it on my Windows machine if you're interested.

Thanks for offering! But I managed to get a VM running with Windows 10 on my Linux machine. I did a quick investigation and I could reproduce it. One thing I noticed is that if you run npm install wasm-pack and then looks in node_modules\binary-install you will find a folder called bin with a wasm-pack.exe file in it. If you run it node_modules\binary-install\bin\wasm-pack.exe new my_template and then node_modules\binary-install\bin\wasm-pack.exe build my_template both of those works fine! Not sure why wasm-pack.exe is still left in bin folder in binary-install. If we look in node_modules/.bin there's no .exe file there, just one without file extension and a wasm-pack.cmd and a wasm-pack.ps1

However, by removing this check https://github.com/EverlastingBugstopper/binary-install/blob/main/packages/binary-install/index.js#L76-L78 in my node_modules it seems to be working...

Meaning the bug seems the be that check only ☝️i.e. buggy binary-install. It does not take file extensions into consideration. this.binaryPath is simply node_modules\binary-install\bin\wasm-pack and not node_modules\binary-install\bin\wasm-pack.exe and wasm-pack does not exists in that folder. wasm-pack.exe does.

@celsobonutti
Copy link

@drager I'm not sure if it's the same cause, but I do get the exact same problem/message. Using 0.9.1 solves it, though.

@drager
Copy link
Member

drager commented Sep 5, 2021

I just published https://www.npmjs.com/package/wasm-pack/v/0.10.1 that hopefully will work fine on Windows. Please let me know if it does or doesn't. 🙏

@janpio
Copy link

janpio commented Sep 5, 2021

Looking good, for me at least!

C:\Users\Jan\Documents\throwaway  (throwaway@1.0.0)
λ npm init -y
Wrote to C:\Users\Jan\Documents\throwaway\package.json:

{
  "name": "throwaway",
  "version": "1.0.0",
  "main": "index.js",
  "directories": {
    "doc": "docs"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "prisma": "^2.30.2"
  },
  "devDependencies": {},
  "description": ""
}



C:\Users\Jan\Documents\throwaway  (throwaway@1.0.0)
λ npm install wasm-pack

> wasm-pack@0.10.1 postinstall C:\Users\Jan\Documents\throwaway\node_modules\wasm-pack
> node ./install.js

Downloading release from https://github.com/rustwasm/wasm-pack/releases/download/v0.10.1/wasm-pack-v0.10.1-x86_64-pc-windows-msvc.tar.gz
wasm-pack.exe has been installed!
npm WARN throwaway@1.0.0 No description
npm WARN throwaway@1.0.0 No repository field.

+ wasm-pack@0.10.1
added 23 packages from 10 contributors and audited 25 packages in 4.895s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


C:\Users\Jan\Documents\throwaway  (throwaway@1.0.0)
λ npx wasm-pack build
Error: crate directory is missing a `Cargo.toml` file; is `.` the wrong directory?

@Pauan
Copy link
Contributor Author

Pauan commented Sep 5, 2021

@drager Works for me, thanks!

@Pauan Pauan closed this as completed Sep 5, 2021
@Tristyn
Copy link

Tristyn commented Sep 19, 2022

This problem has resurfaced in 0.10.3 but downgrading to 0.10.1 works. Windows 11 10.0.22000 Build 22000

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

6 participants