Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

ruby: postinstall fail #29982

Closed
robsonpeixoto opened this issue Jun 8, 2014 · 24 comments
Closed

ruby: postinstall fail #29982

robsonpeixoto opened this issue Jun 8, 2014 · 24 comments

Comments

@robsonpeixoto
Copy link
Contributor

$ brew update
Already up-to-date.

$ brew doctor
Your system is ready to brew.

$ brew install ruby
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/ruby-2.1.2_1.mavericks.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/ruby-2.1.2_1.mavericks.bottle.tar.gz
==> Pouring ruby-2.1.2_1.mavericks.bottle.tar.gz
==> Caveats
By default, gem installed executables will be placed into:
  /usr/local/opt/ruby/bin

You may want to add this to your PATH. After upgrades, you can run
  gem pristine --all --only-executables

to restore binstubs for installed gems.
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall ruby`
==> Summary
🍺  /usr/local/Cellar/ruby/2.1.2_1: 941 files, 20M

$ brew postinstall ruby
Error: Directory not empty - /usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems

$ rm -rf /usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/*

$ brew postinstall ruby
Error: undefined method `symlink' for #<Pathname:/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems>
Please report this bug:
    https://github.com/Homebrew/homebrew/wiki/troubleshooting
/usr/local/Library/Formula/ruby.rb:79:in `block in post_install'
/usr/local/Library/Formula/ruby.rb:70:in `each'
/usr/local/Library/Formula/ruby.rb:70:in `post_install'
/usr/local/Library/Homebrew/cmd/postinstall.rb:5:in `block in postinstall'
/usr/local/Library/Homebrew/cmd/postinstall.rb:5:in `each'
/usr/local/Library/Homebrew/cmd/postinstall.rb:5:in `postinstall'
/usr/local/Library/brew.rb:106:in `<main>'
@jacknagel
Copy link
Contributor

@Homebrew/owners I've run out of patience for working on this particular problem, so if someone would look at this and try to fix it I would really appreciate it.

Previously: #28343, #28466, #28467, #28759, #29600

/cc @anemator, who worked on the most recent iteration.

@lgw4
Copy link

lgw4 commented Jun 9, 2014

I hate do do this, but "me, too."

$ brew install ruby
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/ruby-2.1.2_1.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ruby-2.1.2_1.mavericks.bottle.tar.gz
==> Caveats
By default, gem installed executables will be placed into:
  /usr/local/opt/ruby/bin

You may want to add this to your PATH. After upgrades, you can run
  gem pristine --all --only-executables

to restore binstubs for installed gems.
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall ruby`
==> Summary
🍺  /usr/local/Cellar/ruby/2.1.2_1: 941 files, 20M

@anemator
Copy link
Contributor

anemator commented Jun 9, 2014

I'm not sure what's causing that undefined method error, I wasn't getting it a few days ago (installed from bottle and source). However as of 2.1.2_1, the newly installed gems directory is non-empty, so I guess we can just wipe it for now.

@DomT4
Copy link
Member

DomT4 commented Jun 9, 2014

Same issue on OS X 10.10 FWIW. I just ended up removing the Homebrew ruby and going back to Yosemite's system version. For some reason the Homebrew formula for Ruby has always given me issues on both 10.9-10.9.3 and now 10.10.

@mistydemeo
Copy link
Member

Is it really safe to delete the gems that come bundled with Ruby?

@DomT4
Copy link
Member

DomT4 commented Jun 9, 2014

Doing so has never caused me any issues. For some reason Ruby seems to habitually get bunged up and struggles to update gems, so I occasionally end up wandering into the folder and blitzing everything in sight and then going back to the terminal and doing 'gem install xxxxx' and updating that way, which works flawlessly from then for a pretty decent amount of time.

@evanmeng
Copy link

evanmeng commented Jun 9, 2014

Got the same problem...

@RSully
Copy link

