Skip to content

Instantly share code, notes, and snippets.

@jhirbour
Last active December 22, 2015 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhirbour/6463036 to your computer and use it in GitHub Desktop.
Save jhirbour/6463036 to your computer and use it in GitHub Desktop.
Getting RoR up and running on OS X
How to get RoR running on OS X.
# Supported OS
OS X: 10.8.4
# PREFACE:
* None of these commands should be run as root. Run them as the user you want to do devlopment as. There ARE steps where you'll be prompted for your password.
* you SHOULD NOT have mysql installed locally if you intend to use this guide... if you do the "brew install mysql" commands may break it...
* the Pow and Anvil steps are 100% optional (this does not include the .ruby-version and .ruby-gemset) steps. Pow is a webs erver for RoR and Anvil is a gui front end (just a simple program in your menu bar...)
# Install
There is some debate about which GCC you REALLY need. If you cant' install XCODE then you CAN just try using the home brew package. (apple-gcc42).
## Install Xcode
* Once installed, create a new project (save it anywhere it's a throw away) ()If prompted to install any packages (from xcode) just install)
* Once the project is created, go to the Xcode menu and choose preferences
* Now click on the downloads tab and click install next to the "Command Line Tools"
* Once downloaded your all set and can quite Xcode
## Install Homebrew
* Open terminal paste the command below
```
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
```
* run brew doctor to make sure you're GTG you shoudl see "Your system is ready to brew."
```
brew doctor
```
## Install Xquartz
* Install xquartz
```
http://xquartz.macosforge.org/landing/
```
* Download and run the installer: next, next, next finish. (sign away first child)
## Install Homebrew packages
* Install needful homebrew pacakges
```
brew install git
```
* (close and reopen your terminal after this one)
* install all the needful
```
brew install autoconf
brew install automake
brew install imagemagick
brew install libyaml openssl sqlite wget tree readline libxslt libksba pkg-config libxml2 libgpg-error gdbm
brew tap homebrew/dupes
brew install apple-gcc42
brew install mysql
```
* The Mysql Install may warn about about starting mysql... but you can ignore it
* make sure you run the command for "to have lunahcd start mysql at login"
## Misc
* Progress logging for CURL
```
echo progress-bar >> ~/.curlrc
```
## Install RVM
* (don't miss the preceding \)
```
\curl -L https://get.rvm.io | bash -s stable --ruby
```
* logout and log back in
* run
```
type rvm | head -1
```
* update rvm to the lastest version.
```
rvm get
```
* you should see "rvm is a function"
## Install POW (Ruby/Rack/Rails web server)
```
curl get.pow.cx | sh
```
## Install Anvil (Gui frontend for POW)
```
http://anvilformac.com/support (download install, drop in application folder)
```
* launch the app (from your applications folder)
* click the anvil in the task bar then the gear icon and then "start at login"
## Install Ruby
* You can use "ruby-1.9.3" or "ruby-2.0.0" pick your pleasure
```
rvm install ruby-1.9.3
```
* you'll see the full name and the patch version from the above command. Use the whole string below where I have "ruby-1.9.3-p448" Make note of this Ruby version for later use.
## Set default ruby
```
rvm default ruby-1.9.3-p448
```
## Create gemset
```
rvm gemset create somegemsetname
```
## use the gemset
```
rvm gemset use somegemsetname
```
## Install Rails
* this part may take a while there's a lot of packages to install that Rails needs. Bundler will will do the needful.
```
gem install rails
```
## Create a new Rails project
* Rails will create a new directory where you type this command.. so use "cd" to change to a directory where you want to store your project folder. IE: "cd ~/Documents" and then your project will be in Documents/project_name
* Make note of the full path to this direcotry you're
```
cd ~/Documents
rails new project_name
cd project_name
```
* It's helpful to capture the output of what files get created (paste it into a text document (copy/paste)) so you can see what files got created, and the Rails directory structure.
## Set Ruby version and Gemset name
* Put the ruby version into a file (this tells RVM later what version of ruby to look for)
* Make sure you are in your project directory first "cd ~/Documents/project_name"
* Note: I just put the version of ruby withouth the p### at the end.
* Note: this stuff used to go into a file called .rvmrc but that has been deprecated.
```
echo "ruby-1.9.3" > .ruby-version
echo "somegemsetname> > .ruby-gemset
```
## Link pow to your project
* This step tells pow where to find your rails project
```
cd ~/.pow
ln -s ~/Documents/myproject
cd ~/Documents/myproject
```
## Setup Pow to use RVM
* If you get an error on this step you probably didn't run "rvm get" from the rvm setup step above, or it didn't work.
```
cd ~/Documents/git/sos.primetimesolutions.net
rvm env . -- --env > .powenv
```
## Configure Pow
```
vi ~/.powconfig
```
## Not using pow/anvil
If you are not using pow/anvil and you just want to see your rails project, you can start the rails built in web server.
```
cd ~/Documents/myproject
rails server
```
* Then you can navigate to http://127.0.0.1:3000 in your browser or http://localhost:3000
## Finally
Now you should be able to:
- click anvil (in your task bar) and navigate to project_name.dev
OR
- just goto http://project_name.dev in your browser.
## Post note:
SOME people have weird issues with POW and DNS ... it basically makes anything.dev resolve to your local computer.
## Post Post Note:
Other helpful commands
* Debug rails issues
```
rails console
```
* Access the database (sqllite by default)
```
rails dbconsole
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment