确认系统版本:
root@fv-az392-322:/tmp# cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
root@fv-az392-322:/tmp#
确认ruby版本:
root@fv-az392-322:/tmp# ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]
root@fv-az392-322:/tmp#
安装rbenv:
apt-get install -y rbenv;
确认rbenv版本:
root@fv-az392-322:/tmp# rbenv -v
rbenv 1.1.2
root@fv-az392-322:/tmp#
安装openssl1.0(直接安装是不行的,先添加ppa库):
sudo apt-add-repository -y ppa:rael-gc/rvm;\
sudo apt update -y;
apt-get install -y libssl1.0-dev;\
openssl version -d;
接下来执行如下命令:
eval "$(rbenv init -)";
rbenv versions ;\
rbenv version ;\
rbenv install --list | grep 2.7;
root@fv-az392-322:/tmp# eval "$(rbenv init -)"
rbenv versions ;\
rbenv version ;\
rbenv install --list | grep 2.7;
* system (set by /.rbenv/version)
system (set by /.rbenv/version)
1.8.6-p287
2.0.0-p247
2.2.7
2.7.0-dev
2.7.0-preview1
2.7.0-preview2
2.7.0-preview3
2.7.0-rc1
2.7.0-rc2
2.7.0
2.7.1
jruby-9.2.7.0
rbx-2.2.7
rbx-2.7
rbx-2.71828182
root@fv-az392-322:/tmp#
我们选择2.7.1的版本,直接安装:
rbenv install 2.7.1
root@fv-az392-322:/tmp# rbenv install 2.7.1
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
Installed ruby-2.7.1 to /.rbenv/versions/2.7.1
root@fv-az392-322:/tmp#
试一试看看版本号:
rbenv global 2.7.1;
eval "$(rbenv init -)";
rbenv shell 2.7.1;
rbenv local 2.7.1;
ruby -v
root@fv-az392-322:/tmp# rbenv global 2.7.1;
eval "$(rbenv init -)";
rbenv shell 2.7.1;
ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
root@fv-az392-322:/tmp#
最后一步:
cd /tmp;
gem -v;which gem;
rbenv rehash;
which gem;gem -v;
sudo gem install winrm winrm-fs colorize stringio;\
sudo gem install evil-winrm ;
evil-winrm -h;
还是失败,虽然ruby是2.7,但是gem路径不太对,还是用rvm的方式吧
/.rbenv/versions/2.7.1/bin/gem install winrm winrm-fs colorize stringio;
/.rbenv/versions/2.7.1/bin/gem install evil-winrm ;
/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/evil-winrm-3.4/evil-winrm.rb -h
root@fv-az618-84:/tmp# rbenv install 2.7.1
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
Installed ruby-2.7.1 to /.rbenv/versions/2.7.1
root@fv-az618-84:/tmp# gem -v;which gem;
3.3.5
/.rbenv/shims/gem
root@fv-az618-84:/tmp#
root@fv-az618-84:/tmp# ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]
root@fv-az618-84:/tmp#
root@fv-az618-84:/tmp#
rbenv global 2.7.1;
eval "$(rbenv init -)";
rbenv shell 2.7.1;
rbenv local 2.7.1;
ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
root@fv-az618-84:/tmp#
root@fv-az618-84:/tmp#
root@fv-az618-84:/tmp# gem -v;which gem;
3.1.2
/.rbenv/shims/gem
root@fv-az618-84:/tmp#
报的错误是这个:
oot@fv-az618-84:/tmp# evil-winrm -h;
/var/lib/gems/3.0.0/gems/evil-winrm-3.4/evil-winrm.rb:56:in `': undefined method `+' for nil:NilClass (NoMethodError)
from :85:in `require'
from :85:in `require'
from /var/lib/gems/3.0.0/gems/evil-winrm-3.4/bin/evil-winrm:3:in `'
from /usr/local/bin/evil-winrm:25:in `load'
from /usr/local/bin/evil-winrm:25:in `'
root@fv-az618-84:/tmp#
备忘录:
#/usr/include/openssl/ssl.h:36,
#ossl_hmac.c:57:5: warning: 'HMAC_CTX_new' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
grep ssl.h /tmp/ruby-build.20230415141611.90255.log
root@fv-az618-84:/tmp# rbenv shims
/.rbenv/shims/bundle
/.rbenv/shims/bundler
/.rbenv/shims/erb
/.rbenv/shims/gem
/.rbenv/shims/irb
/.rbenv/shims/racc
/.rbenv/shims/racc2y
/.rbenv/shims/rake
/.rbenv/shims/rdoc
/.rbenv/shims/ri
/.rbenv/shims/ruby
/.rbenv/shims/y2racc
root@fv-az618-84:/tmp#