5.安装RVM和Ruby的步骤(Ubuntu)

1.安装GPG密钥

sudo apt install gnupg2
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

或者

sudo apt install gnupg
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

2.安装RVM

最新稳定版

sudo apt-get update && sudo apt-get install curl git
\curl -sSL https://get.rvm.io | bash -s stable      

get.rvm.io跳转到https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer,可以使用一下命令同等安装:

\curl https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer | bash -s stable

如果总是报错curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused的解决方案

安装完以后运行以下命令:

echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc

3.安装Ruby

#配置 ruby-china ruby源(RVM 通用版)
echo "ruby_url=https://cache.ruby-china.com/pub/ruby" > ~/.rvm/user/db
#配置 ruby-china ruby源(RVM PPA版)
echo "ruby_url=https://cache.ruby-china.com/pub/ruby" > /usr/share/rvm/user/db
rvm reload
#安装ruby3.0.2(忽略二进制,否则可能会请求 rubies.travis-ci.org)
rvm install 3.0.2 --disable-binary
#切换ruby 3.0.2为 current && default 版本   
rvm use 3.0.2 --default
ruby -v
#此处会非常慢,请耐心等待,除非翻q
gem update --system --no-document
#查看版本号看是否升级成功
gem -v
#更改rubychina gem源            
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
#查看源列表,确保只有 gems.ruby-china.com
gem sources -l
#安装bundler依赖包工具
gem install bundler --no-document
#更改rubychina bundler gem源,修改的~/.bundle/config全局配置,非gemfile
bundle config mirror.https://rubygems.org https://gems.ruby-china.com

原创文章,作者:huoxiaoqiang,如若转载,请注明出处:https://www.huoxiaoqiang.com/ruby/rvm/1747.html

发表评论

登录后才能评论