boxen / our-boxen

Copy me for your team.
https://github.com/boxen/our-boxen/
MIT License
2.58k stars 883 forks source link

Lost Bundler on upgrade to El Capitan - how to reinstall Bundler in a safe way for Boxen? #794

Closed henscu closed 8 years ago

henscu commented 8 years ago

I just tried to get my Boxen up to date as per the upgrade instructions. I haven't upgraded since Jan 2015. However the process fails when I get to the bundle install... command below:

rm Puppetfile.lock Gemfile.lock
bundle install --no-deployment --without development --path .bundle
rbenv: bundle: command not found

The `bundle' command exists in these Ruby versions:
  2.1.0

Somehow I lost Bundler from /usr/bin! I looked for a solution online that would be compatible with Boxen.

Some people suggest simply doing a gem install bundler from my home directory. However I saw some warnings about this approach.

What is the best way to reinstall Bundler (or any /usr/bin application) in a way that is compatible with Boxen?

lyzadanger commented 8 years ago

+1

For lack of better idea, our team (all of us have run into this on the El Capitan update) have been taking the gem install bundler route. Haven't noticed any odd side effects, at least yet, with boxen. But, like you, we have some lingering concerns that this isn't the best way.

Looks like other folks are running into this...good to know we're not alone, I suppose!

jacobbednarz commented 8 years ago

Within our private fork, we have made a couple of adjustments which address this in El Capitan.

1) Updating system bundler

diff --git a/script/bootstrap b/script/bootstrap
index a0d4026..7282a29 100755
--- a/script/bootstrap
+++ b/script/bootstrap
@@ -54,10 +54,10 @@ set -e

 # FIX: only sudo if gem home isn't writable

-(/usr/bin/gem spec bundler -v '~> 1.5.3' >/dev/null 2>&1) || {
+(/usr/bin/gem spec bundler -v '~> 1.10.5' >/dev/null 2>&1) || {
     log "====> Installing bundler to system ruby"
     /usr/bin/sudo -p "Password for sudo to install bundler: " \
-        /usr/bin/gem install bundler -v '~> 1.5.3' --no-rdoc --no-ri
+        /usr/bin/gem install bundler -v '~> 1.10.5' --no-rdoc --no-ri
 }
 PATH="/Library/Ruby/bin:$PATH"

2) Adding system bundler to the $PATH

diff --git a/script/bootstrap b/script/bootstrap
index f233066..3b611e5 100755
--- a/script/bootstrap
+++ b/script/bootstrap
@@ -59,7 +59,7 @@ set -e
     /usr/bin/sudo -p "Password for sudo to install bundler: " \
         /usr/bin/gem install bundler -v '1.10.5' --no-rdoc --no-ri
 }
-PATH="/Library/Ruby/bin:$PATH"
+PATH="/Library/Ruby/bin:$(gem which bundler | sed -e 's!lib/bundler.rb!bin!'):$PATH"

 # Use checksums to quickly determine if we need to re-bundle

We are looking at pushing these upstream after getting some more testing around the changes but feel free to apply it and let me know how it works out for you.

fivetanley commented 8 years ago

@jacobbednarz's patch worked wonders for me. Thank you!

henscu commented 8 years ago

@jacobbednarz , what's the easiest way to test your fix? Is it:

  1. Create a branch
  2. Edit script/bootstrap as above
  3. Re-run Boxen to fix path to bundler
  4. Rerun Boxen upgrade, in which the bundler command should now work.

Or do I need to nuke Boxen, then re-run it?

henscu commented 8 years ago

@jacobbednarz patch worked for me..!

jacobbednarz commented 8 years ago

My apologies @henscu - I was on vacation when your question came through and only just noticed this pop up again in my feed. The usual way I run the testing is just to checkout the remote branch from the Boxen directory and then run boxen. However, this one was slightly different so I nuked Boxen and started fresh (as that was where the problem existed).

henscu commented 8 years ago

Thanks @jacobbednarz . Can I close this issue now or should I wait until #804 is merged?

jacobbednarz commented 8 years ago

When #804 is merged, it should close this automagically. If you're happy with the state of #804, drop a comment over there so we don't need to jump back and forth between the two for references :)