Skip to content

Instantly share code, notes, and snippets.

@nhatkha1407
Forked from bill-mfv/install.md
Last active April 19, 2020 20:26
Show Gist options
  • Save nhatkha1407/5dacc9e4391a6f0c45b42f60a5017f52 to your computer and use it in GitHub Desktop.
Save nhatkha1407/5dacc9e4391a6f0c45b42f60a5017f52 to your computer and use it in GitHub Desktop.
Install RoR env

HomeBrew is a package manager for OSX. Brew install missing stuff so easy…

  • Install Homebrew:
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

RVM: is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.

  • Install GPG keys:
    brew install gnupg
    gpg --keyserver hkp://51.38.91.189 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
  • Install RVM:
    \curl -sSL https://get.rvm.io | bash -s stable
  • Install Ruby:
    rvm install 2.6.3 (2.6.3 is version of Ruby, you can change it to whater version you want)

Because each project will have a different gem list, so you should use a gemset for each project. In local you should create a file .rvmrc in project folder.
Example: if project is using ruby 2.6.3, we will have
rvm use 2.6.3@gemset_name --create

Each time we cd into the project folder, the rvm will use right gemset for this project.

MySQL

Version 5.7

  • Find older mysql versions
    brew search mysql

  • Install older mysql version . brew install mysql@5.7

  • Start agent for older version of mysql (including on login) . ln -sfv /usr/local/opt/mysql@5.7/*.plist ~/Library/LaunchAgents launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist

  • Unlink current mysql version . brew unlink mysql

  • Check older mysql version . ls /usr/local/Cellar/mysql@5.7
    Example output: 5.7.25

  • Link the older version (above output) . brew switch mysql@5.7 5.7.25

  • If you have trouble with installing the mysql gem when bundle install, you can run:
    gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/' -- --with-mysql-config=/usr/local/opt/mysql@5.7/bin/mysql_config

  • Start & Stop mysql service:
    /usr/local/opt/mysql@5.7/bin/mysql.server start /usr/local/opt/mysql@5.7/bin/mysql.server stop


rvm install 2.7.1
rvm use 2.7.1@project_name --create
gem install rails
rails new . --skip-test --skip-bundle --database=mysql
cp config/database.yml config/database.yml.example
group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rspec-rails', '~> 3.7'
end
bundle
rails g rspec:install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment