Changing fs.inotify.max_user_watches

Hi there,

As part of the React Native packager facebook uses watchman which in turn uses inotify. The default limits specified by ubuntu are low

ubuntu@box324:~$ cat /proc/sys/fs/inotify/max_user_watches
8192

So they suggest running (from here: https://facebook.github.io/react-native/docs/troubleshooting.html#unable-to-start-react-native-package-manager-on-linux)

echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

The problem is I get

sysctl: permission denied on key ā€˜fs.inotify.max_user_watchesā€™

When running that command on CircleCI. How can I set that parameter so my React build could work?

Many thanks
Frankie

2 Likes

Iā€™m running into the same issue, did you solve it?

Iā€™ve had success using:

- sudo sysctl fs.inotify.max_user_watches=524288
- sudo sysctl -p

as part of the build setup to just set the limit temporarily. YMMVā€¦

How to do that if you use the docker executor?

Since sudo is not allowed thereā€¦

2 Likes

So, how do you set ā€œmax_user_watchesā€ on the host machine if you use the Docker executor?

1 Like

Since inotify limits cannot be raised in the Circle 2.0 docker, Iā€™ve gotten successful builds (and deploys with exp publish) by using a machine build (set machine: true) in config.ymlā€¦ and (for my project) installing yarn as part of the build. Iā€™ve left these changes only on the deploy branch.

version: 2
jobs:
  build:
    # Allow increase of inotify limit to support watchman for exp publish.
    # This should only be on the deploy branch.
    # See  https://circleci.com/docs/2.0/executor-types/
    machine: true
    steps:
      ...
      - run: |
          curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
          echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
          sudo apt-get update && sudo apt-get install yarn
      - run: yarn install

Good luck. Itā€™s an unfortunate limitation in the environment for docker in CircleCI 2.0. Hope they fix it soon.

Does it still work for you?

I get:

sudo sysctl fs.inotify.max_user_watches=524288

sysctl: permission denied on key 'fs.inotify.max_user_watches'