Upgrading from react-native 1.7 to 1.9 on MacOS 11.11.4 (Beta) fails when upgrading a project
$ react-native upgrade
/Users/adam/Documents/Versio4/XXXXXXX/node_modules/react-native/local-cli/setup_env.sh: line 8: ulimit: open files: cannot modify limit: Operation not permitted
child_process.js:464
throw err;
The reason it errors is that setup_env.sh tries to do:
ulimit -n 4096
On my MacOS I can't as a non-root user increase the ulimit above 2048
Adams-MacBook-Pro:tmp adam$ ulimit -n 2048
Adams-MacBook-Pro:tmp adam$ ulimit -n 4096
-bash: ulimit: open files: cannot modify limit: Operation not permitted
Adams-MacBook-Pro:tmp adam$ ulimit -n 2049
-bash: ulimit: open files: cannot modify limit: Operation not permitted
Editing the setup_env.sh to use 2048 fixes the issue.
Full platform:
Node v4.2.2
MacOS 10.11.4 Beta (15E27e)
Hey adamtwiss, thanks for reporting this issue!
React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
react-native or for more real time interactions, ask on Discord in the #react-native channel.@nicklockwood @vjeux do you think 2048 would be enough for RN to run by default?
Kind of reasonable not to require root permissions to run RN.
Yeah we don't want to require sudo to run react native. Can you send a diff to use 2048 and see if anyone complains about it? :p
Created diff D2905603
I just stumbled over the same problem. Do you know when this will be released? Thanks.
It should be in 0.21 already
On Tuesday, 8 March 2016, Donald Pipowitch [email protected] wrote:
I just stumbled over the same problem. Do you know when this will be
released? Thanks.—
Reply to this email directly or view it on GitHub
https://github.com/facebook/react-native/issues/5668#issuecomment-193956712
.
Strange. I'll check my version tomorrow, but I installed it just two hours ago. Thanks so far.
sure, this setting is definitely in 0.21: https://github.com/facebook/react-native/blob/0.21-stable/local-cli/setup_env.sh
I don't know why this happened. I use 0.21 and you're right, I have "ulimit -n 2048", too.
And what message do you get when you run it?
I had ulimit: open files: cannot modify limit: Operation not permitted yesterday, but switched to a root user since then. I can't reproduce it now easily, sorry.
No worries.
I'll close the task.
This question would be best asked on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there.
Hi!
I've faced with the same problem. For some reason, my machine allows me to call ulimit only for 1024 without root access, so this limitation does not work for me.
I found the fix which could be useful for others with the same problem. All you need is to all following lines into you ~/.profile file
function ulimit() { builtin ulimit -n 1024; }
export -f ulimit
This will redefine ulimit calls in order to call it with 1024 limit all the time.
Pls, note that this overwriting will ignore all arguments, so use builtin ulimit for real ulimit
I had previously defined a limit in bash_profile
ulimit -n 1024
when i removed it it fixed the error for me.
I guess its because im now non-root after updating to El Capitan.
macOS 10.12.1 doesn't let you ulimit -n 2048 without sudo. I've commented out the offending line to get by. My .profile already raises my ulimit -n 1024.
I believe the actual issue is that ulimit -n 2048 sets both the soft and the hard file limits, and OS X only lets you lower the hard limit once it's been set:
$ ulimit -Hn
unlimited
$ ulimit -n
256
$ ulimit -n 10000
$ ulimit -n
10000
$ ulimit -Hn
10000
$ ulimit -n 10001
-bash: ulimit: open files: cannot modify limit: Operation not permitted
$ ulimit -n 9999
$ ulimit -n 10000
-bash: ulimit: open files: cannot modify limit: Operation not permitted
On my system (OS X 10.11.6), ulimit -Hn is by default unlimited. A more elegant solution here might be to only set ulimit -Sn 2048 and only do so if the hard limit is high enough. If the hard limit is too low, I don't think a non-root shell will be able to change it regardless, so an error should be thrown.
ETA: I've put together the above proposal: https://github.com/facebook/react-native/compare/master...jacob-meacham:bugfix/ulimit?expand=1. I'll open a PR tomorrow, to discuss if the extra complexity is worthwhile.
@jacob-meacham just try my solution :)
Most helpful comment
I had previously defined a limit in bash_profile
ulimit -n 1024when i removed it it fixed the error for me.
I guess its because im now non-root after updating to El Capitan.