react-native: Error running react-native upgrade on MacOS [1.9]

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)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (11 by maintainers)

Most upvoted comments

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.

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