RSully commented Jun 9, 2014

Same issue this morning while doing an upgrade (10.9.3):

rsully@macbookpro ~> brew update
Updated Homebrew from aa6ebf58 to dc2c54a8.
==> Updated Formulae
mercurial   ruby [...]

rsully@macbookpro ~> brew outdated
mercurial (3.0 < 3.0.1)
ruby (2.1.1_1, 2.1.2 < 2.1.2_1)

rsully@macbookpro ~> brew upgrade
==> Upgrading 2 outdated packages, with result:
mercurial 3.0.1, ruby 2.1.2_1
==> Upgrading mercurial
[... snip]
==> Summary
  /usr/local/Cellar/mercurial/3.0.1: 363 files, 4.6M
==> Upgrading ruby
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/ruby-2.1.2_
######################################################################## 100.0%
==> Pouring ruby-2.1.2_1.mavericks.bottle.tar.gz
==> Caveats
By default, gem installed executables will be placed into:
  /usr/local/opt/ruby/bin

You may want to add this to your PATH. After upgrades, you can run
  gem pristine --all --only-executables

to restore binstubs for installed gems.
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall ruby`
==> Summary
  /usr/local/Cellar/ruby/2.1.2_1: 941 files, 20M

rsully@macbookpro ~> brew postinstall ruby
Error: Directory not empty - /usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems

@xvoland
Copy link

xvoland commented Jun 9, 2014

Same issue OSX 10.9.3
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

$ ls /usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems
2.1.0

@adamv
Copy link
Contributor

adamv commented Jun 9, 2014

We don't need any more "I also have this issue" reports at this time, thanks.

@MikeMcQuaid
Copy link
Member

Yup. Please run brew postinstall -v ruby if you have this issue and try and submit a PR to fix it, thanks.

@xvoland
Copy link

xvoland commented Jun 9, 2014

@MikeMcQuaid

$ brew postinstall -v ruby
Error: Directory not empty - /usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems

@mistydemeo
Copy link
Member

At this point we don't need any more debugging information - thanks. Will have a solution soon.

@xvoland
Copy link

xvoland commented Jun 9, 2014

@mistydemeo Sorry! Thank you!

@c-hoeger
Copy link

I guess there's no workaround for the time being?
Update:
My workaround: https://github.com/sstephenson/rbenv#homebrew-on-mac-os-x

@hlian
Copy link

hlian commented Jun 12, 2014

brew edit ruby

diff --git a/Library/Formula/ruby.rb b/Library/Formula/ruby.rb
index cc2b5..fd1f4 100644
--- a/Library/Formula/ruby.rb
+++ b/Library/Formula/ruby.rb
@@ -76,7 +76,7 @@ class Ruby < Formula
       real.mkpath

       link.unlink if link.exist?
-      link.symlink real
+      link.make_symlink(real)
     end
   end

(workaround)

@treyharris
Copy link
Contributor

@hlian Your workaround doesn't work for me:


% (cd /usr/local; git diff Library/Formula/ruby.rb)
diff --git a/Library/Formula/ruby.rb b/Library/Formula/ruby.rb
index cc2b5da..fd1f453 100644
--- a/Library/Formula/ruby.rb
+++ b/Library/Formula/ruby.rb
@@ -76,7 +76,7 @@ class Ruby < Formula
       real.mkpath
 
       link.unlink if link.exist?
-      link.symlink real
+      link.make_symlink(real)
     end
   end
% brew reinstall ruby --with-doc --with-gdbm --with-gmp --with-libffi
==> Reinstalling ruby with --with-doc, --with-gdbm, --with-gmp, --with-libffi
==> Downloading http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.bz2
Already downloaded: /Library/Caches/Homebrew/ruby-2.1.2.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/ruby/2.1.2_1 --enable-shared --disabl
==> make
==> make install
==> Caveats
By default, gem installed executables will be placed into:
  /usr/local/opt/ruby/bin
You may want to add this to your PATH. After upgrades, you can run
  gem pristine --all --only-executables
to restore binstubs for installed gems.
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall ruby`
==> Summary
🍺  /usr/local/Cellar/ruby/2.1.2_1: 14641 files, 82M, built in 4.2 minutes
% brew postinstall ruby
Error: Directory not empty - /usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems
% ls -Fd /usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/**/*(/)
/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/2.1.0/
/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/2.1.0/gems/
/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/2.1.0/gems/rake-10.1.0/
/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/2.1.0/gems/rake-10.1.0/bin/
/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/2.1.0/gems/rdoc-4.1.0/
/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/2.1.0/gems/rdoc-4.1.0/bin/
/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/2.1.0/gems/test-unit-2.1.2.0/
/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/2.1.0/gems/test-unit-2.1.2.0/bin/
/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/2.1.0/specifications/
/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems/2.1.0/specifications/default/

