moonglum / exogenesis

Build your dotfile installer, updater and teardown
MIT License
19 stars 8 forks source link

Homebrew update is stuck during upgrading brews state #11

Closed bitboxer closed 10 years ago

bitboxer commented 11 years ago

When I enter rake update and there are updates in homebrew, Homebrew is stuck in the upgrading brews state.

The stacktrace after I killed it:

code/exogenesis/lib/exogenesis/support/executor.rb:65:in `execute'
code/exogenesis/lib/exogenesis/homebrew.rb:36:in `update'
moonglum commented 11 years ago

Same here... :panda_face: I will look at it this evening :wink:

moonglum commented 11 years ago

I changed the homebrew update process. Can you try it again, @bitboxer?

bitboxer commented 11 years ago

Yes, it worked!

moonglum commented 11 years ago

Awesome :dancer:

bitboxer commented 10 years ago

Sorry, but I have to reopen this. My change to the homebrew recipie might have something to do with this, but I don't know how. If there is no update for homebrew, it works fine. But If there is an update, the executor is waiting forever for the process to return :sob:

moonglum commented 10 years ago

Damn you, homebrew! :fist:

moonglum commented 10 years ago

What about just calling brew upgrade without any arguments?

bitboxer commented 10 years ago

Nope, does not help. I reverted back to the version before my changes without any luck.

Something really strange is happening on my system when homebrew is stuck: I can't start a new terminal process and when I start a new command, it throws this error:

Could not create child process - exiting
fork: Resource temporarily unavailable

Don't understand what is going on here ?!

bitboxer commented 10 years ago

I also changed my shell to zsh without any configuration just to be sure it is not a) my fish config or b) fish itself that is causing this problems. And it is still happening?! Very :confused: right now.

bitboxer commented 10 years ago

Digging deeper. The config log stops at

configure:3932: checking whether make sets $(MAKE)

and I see tons and tons of process like this:

36579 s009  SN+    0:00.00 sh -c xcode-select --print-path >/dev/null 2>&1 && xcrun --sdk macosx --show-sdk-path 2>/dev/null
36581 s009  SN+    0:00.36 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/xcrun --sdk macosx --show-sdk-path
36582 s009  SN+    0:00.01 /usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/git ls-files

There are so many of those that the kernel stops forking new ones and everything is stuck until I kill the brew upgrade. That only happens when using exogenesis, not when I am doing it by hand. Something odd is going on on my system.

bitboxer commented 10 years ago

to be more precise it looks like this:

57973 s009  S+     0:00.45 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0 /usr/local/Library/brew.rb upgrade wget
57995 s009  SN+    0:00.44 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0 -I /usr/local/Library/Homebrew -rbuild -- /usr/local/Library/Formula/wget.rb --build-
58013 s009  SN+    0:00.06 /bin/sh ./configure --prefix=/usr/local/Cellar/wget/1.15 --sysconfdir=/usr/local/etc --with-ssl=openssl --with-libssl-prefix=/usr/local/opt/openssl --disable
58155 s009  SN+    0:00.00 /bin/sh ./configure --prefix=/usr/local/Cellar/wget/1.15 --sysconfdir=/usr/local/etc --with-ssl=openssl --with-libssl-prefix=/usr/local/opt/openssl --disable
58156 s009  SN+    0:00.34 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/xcrun make -f conftest.make
58163 s009  SN+    0:00.01 /usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/git ls-files
58164 s009  SN+    0:00.00 sh -c xcode-select --print-path >/dev/null 2>&1 && xcrun --sdk macosx --show-sdk-path 2>/dev/null
58166 s009  SN+    0:00.34 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/xcrun --sdk macosx --show-sdk-path
58167 s009  SN+    0:00.02 /usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/git ls-files
58169 s009  SN+    0:00.00 sh -c xcode-select --print-path >/dev/null 2>&1 && xcrun --sdk macosx --show-sdk-path 2>/dev/null
58171 s009  SN+    0:00.34 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/xcrun --sdk macosx --show-sdk-path
58177 s009  SN+    0:00.02 /usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/git ls-files
58178 s009  SN+    0:00.00 sh -c xcode-select --print-path >/dev/null 2>&1 && xcrun --sdk macosx --show-sdk-path 2>/dev/null
58180 s009  SN+    0:00.34 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/xcrun --sdk macosx --show-sdk-path
58187 s009  SN+    0:00.02 /usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/git ls-files
58188 s009  SN+    0:00.00 sh -c xcode-select --print-path >/dev/null 2>&1 && xcrun --sdk macosx --show-sdk-path 2>/dev/null
58190 s009  SN+    0:00.34 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/xcrun --sdk macosx --show-sdk-path
58195 s009  SN+    0:00.01 /usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/git ls-files
58197 s009  SN+    0:00.00 sh -c xcode-select --print-path >/dev/null 2>&1 && xcrun --sdk macosx --show-sdk-path 2>/dev/null
58200 s009  SN+    0:00.33 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/xcrun --sdk macosx --show-sdk-path
58201 s009  SN+    0:00.02 /usr/bin/ruby -W0 /usr/local/Library/ENV/4.3/git ls-files

and on and on till the fork limit of the kernel is reached

bitboxer commented 10 years ago

I now created a small test project to experiment with:

require 'open3'

output, error_output, exit_status = nil
Open3.popen3("brew upgrade") do |stdin, stdout, stderr, process|
  output = stdout.read
  error_output = stderr.read
  exit_status = process.value.exitstatus
end
p output

And I found out that starting this little fellow with ruby example.rb it works perfectly. But with bundle exec ruby example.rb it fails.

bitboxer commented 10 years ago

Okay, I have the fix now. Sending patch in a few minutes.

The solution was in "Shelling out" here: http://bundler.io/v1.5/man/bundle-exec.1.html

moonglum commented 10 years ago

Wow, that was an awesome bug hunt :smile_cat: Thank you so much!

bitboxer commented 10 years ago

I needed to sleep a few hours to find the solution. And I love the feeling when you finally nail it. The time till you find it...not so mich :wink:

moonglum commented 10 years ago

That explains why I didn't have the problem and you did by the way :wink: I don't execute exogenesis with bundle exec

moonglum commented 10 years ago

What you describe == Programming, right? :wink:

bitboxer commented 10 years ago

I automatically run bundle exec on a few commands, rake being one of them.

moonglum commented 10 years ago

Yep, I know :smile: