Skip to content

Error: spawn E2BIG #2561

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

Closed
rLoka opened this issue Feb 22, 2017 · 10 comments
Closed

Error: spawn E2BIG #2561

rLoka opened this issue Feb 22, 2017 · 10 comments
Assignees
Labels
Milestone

Comments

@rLoka
Copy link

rLoka commented Feb 22, 2017

Preparing project...
[31;1mProcessing node_modules failed. Error: spawn E2BIG
[NSDebugAdapter] The tns command finished its execution with code 127.
getconf ARG_MAX
2097152
All NativeScript components versions information
┌──────────────────┬─────────────────┬────────────────┬──────────────────┐
│ Component        │ Current version │ Latest version │ Information      │
│ nativescript     │ 2.5.0           │ 2.5.1          │ Update available │
│ tns-core-modules │ 2.5.1           │ 2.5.1          │ Up to date       │
│ tns-android      │ 2.5.0           │ 2.5.0          │ Up to date       │
│ tns-ios          │ 2.3.0           │ 2.5.0          │ Update available │
└──────────────────┴─────────────────┴────────────────┴──────────────────┘

Running on Ubuntu 16.10, while I did not have such problems with NS 2.0.0

@pkoleva pkoleva added the bug label Feb 27, 2017
@silveirado
Copy link

I experienced the same issue. The result of tns prepare android --log trace > build.log can be seen at the attachment.
I tried to identify the bug.
It may be at traverseDependency (source nativescript-cli/lib/tools/node-modules/node-modules-dependencies-builder.ts), because {"name":"d","directory":"/home/myproject/node_modules/d","depth":0} shows up many times in the log.

prepare.log.txt

@silveirado
Copy link

I solved my issue by removing the number-generator package, because it has an incorrect dependency environment for eslint causing a cyclic import for es6-iterator. To permit use this package I changed it's eslint to devDependencies of package.
Also i believe this routine should be fixed to prevent similar issues. tx.

@Plamen5kov
Copy link
Contributor

@rLoka, @silveirado can you provide steps to reproduce and the version of cli you're using?

@rLoka
Copy link
Author

rLoka commented Mar 9, 2017

@Plamen5kov I updated from 2.0.0 to 2.5.0 and that is what happened. I am on Ubuntu 16.10.
Here is the project source https://github.com/Non-BinaryT/OfficeEquipmentTracker .. you can try building it yourself.

@Plamen5kov
Copy link
Contributor

Thank you @rLoka, I managed to reproduce the problem and will investigate.

@Plamen5kov
Copy link
Contributor

You can't have nativescript as a dependency, if you're going to install it locally, install it as a devDependency or even better use it globally.

to fix your issue:

  • npm uninstall nativescript --save
  • npm install -g nativescript
  • tns build android

@silveirado
Copy link

Steps to reproduce this issue:

$ tns create issue-2561 --ng
$ cd issue-2561
$ npm i -S lodash
$ npm i -S moment
$ npm i -S nativescript-cardview
$ npm i -S nativescript-sqlite
$ npm i -S nativescript-statusbar
$ npm i -S nativescript-websockets
$ npm i -S number-generator
$ tns platform add android
$ tns prepare android
$ echo "Everything ok"
$ npm i -S eslint eslint-plugin-compat
$ tns update
$ tns prepare android

Result:

Executing before-prepare hook from /home/derotino/desenvolvimento/issue-2561/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /home/derotino/desenvolvimento/issue-2561/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.1.6
Preparing project...
Processing node_modules failed. Error: spawn E2BIG

I know that the eslint eslint-plugin-compat packages must be in devDependecies, it has been fixed at PR [#3] (MartinHelmut/number-generator#3) from 'number generator' package. But indeed miss happens may occur.

@Plamen5kov
Copy link
Contributor

@silveirado thank you, for the detailed steps to reproduce. It's a node restriction on the size of arguments you can call it with, we'll fix it as soon as possible.
Until we do, all we can provide as a workaround is to install any non-production dependencies as devDependencies.

@Plamen5kov Plamen5kov reopened this Mar 9, 2017
@Plamen5kov Plamen5kov assigned Plamen5kov and petekanev and unassigned Plamen5kov Mar 9, 2017
@petekanev
Copy link
Contributor

petekanev commented Mar 13, 2017

As mentioned above - the problem arises from passing arguments of length greater, than that allowed by the OS, when spawning a new process. This is, as seen from the provided logs, a result of traversing cyclic production dependencies. The prepare step during build also slows up dramatically.

The script that is ran in node is responsible for checking whether any of the installed application plugins has declared dependency on the public v8 API, so that we may determine whether to distribute optimized (lower package size), or the regular runtime package.

We can currently address the E2BIG/ENAMETOOLONG (Win) problem by defaulting to using the optimized version of the runtime if an error is thrown while spawning the child process. This will allow the CLI process to continue, and the application will likely start up. What concerns me most is that these cyclic dependencies may be used in release builds, and may cause problems runtime/increase app size. So the responsibility for clean and neat dependencies should still fall in the developer's hands.

If and when the changes

this.$fs.writeJson(prodDependenciesFilePath, prodDependenciesArr);
in #2532 make it in master, the node script can instead read the production dependencies from a file, which should eliminate this problem entirely.

@petekanev
Copy link
Contributor

Merged PR #2604 so that the prepare process no longer terminates if passing too many arguments (a result of bad dependency tree) to a new node process. If the above error is caught then the runtime will fallback to the default optimized (stripped v8 symbols table) android runtime without checking whether any of the nativescript plugins depend on v8.

@pkoleva pkoleva added this to the 3.0.0-RC milestone Mar 27, 2017
dtopuzov added a commit to NativeScript/nativescript-cli-tests that referenced this issue Apr 21, 2017
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

6 participants