@hlian
Copy link

hlian commented Jun 13, 2014

Error: Directory not empty - /usr/local/Cellar/ruby/2.1.2_1/lib/ruby/gems

Try making the directory empty :)

@treyharris
Copy link
Contributor

@hlian I don't know the semantic result of that—clearly I had rake, test-unit, and rdoc before; do I still need them? These aren't symlinks so if I just blow away those libs and executables, they're gone.

I've managed distros of Perl and Python before, so I'd know what to do in this sort of situation, but I'm a neophyte when it comes to Ruby installs.

@hlian
Copy link

hlian commented Jun 13, 2014

Conjecture: those are the default gems, and the recipe wants to delete them, but it's using #unlink instead of (say) FileUtils#rm_rf, so you might as well delete them.

Qualifier: not a Ruby expert. Just an ordinary dude who wanted to update a CocoaPod.

@treyharris
Copy link
Contributor

@hlian That's what pull request #29986 does in 5dcf6c1, so I'm hoping it's safe? (OTOH, that pull request hasn't been accepted and others earlier in the thread say this is "being worked on", so not sure if this is the right answer or just a "make-it-work-for-now" hack.) I use rake and rdoc myself. I suppose I can always backup those dirs and back out to a previous ruby if it's not the case.

@mistydemeo
Copy link
Member

I'm testing a fix for this that should be ready later today.

mistydemeo added a commit to mistydemeo/homebrew that referenced this issue Jun 13, 2014
This configures rubygems to install all gems into a public, non-versioned
directory by default - both gems and their binaries. (This means that
users no longer need /usr/local/opt/ruby/bin in their PATH.)

This means that we no longer have to monkey with gem directories at all
in postinstall. Bundled gems will be symlinked into this location.

Fixes Homebrew#29982.
Closes Homebrew#29986.
@mistydemeo
Copy link
Member

PR in #30129 for the bots to test/build bottles

mistydemeo added a commit to mistydemeo/homebrew that referenced this issue Jun 13, 2014
This configures rubygems to install all gems into a public, non-versioned
directory by default - both gems and their binaries. (This means that
users no longer need /usr/local/opt/ruby/bin in their PATH.)

This means that we no longer have to monkey with gem directories at all
in postinstall. Bundled gems will be symlinked into this location.

Fixes Homebrew#29982.
Closes Homebrew#29986.
@mistydemeo
Copy link
Member

Pushed the fix.

steve-ayerhart pushed a commit to steve-ayerhart/homebrew that referenced this issue Jun 19, 2014
This configures rubygems to install all gems into a public, non-versioned
directory by default - both gems and their binaries. (This means that
users no longer need /usr/local/opt/ruby/bin in their PATH.)

This means that we no longer have to monkey with gem directories at all
in postinstall. Bundled gems will be symlinked into this location.

Fixes Homebrew#29982.
Closes Homebrew#29986.
@Homebrew Homebrew locked and limited conversation to collaborators Feb 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet