How to fix GitKraken Inotify Limit Error - upgrading Ubuntu/Linux inotify limits

; Date: Wed Feb 07 2018

Tags: GitKraken

GitKraken is a totally excellent Git client. If you're a software developer you should absolutely give GitKraken a try. Today I went to do some commits in one of my repositories but GitKraken told me it had gotten an Inotify Limit Error, and that I needed to increase this limit. Turns out the issue has nothing to do with GitKraken, and is also fairly easy to fix.

Upon opening the repository in question, GitKraken showed a notification window with this message:

Inotify Limit Error File watching is disabled for this repository. Please increase your inotify limit and reopen this repository.

Previously in the day GitKraken gave a message while opening the same repository that it didn't find a "Compatible Repository" and it refused to even open the repository. Thing is, the repository is fine, and I used git to do my commits without problem. It's possible the Inotify Limit made some kind of impact on GitKraken causing GitKraken to say it could not find a compatible repository. I've sent the GitKraken team a query and haven't received a reply.

An important detail is that I'm on Ubuntu 17.10. I've been using Mac OS X for many years, and recently setup this Ubuntu machine to see how well any kind of Linux would work for me. For what it's worth GitKraken is working the same on both, thanks to the portability coming from it being an Electron-based application.

What is Inotify?

From Wikipedia:

Inotify (inode notify) is a Linux kernel subsystem that acts to extend filesystems to notice changes to the filesystem, and report those changes to applications.

One major use is in desktop search utilities like Beagle, where its functionality permits reindexing of changed files without scanning the filesystem for changes every few minutes, which would be very inefficient.

Since GitKraken automagically notices changes in files in a workspace, it obviously must be using this subsystem on Linux. Since I'm using Ubuntu, this applies to me.

Inotify limits

Type this command:

$ cat /proc/sys/fs/inotify/max_user_watches
8192

This is the limit on your computer.

Each inotify watch consumes a modest amount of memory. On a 64-bit computer like this one, each consumes 1 KB, so 8,192 watches consumes about 8 MB of memory. On a 16GB main memory computer that's a drop in the bucket.

Temporarily increasing the limit is this simple:

# echo 99999 > /proc/sys/fs/inotify/max_user_watches

After which you'll get this:

$ cat /proc/sys/fs/inotify/max_user_watches
99999

To make a permanent change, set fs.inotify.max_user_watches= in sysctl settings. On some systems (Debian/Ubuntu/etc) those settings are in /etc/sysctl.conf and on some others there will be a file in /etc/sysctl.d.

After editing the sysctl settings, run this:

# sysctl -p
fs.inotify.max_user_watches = 99999

Putting it on one line:

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

Or on certain other systems:

# echo fs.inotify.max_user_watches=99999 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system

References:

About the Author(s)

(davidherron.com) David Herron : David Herron is a writer and software engineer focusing on the wise use of technology. He is especially interested in clean energy technologies like solar power, wind power, and electric cars. David worked for nearly 30 years in Silicon Valley on software ranging from electronic mail systems, to video streaming, to the Java programming language, and has published several books on Node.js programming and electric vehicles.