$ brew install rbenv ruby-build
$ rbenv init
Load rbenv automatically by appending
the following to ~/.bash_profile:
eval "$(rbenv init - bash)"
// list latest stable versions:
$ rbenv install -l
// install a Ruby version, rbenv将把ruby安装在~/.rbenv/目录下
$ rbenv install 3.1.3
// 设置全局默认的ruby版本,原理为通过这个文件控制~/.rbenv/version
$ rbenv global 3.1.3
$ rbenv versions
system
* 3.1.3 (set by ~/.rbenv/version)
$ which ruby
~/.rbenv/shims/ruby
// 设置单个项目使用的ruby版本,原理为通过将版本名写入当前项目目录下的.ruby-version文件实现
$ rbenv local 3.1.3
// 安装rails
$ gem install rails
// 列出已安装的gem
$ gem list
bundle init
bundle add rspec
bundle install
bundle exec rspec
source 'https://rubygems.org'
gem 'jekyll'
gem 'rack', '~> 2.2.4'
gem 'rspec'
$ bundle install
$ git add Gemfile Gemfile.lock
$ bundle exec jekyll serve