現象:
linux
[root@arslinux-01 ~]# gem install redis Fetching: redis-4.1.2.gem (100%) ERROR: Error installing redis: redis requires Ruby version >= 2.3.0.
解決:
git
安裝 rvm 來更新 rubygithub
1)下載、生效redis
[root@arslinux-01 ~]# gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB [root@arslinux-01 ~]# useradd -g rvm rvm [root@arslinux-01 ~]# source /etc/profile.d/rvm.sh [root@arslinux-01 ~]# \curl -sSL https://get.rvm.io | bash -s stable
2))改rvm下載 ruby 的源,到鏡像 ruby chinaapi
[root@arslinux-01 ~]# gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ https://gems.ruby-china.com/ added to sources https://rubygems.org/ removed from sources
3)從新 \curlruby
[root@arslinux-01 ~]# \curl -sSL https://get.rvm.io | bash -s stable
4)安裝完成後的 rvm 的版本bash
[root@arslinux-01 ~]# rvm -v rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
5)查看 rvm 庫已知 ruby 版本curl
[root@arslinux-01 ~]# rvm list known # MRI Rubies [ruby-]1.8.6[-p420] [ruby-]1.8.7[-head] # security released on head [ruby-]1.9.1[-p431] [ruby-]1.9.2[-p330] [ruby-]1.9.3[-p551] [ruby-]2.0.0[-p648] [ruby-]2.1[.10] [ruby-]2.2[.10] [ruby-]2.3[.8] [ruby-]2.4[.6] [ruby-]2.5[.5] [ruby-]2.6[.3] [ruby-]2.7[.0-preview1] ruby-head
6)安裝 ruby 2.3.0ide
[root@arslinux-01 ~]# rvm install 2.3.0
7)安裝完後 ruby 版本ui
[root@arslinux-01 ~]# ruby -v ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
8)從新 gem install redis
[root@arslinux-01 ~]# gem install redis Fetching redis-4.1.2.gem Successfully installed redis-4.1.2 Parsing documentation for redis-4.1.2 Installing ri documentation for redis-4.1.2 Done installing documentation for redis after 2 seconds 1 gem installed
成功
最後:
由於我是用 ruby22xx.spec 來編譯製做 rpm 包,再 yum localinstall 安裝的 ruby 2.2.3
若是 須要 ruby 版本爲 2.3.0,那麼下一個 ruby 2.3.0的rpm包,用 ruby2.3.x.spec 是否可行?
cd ~/rpmbuild/SPECS
wget https://raw.github.com/xiexianbin/ruby-rpm/master/ruby2.3.x.spec
rpmbuild -bb ruby2.3.1.spec
有時間試一下~