Last active
February 15, 2018 13:27
-
-
Save yoyozi/9c7459e87d590d1d3c37f7bc1448fed2 to your computer and use it in GitHub Desktop.
Setup dev env on Mac Sierra
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Open terminal | |
> ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
Say yes to X-Code (have fast connection for download) | |
> brew install rbenv ruby-build | |
Add rbenv to bash so that it loads every time you open a terminal | |
> echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile | |
> source ~/.bash_profile | |
Install Ruby | |
> rbenv install 2.4.0 | |
> rbenv global 2.4.0 | |
> ruby -v | |
More on rbenv | |
rbenv-bundler is a near-invaluable plugin that makes the rbenv shims Bundler-aware and alleviates you from needing to type | |
bundler exec in front of every command. It is also easy to install straight from Github. | |
git clone git://github.com/carsomyr/rbenv-bundler.git ~/.rbenv/plugins/bundler | |
Bundler is the only Gem that you need install the traditional way. You will need to do this once for each version of Ruby | |
that you have. The rehash command updates the shim for the bundle binary. | |
gem install bundler | |
rbenv rehash | |
To start a new project | |
To find out what the most recent Rails version is, use the command gem search rails | grep "^rails ". | |
Create a directory for your application along with a Gemfile to specify your desired Rails version and | |
let Bundler install the dependent gems: | |
cd /tmp/rails-apps | |
mkdir my-first-app | |
cd my-first-app | |
echo "source 'https://rubygems.org'" > Gemfile | |
echo "gem 'rails', '5.0.1'" >> Gemfile | |
bundle install | |
Check that the correct version has been installed using bundle exec rails -v or if you installed the plugin above just rails -v | |
Now create your application, let Rails create a new Gemfile (or rather overwrite the existing one by using the --force flag) and | |
instead of installing the bundle (--skip-bundle) update it manually: | |
bundle exec rails new . --force --skip-bundle | |
or just if plugin installed | |
rails new myapp -d postgresql | |
rails new . -d postgresql --force --skip-bundle | |
bundle update | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment