brew update and retried your prior step?brew doctor, fixed as many issues as possible and retried your prior step?sudo chown -R $(whoami) $(brew --prefix)?brew update fails.
steps taken
[1] ls -la $(brew --prefix)
drwxrwxr-x 19 ram admin 646 May 16 00:12 .
drwxr-xr-x@ 13 root wheel 442 May 15 17:17 ..
drwxr-xr-x 14 ram admin 476 May 18 22:57 .git
drwxr-xr-x 5 ram admin 170 May 15 17:18 .github
-rw-r--r-- 1 ram admin 1016 May 15 17:18 .gitignore
-rw-r--r-- 1 ram admin 861 May 15 17:18 .travis.yml
-rw-r--r-- 1 ram admin 291 May 15 17:18 .yardopts
-rw-r--r-- 1 ram admin 3161 May 15 17:18 CODEOFCONDUCT.md
drwxr-xr-x 11 ram admin 374 May 16 00:39 Cellar
-rw-r--r-- 1 ram admin 1241 May 15 17:18 LICENSE.txt
drwxr-xr-x 11 ram admin 374 May 15 17:32 Library
-rw-r--r-- 1 ram admin 3918 May 15 17:18 README.md
drwxr-xr-x 94 ram admin 3196 May 18 22:50 bin
drwxr-xr-x 5 ram admin 170 May 16 00:36 etc
drwxr-xr-x 4 ram admin 136 May 16 00:31 include
drwxr-xr-x 12 ram admin 408 May 16 00:31 lib
drwxr-xr-x 11 ram admin 374 May 16 00:39 opt
drwxr-xr-x 16 ram admin 544 May 17 20:27 share
drwxr-xr-x 5 ram admin 170 May 16 00:36 var
[2] brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.
[3] brew update
-e:1:in `initialize': Bad file descriptor (Errno::EBADF)
from -e:1:in `new'
from -e:1:in `<main>'
Error: Another active Homebrew process is already in progress.
Please wait for it to finish or terminate it to continue.
Try to cd /usr/local; git reset --hard origin/master; brew update.
CC @xu-cheng for what looks like a locking bug.
Can you show the output of ls -al /tmp/
output is (relevant pasted here only)
drwxrwxrwt 12 root wheel 408 May 18 23:12 .
drwxr-xr-x@ 6 root wheel 204 May 15 14:58 ..
-rw-r--r-- 1 ram wheel 0 May 18 23:08 homebrew-usr-local-update.lock
FIX: I just restarted the terminal. brew updated correctly. You may close this
please. I do understand that I have to remove this lock file too, just in case. Thank you.
@ramonrails Were you using tmux or screen or anything? The output of ls -al /tmp/ would still be useful if you can provide it so we can avoid others hitting this issue. Thanks!
@mikemcquaid I just did. the relevant part only, though. thank you.
@ramonrails Thanks!
This came again Today. Here are the complete output and steps.
brew doctor is clean
ruby-2.3.1 ~/work/projects/code/sso (develop)*$ brew doctor
Your system is ready to brew.
brew update complained about another process (I only had single terminal console open.
ruby-2.3.1 ~/work/projects/code/sso (develop)*$ brew update
-e:1:in `initialize': Bad file descriptor (Errno::EBADF)
from -e:1:in `new'
from -e:1:in `<main>'
Error: Another active Homebrew process is already in progress.
Please wait for it to finish or terminate it to continue.
I looked at the /tmp folder as suggested above
ruby-2.3.1 ~/work/projects/code/sso (develop)*$ ll /tmp/
total 8
drwxrwxrwt 12 root wheel 408B May 19 13:03 ./
drwxr-xr-x@ 6 root wheel 204B May 15 14:58 ../
-rw-rw-rw- 1 ram wheel 0B May 19 12:53 .keystone_install_lock
drwx------ 3 ram wheel 102B May 19 12:53 KSOutOfProcessFetcher.501.ppfIhqX0vjaTSb8AJYobDV7Cu68=/
drwx------ 3 ram wheel 102B May 19 12:53 com.apple.launchd.LVqVic1quK/
drwx------ 3 ram wheel 102B May 19 12:53 com.apple.launchd.UhC06p2CBa/
-rw-r--r--@ 1 ram wheel 0B May 19 12:53 ct.shutdown
-rw-r--r-- 1 ram wheel 0B May 19 13:03 homebrew-usr-local-update.lock
srwx------ 1 ram wheel 0B May 19 12:53 mongodb-27017.sock
srwxrwxrwx 1 ram wheel 0B May 19 12:53 mysql.sock
-rw------- 1 ram wheel 4B May 19 12:53 mysql.sock.lock
srwxr-xr-x 1 ram wheel 0B May 19 12:57 textmate-501.sock
found home-brew-.... lock file, removed it.
ruby-2.3.1 ~/work/projects/code/sso (develop)*$ rm /tmp/homebrew-usr-local-update.lock
ruby-2.3.1 ~/work/projects/code/sso (develop)*$ ll /tmp/
total 8
drwxrwxrwt 11 root wheel 374B May 19 13:04 ./
drwxr-xr-x@ 6 root wheel 204B May 15 14:58 ../
-rw-rw-rw- 1 ram wheel 0B May 19 12:53 .keystone_install_lock
drwx------ 3 ram wheel 102B May 19 12:53 KSOutOfProcessFetcher.501.ppfIhqX0vjaTSb8AJYobDV7Cu68=/
drwx------ 3 ram wheel 102B May 19 12:53 com.apple.launchd.LVqVic1quK/
drwx------ 3 ram wheel 102B May 19 12:53 com.apple.launchd.UhC06p2CBa/
-rw-r--r--@ 1 ram wheel 0B May 19 12:53 ct.shutdown
srwx------ 1 ram wheel 0B May 19 12:53 mongodb-27017.sock
srwxrwxrwx 1 ram wheel 0B May 19 12:53 mysql.sock
-rw------- 1 ram wheel 4B May 19 12:53 mysql.sock.lock
srwxr-xr-x 1 ram wheel 0B May 19 12:57 textmate-501.sock
brew update failed anyways. the lock file was also re-created somehow during the brew update command
ruby-2.3.1 ~/work/projects/code/sso (develop)*$ brew update
-e:1:in `initialize': Bad file descriptor (Errno::EBADF)
from -e:1:in `new'
from -e:1:in `<main>'
Error: Another active Homebrew process is already in progress.
Please wait for it to finish or terminate it to continue.
ruby-2.3.1 ~/work/projects/code/sso (develop)*$ ll /tmp/
total 8
drwxrwxrwt 11 root wheel 374B May 19 13:05 ./
drwxr-xr-x@ 6 root wheel 204B May 15 14:58 ../
-rw-rw-rw- 1 ram wheel 0B May 19 12:53 .keystone_install_lock
drwx------ 3 ram wheel 102B May 19 12:53 KSOutOfProcessFetcher.501.ppfIhqX0vjaTSb8AJYobDV7Cu68=/
drwx------ 3 ram wheel 102B May 19 12:53 com.apple.launchd.LVqVic1quK/
drwx------ 3 ram wheel 102B May 19 12:53 com.apple.launchd.UhC06p2CBa/
-rw-r--r--@ 1 ram wheel 0B May 19 12:53 ct.shutdown
-rw-r--r-- 1 ram wheel 0B May 19 13:04 homebrew-usr-local-update.lock
srwx------ 1 ram wheel 0B May 19 12:53 mongodb-27017.sock
srwxrwxrwx 1 ram wheel 0B May 19 12:53 mysql.sock
-rw------- 1 ram wheel 4B May 19 12:53 mysql.sock.lock
_PS: I was not sure whether to create a new issue or re-open this one. So, I just posted here on the closed issue @mikemcquaid @xu-cheng thank you for looking into this. Meanwhile, I will just reinstall home-brew fresh again to see if this goes away._
May I ask the output of which ruby? Are you using rbenv or RVM?
rbenv 1.0.0
/Users/ram/.rbenv/shims/ruby
What's the output of rbenv which ruby and rbenv version?
ruby-2.3.1 ~ $ rbenv which ruby
/Users/ram/.rbenv/versions/2.3.1/bin/ruby
ruby-2.3.1 ~ $ rbenv version
2.3.1 (set by /Users/ram/.rbenv/version)
I have the exact same problem, running brew update gives
Errno::EBADF: Bad file descriptor - Bad file descriptor
initialize at org/jruby/RubyIO.java:923
initialize at org/jruby/RubyFile.java:362
new at org/jruby/RubyIO.java:853
(root) at -e:1
Error: Another active Homebrew process is already in progress.
I'm using rvm, outputs of aforeasked
which ruby
/Users/ahtikatiska/.rvm/rubies/jruby-1.7.23/bin/ruby
rvm which ruby
/Users/ahtikatiska/.rvm/rubies/jruby-1.7.23/bin/ruby
rvm version
rvm 1.27.0 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
Also tried removing the .lock file that the brew update creates, no change. Closed all terminals, no change. Rebooted system, no change.
@ramonrails @KatsCyl
In order to help me debug this, could you show the output for following commands run in Bash?
brew config
brew doctor
ls -al /dev/fd/
exec 200>/tmp/test.lock
ls -al /dev/fd/
ruby -e 'File.new(200)'
Also have you set Bash in restricted mode or other non-standard mode?
brew config
HOMEBREW_VERSION: 0.9.9
ORIGIN: https://github.com/Homebrew/brew
HEAD: 2f20a42292e7d8d8f9ae9286632155a46e599700
Last commit: 8 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 0a6ddaa2dce2a03675f9296d7fafc98278a73cbc
Core tap last commit: 7 days ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: 8-core 64-bit haswell
Clang: 7.3 build 703
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /Users/ahtikatiska/.rvm/rubies/jruby-1.7.23/bin/ruby => /Users/ahtikatiska/.rvm/rubies/jruby-1.7.23/bin/jruby
Java: 1.8.0_92, 1.8.0_91
System Ruby: 2.0.0-p648
OS X: 10.11.5-x86_64
Xcode: N/A
CLT: 7.3.1.0.1.1461711523
X11: N/A
brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.
ls -al /dev/fd/
total 0
crw--w---- 1 ahtikatiska tty 16, 0 May 23 15:31 0
crw--w---- 1 ahtikatiska tty 16, 0 May 23 15:31 1
crw--w---- 1 ahtikatiska tty 16, 0 May 23 15:31 2
drw-r--r-- 36 ahtikatiska staff 1224 May 23 13:48 3
dr--r--r-- 1 root wheel 0 May 23 14:39 4
exec 200>/tmp/test.lock
ls -al /dev/fd/
total 0
crw--w---- 1 ahtikatiska tty 16, 0 May 23 15:32 0
crw--w---- 1 ahtikatiska tty 16, 0 May 23 15:32 1
crw--w---- 1 ahtikatiska tty 16, 0 May 23 15:32 2
-rw-r--r-- 1 ahtikatiska wheel 0 May 23 15:32 200
drw-r--r-- 36 ahtikatiska staff 1224 May 23 13:48 3
dr--r--r-- 1 root wheel 0 May 23 14:39 4
ruby -e 'File.new(200)'
Errno::EBADF: Bad file descriptor - Bad file descriptor
initialize at org/jruby/RubyIO.java:923
initialize at org/jruby/RubyFile.java:362
new at org/jruby/RubyIO.java:853
(root) at -e:1
And I don't believe that my bash is in any non-standard mode.
ruby-2.3.1 ~/tmp $ brew config
HOMEBREW_VERSION: 0.9.9
ORIGIN: https://github.com/Homebrew/brew
HEAD: d345483de164e062727f95d3fbd575433d735548
Last commit: 16 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 6442c12aea41de740333aff8249cc3c09fb1dd9e
Core tap last commit: 10 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: 8-core 64-bit ivybridge
Clang: 7.3 build 703
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /Users/ram/.rbenv/shims/ruby => /Users/ram/.rbenv/versions/2.3.1/bin/ruby
Java: N/A
System Ruby: 2.0.0-p648
OS X: 10.11.4-x86_64
Xcode: 7.3.1
CLT: 7.3.1.0.1.1461711523
X11: N/A
ruby-2.3.1 ~/tmp $ brew doctor
Your system is ready to brew.
ruby-2.3.1 ~/tmp $ ls -al /dev/fd/
total 0
crw--w---- 1 ram tty 16, 2 May 23 18:17 0
crw--w---- 1 ram tty 16, 2 May 23 18:17 1
crw--w---- 1 ram tty 16, 2 May 23 18:17 2
drw-r--r-- 5 ram staff 170 May 22 23:41 3
dr--r--r-- 1 root wheel 0 May 23 11:52 4
ruby-2.3.1 ~/tmp $ exec 200>/tmp/test.lock
ruby-2.3.1 ~/tmp $ ls -al /dev/fd/
total 0
crw--w---- 1 ram tty 16, 2 May 23 18:18 0
crw--w---- 1 ram tty 16, 2 May 23 18:18 1
crw--w---- 1 ram tty 16, 2 May 23 18:18 2
-rw-r--r-- 1 ram wheel 0 May 23 18:18 200
drw-r--r-- 5 ram staff 170 May 22 23:41 3
dr--r--r-- 1 root wheel 0 May 23 11:52 4
ruby-2.3.1 ~/tmp $ ruby -e 'File.new(200)'
ruby-2.3.1 ~/tmp $
FYI, I had the privilege and therefore did a complete uninstall and reinstall of homebrew, rbenv, ruby. After that, this error came once only.
@ramonrails It seems that error has been gone for you.
@KatsCyl Can you try:
exec 200>/tmp/test.lock
/usr/bin/ruby -e 'File.new(200)'
That completed without errors
As I explained above, I just needed to move on with my work, so reinstalled everything. Thank you for your time & attention to this issue @xu-cheng .
@MikeMcQuaid It seems that this bug comes from third party ruby interpreter. Shall we hardcore the path to /usr/bin/ruby, i.e. system ruby?
@xu-cheng Seems like a good idea for now on OS X and then it can use the vendored Ruby when that exists.
@MikeMcQuaid Since I have no Mac access in this week, would you mind to open the PR?
As for vendor Ruby, I think we can keep to use system Ruby because this one line command is Ruby 1.x compatible. And we will use this lock when installing vendor Ruby.
@xu-cheng done in https://github.com/Homebrew/brew/pull/271
I had the same issue, my problem was that I run a sudo command that probably affected some permissions, so to fix Homebrew I first run the following command to fix the permissions:
sudo chown -R "$USER":admin /usr/local
After that I did a cleanup:
brew cleanup
And I was successfully able to update Homebrew and install packages.
Hope this helps!
@rochastuff helped me!
Thanks rochastuff: that worked for me too.
I hit this issue as well, thanks @rochastuff your workaround fixed this.
Most helpful comment
I had the same issue, my problem was that I run a sudo command that probably affected some permissions, so to fix Homebrew I first run the following command to fix the permissions:
sudo chown -R "$USER":admin /usr/localAfter that I did a cleanup:
brew cleanupAnd I was successfully able to update Homebrew and install packages.
Hope this helps!