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

pack error on Windows 10 17746 #277

Closed
wangzishi opened this issue Aug 31, 2018 · 15 comments
Closed

pack error on Windows 10 17746 #277

wangzishi opened this issue Aug 31, 2018 · 15 comments
Assignees
Labels
Milestone

Comments

@wangzishi
Copy link

wangzishi commented Aug 31, 2018

🐛 Bug description

I just try the hello world on my computer.
Project structure is

default

wasm-pack init is success
default

but wasm-pack pack . is faild
default

wasm-pack.log

Aug 31 10:21:31.981 INFO Running pack command...
Aug 31 10:21:31.982 INFO Path: Some(".")
Aug 31 10:21:31.982 INFO Packing up the npm package...
Aug 31 10:21:31.982 ERRO 系统找不到指定的文件。 (os error 2)

🤔 Expected Behavior

No error occurred

👟 Steps to reproduce

  1. create new hello world project
  2. wasm-pack init
  3. wasm-pack pack .

🌍 Your environment

os: windows 10 x64 17746.1000
wasm-pack version: 0.4.2
rustc version: 1.30.0-nightly (02cb8f2a4 2018-08-29)

@fitzgen fitzgen added the bug Something isn't working label Aug 31, 2018
@fitzgen
Copy link
Member

fitzgen commented Aug 31, 2018

Thanks for the bug report!

@csmoe
Copy link
Member

csmoe commented Sep 6, 2018

@wangzishi I suspect that npm wasn't installed on your machine, could you paste the npm meta info here?


@fitzgen
anyway, pack cmd invokes npm directly

wasm-pack/src/npm.rs

Lines 10 to 18 in 89be40d

pub fn npm_pack(path: &str) -> Result<(), Error> {
let output = Command::new("npm").current_dir(path).arg("pack").output()?;
if !output.status.success() {
let s = String::from_utf8_lossy(&output.stderr);
Error::cli("Packaging up your code failed", s)
} else {
Ok(())
}
}

maybe better to add a binary exsit_or_not checking as you did in test PR here?

@fitzgen
Copy link
Member

fitzgen commented Sep 6, 2018

That sounds good to me! We should probably always do that, just to get good error messages to users

@wangzishi
Copy link
Author

wangzishi commented Sep 7, 2018

@csmoe I do have npm and node installed on my machine.
default

@ashleygwilliams
Copy link
Member

ah @wangzishi what happens when you run wasm-pack pack (without the dot?). the dot shouldn't cause an issue but it may be...

@wangzishi
Copy link
Author

@ashleygwilliams
and it has the same output.
default

what else can I help?

@ashleygwilliams
Copy link
Member

hrm. thanks so much for the response and sorry this is taking so long to figure out. @steveklabnik do you think you could try this locally?

@ashleygwilliams ashleygwilliams self-assigned this Sep 21, 2018
@steveklabnik
Copy link
Contributor

steveklabnik commented Sep 21, 2018

I get

C:\Users\steve> wasm-pack pack

| 🎒  packed up your package!

@csmoe
Copy link
Member

csmoe commented Oct 8, 2018

this bug can be reproduced with Chinese-ver Windows7 in my virtualbox, comparing to stevelabnik's comment, I suspect that system locale is the one to be blamed.

@luotaoyeah
Copy link

this might help: rust-lang/rust#42791

@danwilhelm
Copy link
Member

Unfortunately, this issue affects login, pack, and publish on Windows!

I verified that the cause suggested by @luotaoyeah is indeed occurring. Command places "npm" in quotes when calling it, which causes it to fail in Windows only.

The recommended solution is to call npm using cmd /c. I am working on a PR for this and have verified the cmd /c solution works. Unfortunately, it requires some OS-specific code -- but it seems unavoidable.

@danwilhelm danwilhelm mentioned this issue Jan 11, 2019
@ashleygwilliams ashleygwilliams added this to the 0.6.0 milestone Jan 11, 2019
@ashleygwilliams
Copy link
Member

@danwilhelm are you on discord or IRC? feel free to reach out to me on either platfrom (i'm ag_dubs)

danwilhelm added a commit to danwilhelm/wasm-pack that referenced this issue Jan 12, 2019
Issue rustwasm#277 - Affects running login, pack, and publish on Windows.

`Command::new("npm")` launched `npm` with quotes, `"npm"`, causing a
run-time error on Windows. Now, `Command::new` is wrapped by
`child::new_command(program: &str)`. This prepends `cmd /c` to the
program name if `cfg!(windows)`.

See rustc: #42436, #42791, #44542
@ashleygwilliams
Copy link
Member

closed by #489! about to go out!

ashleygwilliams pushed a commit that referenced this issue Jan 15, 2019
Issue #277 - Affects running login, pack, and publish on Windows.

`Command::new("npm")` launched `npm` with quotes, `"npm"`, causing a
run-time error on Windows. Now, `Command::new` is wrapped by
`child::new_command(program: &str)`. This prepends `cmd /c` to the
program name if `cfg!(windows)`.

See rustc: #42436, #42791, #44542
@danwilhelm
Copy link
Member

danwilhelm commented Jan 16, 2019

@wangzishi @csmoe I was not able to test my commit on Chinese-ver Windows! Could you possibly verify whether it is fixed in wasm-pack 0.6.0?

@csmoe
Copy link
Member

csmoe commented Jan 16, 2019

@danwilhelm thanks for the fix. I'll test then(my locale gussing maybe almost not the cause).

ashleygwilliams pushed a commit that referenced this issue Feb 27, 2019
Issue #277 - Affects running login, pack, and publish on Windows.

`Command::new("npm")` launched `npm` with quotes, `"npm"`, causing a
run-time error on Windows. Now, `Command::new` is wrapped by
`child::new_command(program: &str)`. This prepends `cmd /c` to the
program name if `cfg!(windows)`.

See rustc: #42436, #42791, #44542
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants