rust-webpack-template
rust-webpack-template copied to clipboard
cannot init template
I get a strange error trying to init the rust-webpack template:
C:\r>npm init rust-webpack rvr --verbose
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Users\\d\\nodejs\\node.exe',
npm verb cli 'C:\\Users\\d\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'init',
npm verb cli 'rust-webpack',
npm verb cli 'rvr',
npm verb cli '--verbose' ]
npm info using [email protected]
npm info using [email protected]
npm verb config Skipping project config: C:\Users\d/.npmrc. (matches userconfig)
npx: installed 1 in 1.329s
🦀 Rust + 🕸 WebAssembly + Webpack = ❤️ ping project config: C:\Users\d/.npmrc. (matches userconfig)
events.js:173
throw er; // Unhandled 'error' event
^
Error: spawn npm ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
at onErrorNT (internal/child_process.js:421:16)
at processTicksAndRejections (internal/process/next_tick.js:76:17)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:252:12)
at onErrorNT (internal/child_process.js:421:16)
at processTicksAndRejections (internal/process/next_tick.js:76:17)
npm verb exit [ 0, true ]
npm timing npm Completed in 4725ms
npm info ok
C:\r>
Any hints where to start looking? rust and wasm-pack are fresh installations.
That's strange, the only commands that we spawn during installation are git and npm, I assume you both have this commands.
@fitzgen I can't see the appveyor builds, are we passing the installation on windows?
c:\blank>where git && git --version
C:\Program Files\Git\cmd\git.exe
git version 2.19.1.windows.1
c:\blank>where npm && npm --version
C:\Users\d\nodejs\npm
C:\Users\d\nodejs\npm.cmd
6.5.0
looks like https://github.com/rustwasm/rust-webpack-template/issues/95 might be related...
it gets better: it seems to work when I bang in the create-rust-webpack.js into a node instance manually:
c:\blank>node
>
> const { spawnSync } = require("child_process");
undefined
> const fs = require("fs");
undefined
>
> function run(cmd, args, opts) {
... const output = spawnSync(cmd, args, opts);
...
... if (output.error != null) {
... throw output.error;
... }
...
... if (output.status !== 0) {
... throw new Error("Bad error code when running `" + cmd + " " + args.join(" ") + "`: " + output.status);
... }
... }
undefined
>
> let folderName = '.';
undefined
>
> if (process.argv.length >= 3) {
... folderName = process.argv[2];
... if (!fs.existsSync(folderName)) {
..... fs.mkdirSync(folderName);
..... }
... }
undefined
>
> folderName = 'rvr'
'rvr'
> run("git", ["clone", "https://github.com/rustwasm/rust-webpack-template.git", folderName]);
undefined
> run("npm", ["install"], { cwd: folderName, shell: true });
undefined
>
c:\blank>dir /w rvr\node_modules
Volume in drive C is OS
Volume Serial Number is 4321-1234
Directory of c:\blank\rvr\node_modules
[.] [..]
[acorn-dynamic-import] [ajv]
[anymatch] [aproba]
[array-unique] [asn1.js]
[base] [base64-js]
[bonjour] [boolbase]
[browserify-rsa] [browserify-sign]
[bytes] [cacache]
[...]
c:\blank>
i am still having this problem. Did anyone find a solution?
I upgraded my Git version from 2.7.4
to 2.22.0
, and it now works fine.
Reason being, create-rust-webpack
seems to use --no-tags
option
when git clone
, and older version of Git does not have such option.
I hit the same issue, here's an informative traceback that shows git failing:
npx: installed 18 in 3.828s
/home/blahblah/.npm/_npx/92/lib/node_modules/create-rust-webpack/.bin/create-rust-webpack.js:17
throw new Error("Bad error code when running `" + cmd + " " + args.join(" ") + "`: " + output.status);
^
Error: Bad error code when running `git clone --no-tags --depth 1 https://github.com/rustwasm/rust-webpack-template.git test_ninit_rustwebpack/git-clone`: 129
at run (/home/blahblah/.npm/_npx/92/lib/node_modules/create-rust-webpack/.bin/create-rust-webpack.js:17:11)
at Object.<anonymous> (/home/blahblah/.npm/_npx/92/lib/node_modules/create-rust-webpack/.bin/create-rust-webpack.js:33:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
I ran the git command in isolation and can confirm that git version 2.11.0
does not support --no-tags
.
Running Ubuntu 18.04, git version 2.25.1
, getting the same error.
not working on windows or WSL for me with git 2.25.1
17:43:20 ❯ npm init rust-webpack dip-app --verbose
npm info it worked if it ends with ok
npm verb cli [
npm verb cli 'C:\\Users\\Dhruv Dhamani\\scoop\\apps\\nodejs\\current\\node.exe',
npm verb cli 'C:\\Users\\Dhruv Dhamani\\scoop\\apps\\nodejs\\current\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'init',
npm verb cli 'rust-webpack',
npm verb cli 'dip-app',
npm verb cli '--verbose'
npm verb cli ]
npm info using [email protected]
npm info using [email protected]
npm ERR! code ENOLOCAL
npm ERR! Could not install from "Dhamani\scoop\persist\nodejs\cache\_npx\15180" as it does not contain a package.json fi
le.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Dhruv Dhamani\scoop\persist\nodejs\cache\_logs\2020-03-21T21_43_30_779Z-debug.log
Install for [ 'create-rust-webpack@latest' ] failed with code 1
npm verb exit [ 0, true ]
npm timing npm Completed in 1047ms
npm info ok
Running Ubuntu 16.04, had following error:
npm info it worked if it ends with ok
npm verb cli [
npm verb cli '/home/kayojobor/.nvm/versions/node/v14.4.0/bin/node',
npm verb cli '/home/kayojobor/.nvm/versions/node/v14.4.0/bin/npm',
npm verb cli 'init',
npm verb cli 'rust-webpack',
npm verb cli 'hello',
npm verb cli '--verbose'
npm verb cli ]
npm info using [email protected]
npm info using [email protected]
npx: installed 17 in 1.719s
/home/kayojobor/.npm/_npx/14557/lib/node_modules/create-rust-webpack/.bin/create-rust-webpack.js:17
throw new Error("Bad error code when running `" + cmd + " " + args.join(" ") + "`: " + output.status);
^
Error: Bad error code when running `git clone --no-tags --depth 1 https://github.com/rustwasm/rust-webpack-template.git hello/git-clone`: 129
at run (/home/kayojobor/.npm/_npx/14557/lib/node_modules/create-rust-webpack/.bin/create-rust-webpack.js:17:11)
at Object.<anonymous> (/home/kayojobor/.npm/_npx/14557/lib/node_modules/create-rust-webpack/.bin/create-rust-webpack.js:33:1)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
npm verb exit [ 0, true ]
npm timing npm Completed in 1950ms
npm info ok
upgrading git to 2.27.0 fixed issue.
On macOS Catalina, upgrading git also fixed it for me.
For help on upgrading on Mac see: https://apple.stackexchange.com/a/272220/253705