element-hq/element-web

Unable to yarn start without sudo because of Error: EMFILE: too many open files

SimonBrandner opened this issue · 2 comments

Description

I've been attempting to run yarn start, but most of the time it failed with errors. It works only some time after boot. Though I have been able to run sudo yarn start without a problem. The README.md mentions inotify limits and ulimits. I am not experienced with these things but I followed the instructions. But I wasn't able to fix this.

Steps to reproduce

I was not able to reproduce this on my laptop. But this is what I had done on my PC:

git clone https://github.com/matrix-org/matrix-js-sdk.git
pushd matrix-js-sdk
yarn link
yarn install
popd
git clone https://github.com/matrix-org/matrix-react-sdk.git
pushd matrix-react-sdk
yarn link
yarn link matrix-js-sdk
yarn install
popd
git clone https://github.com/vector-im/element-web.git
cd element-web
yarn link matrix-js-sdk
yarn link matrix-react-sdk
yarn install
yarn start

Info

I am on Debian 11 Bullseye. This is the output of a few commands that could be useful.

As a regular user:

> uname -a
Linux Simon-s-PC 5.8.0-3-amd64 #1 SMP Debian 5.8.14-1 (2020-10-10) x86_64 GNU/Linux
> sudo sysctl fs.inotify.max_user_watches
fs.inotify.max_user_watches = 524288
> ulimit -a
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8192
-c: core file size (blocks)         0
-m: resident set size (kbytes)      unlimited
-u: processes                       46482
-n: file descriptors                8192
-l: locked-in-memory size (kbytes)  unlimited
-v: address space (kbytes)          unlimited
-x: file locks                      unlimited
-i: pending signals                 63664
-q: bytes in POSIX msg queues       819200
-e: max nice                        0
-r: max rt priority                 95
-N 15:                              unlimited
> yarn --version
1.22.5

With sudo su:

> sysctl fs.inotify.max_user_watches
fs.inotify.max_user_watches = 524288
> ulimit -a
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8192
-c: core file size (blocks)         0
-m: resident set size (kbytes)      unlimited
-u: processes                       63664
-n: file descriptors                1024
-l: locked-in-memory size (kbytes)  2043392
-v: address space (kbytes)          unlimited
-x: file locks                      unlimited
-i: pending signals                 63664
-q: bytes in POSIX msg queues       819200
-e: max nice                        0
-r: max rt priority                 0
-N 15:                              unlimited

I am closing this as it doesn't seem to be an element-web problem. I have the same problem with bibviz.

I think I've solved the problem. Here's the answer.