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

"Fatal error: EMFILE, open" when building osx distribution #103

Closed
kiyanwang opened this issue Aug 20, 2014 · 19 comments
Closed

"Fatal error: EMFILE, open" when building osx distribution #103

kiyanwang opened this issue Aug 20, 2014 · 19 comments

Comments

@kiyanwang
Copy link

I'm using grunt-node-webkit-builder my config looks like this :

nodewebkit: {
      options: {
        version: "0.10.0",
        buildDir: './dist',
        // specifiy what to build
        platforms:['osx','win','linux32','linux64'],
        macIcns: './nw.icns',
        macZip: false
        ,win_ico: './nw.ico'
      },
      src: './_public/**/*'
    },

This worked fine whilst my _public folder (the node-webkit app ive written) did not contain a node_modules folder. However as soon as I include a node_modules folder I get this error:

Fatal error: EMFILE, open '/Users/nadeemshabir/Development/projects/desktop_apps/talis-uploader-desktop-app/_public/node_modules/request/node_modules/hawk/node_modules/hoek/package.json'.

It only errors for the OSX distribution, the others work fine.
I'm on Mavericks, running grunt-node-webkit-builder 0.2.1 which is using node-webkit-builder 0.1.1.

Also If I dont include the node_modules folder in the _public directory, then use the the grunt task to build the distribution it works, if I then manually copy the node_modules folder into /Contents/Resources/app.nw/ in the dist folder, and run the app the app works perfectly. So I have a work around.

Any thoughts on how I can prevent that error?

@adam-lynch
Copy link
Contributor

You can try adding the following line to your ~/.bash_profile file:

ulimit -n 1024

@kiyanwang
Copy link
Author

@adam-lynch that appears to have fixed it, many thanks!

@adam-lynch
Copy link
Contributor

@kiyanwang no prob

@smiling-Jack
Copy link

I have the same problem if I build a osx app on Windows 7! what can I do ? ulimit under Windows ?

@adam-lynch
Copy link
Contributor

@smiling-Jack, sure it's the same problem? Maybe it's that you're ending up with paths which are too long for Windows?

@smiling-Jack
Copy link

Yes i think so.
If i build for windows i have no problems.
If i build for osx i have the "Fatal error: EMFILE, open" error. (not every time on the same file)

My project has ca. 1280 files than i have remove many readme, test and liecens files and now i have 1113 files and no problems. But that's not a solution for the future.

I now its strange !

@adam-lynch
Copy link
Contributor

Hmm @smiling-Jack, I've never heard of that before on Windows.

@smiling-Jack
Copy link

If I set the option:
macZip: true
I have no problems ?!?

@smiling-Jack
Copy link

I have found a solution ! :-)

I have change in the "NwBuilder.prototype.mergeAppFiles" the return to:

var x = Promise.all(copiedFiles)
setTimeout(function(){
return x;
},1000)

and it works for me.

@jimbuck
Copy link

jimbuck commented Oct 22, 2014

@smiling-Jack Have you made a pull request for this change? I am also having this issue on Windows 8.

@jamesmortensen
Copy link

Is it possible to add the ulimit as an option in the Gruntfile? Just a thought that might make it easier on folks. Hope this helps!

@adam-lynch
Copy link
Contributor

@jamesmortensen should that not be its own separate Grunt plugin? I'm more used to Gulp where making another simple plugin with a single purpose would be encouraged.

@jamesmortensen
Copy link

I guess it could be its own plugin, but it's so simple that if you know you need to type "ulimit" it's just easier to type it out by hand than to look for a plugin. The only problem my suggestion would solve is to help those who don't know what ulimit is, which -- as Node.js grows and hits its "eternal September" -- would be something that could matter in the future.

It's really not that big of a deal to type it at the terminal if it would go against the "keep it simple" and "single purpose" methodology to add it to grunt-node-webkit-builder. In other words, I think we all can live without it, at least those of us involved in the Node.js community today. Hope this helps clarify.

@jamesmortensen
Copy link

It might not be a bad idea to add that to the documentation; however... Hope this helps!

adam-lynch added a commit to nwutils/nw-builder that referenced this issue Oct 25, 2014
adam-lynch added a commit that referenced this issue Oct 25, 2014
@adam-lynch
Copy link
Contributor

Added to READMEs. FYI, it should be fixed in Node 0.12 nodejs/node-v0.x-archive@6820054

adam-lynch added a commit to nwutils/nw-builder that referenced this issue Oct 29, 2014
adam-lynch added a commit to nwutils/nw-builder that referenced this issue Oct 29, 2014
@NickStefan
Copy link

I'm getting this error on OSX, even after trying:

ulimit -n 1024

or even

ulimit -n 2048

What else can I try? @adam-lynch

@adam-lynch
Copy link
Contributor

I played around with a solution to problems like these... not sure if it solves it completely though. If you want to try, it's on the graceful-ncp branch of node-webkit-builder. So npm install mllrsohn/node-webkit-builder#graceful-ncp. But this is the source repo, not the grunt one so you could test it without grunt or maybe you could try going into your node_modules/grunt-node-webkit-builder and running that npm command, then use it with grunt as normal.

@mudcube
Copy link

mudcube commented Dec 23, 2014

For others on mac who are still hitting this error on the latest version 1.0.0; try setting "macZip: true". For me this seemed to solve the issue.

@flocca
Copy link

flocca commented Jan 22, 2015

Thanks @mudcube, setting macZip to true solves the issue.

So there are two different issue: one that can be solved using ulimit -n 1024 and this one @adam-lynch.

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

8 participants