From 116fd5928c8285f90702728b1f39f5cbb725e04d Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Fri, 3 Mar 2023 18:27:00 -0800 Subject: [PATCH] lock_file: better message if too many open files Recommend using `ulimit -n` to increase maximum number of open files. --- Library/Homebrew/lock_file.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/lock_file.rb b/Library/Homebrew/lock_file.rb index 4ea97b04cd..ca17b61279 100644 --- a/Library/Homebrew/lock_file.rb +++ b/Library/Homebrew/lock_file.rb @@ -42,7 +42,11 @@ class LockFile def create_lockfile return if @lockfile.present? && !@lockfile.closed? - @lockfile = @path.open(File::RDWR | File::CREAT) + begin + @lockfile = @path.open(File::RDWR | File::CREAT) + rescue Errno::EMFILE + odie "The maximum number of open files on this system has been reached. Use `ulimit -n` to increase this limit." + end @lockfile.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) end end