Skip to content

Instantly share code, notes, and snippets.

@prsimp
Last active December 12, 2015 12:39
Show Gist options
  • Save prsimp/4773603 to your computer and use it in GitHub Desktop.
Save prsimp/4773603 to your computer and use it in GitHub Desktop.
p385 Upgrade

Assumption

You installed rbenv and ruby-build via homebrew.

Simple Upgrade

  1. Open a terminal.
  2. curl https://gist.github.com/prsimp/4773603/raw/upgrade_385.sh | sh
  3. Drink some coffee or do something while Ruby compiles.
  4. Profit!

Troubleshooting

  • If you see an error from homebrew complaining about "untracked working files" run this command:
    cd $(brew --repository) && git fetch origin && git reset --hard origin/master && cd -

What the heck is this doing?

  1. Updates your homebrew formulae
  2. Upgrades rbenv to 0.4.0 if you haven't already.
  3. Upgrades ruby-build if you haven't already.
  4. Installs ruby 1.9.3p385 and sets it as your default global Ruby (aren't we presumptious!)
  5. Installs the bundler and rails gems globally.
  6. Prints a message about making sure to install bundler and bundle for all apps.
#!/usr/bin/env bash
RBENV_VERSION='0.4.0'
RUBY_VERSION='1.9.3-p385'
set -e
cd $HOME
echo "$(tput setaf 2)** Updating homebrew formulae...$(tput sgr0)"
brew update
echo "$(tput setaf 2)** Updating rbenv...$(tput sgr0)"
if $(rbenv -v | grep "$RBENV_VERSION" &> /dev/null); then
echo "Already up-to-date."
else
brew upgrade rbenv
fi
echo "$(tput setaf 2)** Updating ruby-build...$(tput sgr0)"
if $(ruby-build --definitions | grep -q "$RUBY_VERSION" &> /dev/null); then
echo "Already up-to-date."
else
brew upgrade ruby-build
fi
echo "$(tput setaf 2)** Checking your Ruby versions...$(tput sgr0)"
if $(rbenv versions | grep -q "$RUBY_VERSION" &> /dev/null); then
echo "Ruby $RUBY_VERSION already installed."
else
echo "Installing Ruby $RUBY_VERSION..."
rbenv install $RUBY_VERSION
fi
echo "Setting $RUBY_VERSION the global default."
rbenv global $RUBY_VERSION
gem install bundler rails ruby-debug19
rbenv rehash
echo "$(tput setaf 3)\n**NOTES**"
echo "You will still need to install bundler and the gems for each app in new gemsets."
echo "Inside each app root directory, run 'gem install bundler && bundle install'.$(tput sgr0)"
@zmoazeni
Copy link

Paul, can you update the docs to also install "debugger" as a gem. I noticed that installing from bundler fails but installing manually was fine. It might just be a Gemfile.lock dependency that we need to bump up.

@prsimp
Copy link
Author

prsimp commented Feb 15, 2013

Script updated. Installing ruby-debug19 globally should generate the necessary files for our apps to bundle successfully out of the gate.

@zmoazeni
Copy link

Ken had trouble with p385 installing and we got it fixed by first running export CC=gcc. Found from stackoverflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment