ruby - 如何在 Ubuntu 14.04 中为 Vagrant 安装 Ruby 版本 >= 2.0?

标签 ruby ubuntu amazon-web-services vagrant vagrant-plugin

我有一个 EC2 Amazon 中的实例运行 Ubuntu 14.4.3 .
哪个会运行 Vagrant并使用 vagrant-aws 部署一些虚拟机插入。
但是每次我尝试安装插件时都会出现以下错误:

ubuntu@ip-172-25-56-198:~$ vagrant plugin install vagrant-aws
Installing the 'vagrant-aws' plugin. This can take a few minutes...
/usr/lib/ruby/1.9.1/rubygems/installer.rb:388:in `ensure_required_ruby_version_met': net-ssh requires Ruby version >= 2.0. (Gem::InstallError)
    from /usr/lib/ruby/1.9.1/rubygems/installer.rb:156:in `install'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:297:in `block in install'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each_with_index'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `install'
    from /usr/share/vagrant/plugins/commands/plugin/action/install_gem.rb:65:in `block in call'
    from /usr/share/vagrant/plugins/commands/plugin/gem_helper.rb:42:in `block in with_environment'
    from /usr/lib/ruby/1.9.1/rubygems/user_interaction.rb:40:in `use_ui'
    from /usr/share/vagrant/plugins/commands/plugin/gem_helper.rb:41:in `with_environment'
    from /usr/share/vagrant/plugins/commands/plugin/action/install_gem.rb:52:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
    from /usr/share/vagrant/plugins/commands/plugin/action/bundler_check.rb:20:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/builder.rb:116:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:69:in `block in run'
    from /usr/lib/ruby/vendor_ruby/vagrant/util/busy.rb:19:in `busy'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:69:in `run'
    from /usr/share/vagrant/plugins/commands/plugin/command/base.rb:17:in `action'
    from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:27:in `execute'
    from /usr/share/vagrant/plugins/commands/plugin/command/root.rb:56:in `execute'
    from /usr/lib/ruby/vendor_ruby/vagrant/cli.rb:38:in `execute'
    from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:484:in `cli'
    from /usr/bin/vagrant:127:in `<main>'

我有相同版本的Ubuntu在我的desktop机器,没有这个问题。我究竟做错了什么 ?我试图删除 ruby1.9并且只安装 ruby2.2但仍然给出同样的错误。

编辑
ubuntu@ip-172-25-56-198:~$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

Vagrant 安装 ruby​​1.9,即使我安装了较新的版本!
root@ip-172-31-29-138:/tmp# apt-get install -y vagrant
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  ruby1.9.1
Suggested packages:
  ruby1.9.1-examples ri1.9.1 graphviz ruby1.9.1-dev virtualbox
The following NEW packages will be installed:
  ruby1.9.1 vagrant
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/425 kB of archives.
After this operation, 1.898 kB of additional disk space will be used.
Selecting previously unselected package ruby1.9.1.
(Reading database ... 146549 files and directories currently installed.)
Preparing to unpack .../ruby1.9.1_1%3a1.9.3.551-2bbox1~trusty1_amd64.deb ...
Unpacking ruby1.9.1 (1:1.9.3.551-2bbox1~trusty1) ...
Selecting previously unselected package vagrant.
Preparing to unpack .../vagrant_1.4.3-1_all.deb ...
Unpacking vagrant (1.4.3-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up ruby1.9.1 (1:1.9.3.551-2bbox1~trusty1) ...
Setting up vagrant (1.4.3-1) ...

然后,再次出现同样的错误:
root@ip-172-25-56-198:/tmp# vagrant plugin install vagrant-aws
Installing the 'vagrant-aws' plugin. This can take a few minutes...
/usr/lib/ruby/1.9.1/rubygems/installer.rb:388:in `ensure_required_ruby_version_met': net-ssh requires Ruby version >= 2.0. (Gem::InstallError)
    from /usr/lib/ruby/1.9.1/rubygems/installer.rb:156:in `install'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:297:in `block in install'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each_with_index'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `install'
    from /usr/share/vagrant/plugins/commands/plugin/action/install_gem.rb:65:in `block in call'
    from /usr/share/vagrant/plugins/commands/plugin/gem_helper.rb:42:in `block in with_environment'
    from /usr/lib/ruby/1.9.1/rubygems/user_interaction.rb:40:in `use_ui'
    from /usr/share/vagrant/plugins/commands/plugin/gem_helper.rb:41:in `with_environment'
    from /usr/share/vagrant/plugins/commands/plugin/action/install_gem.rb:52:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
    from /usr/share/vagrant/plugins/commands/plugin/action/bundler_check.rb:20:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/builder.rb:116:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:69:in `block in run'
    from /usr/lib/ruby/vendor_ruby/vagrant/util/busy.rb:19:in `busy'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:69:in `run'
    from /usr/share/vagrant/plugins/commands/plugin/command/base.rb:17:in `action'
    from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:27:in `execute'
    from /usr/share/vagrant/plugins/commands/plugin/command/root.rb:56:in `execute'
    from /usr/lib/ruby/vendor_ruby/vagrant/cli.rb:38:in `execute'
    from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:484:in `cli'
    from /usr/bin/vagrant:127:in `<main>'

最佳答案

似乎 vagrant 对 ruby​​ 1.9 有很强的依赖性(通过 ruby -v 检查)。

因此,您需要手动安装 ruby​​ 2.2 并确保 2.2 在 PATH 中排在第一位。 .然后尝试通过以下方式再次安装插件:

vagrant plugin install vagrant-aws

关于ruby - 如何在 Ubuntu 14.04 中为 Vagrant 安装 Ruby 版本 >= 2.0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33556714/

相关文章:

node.js - 如何在dynamodb中插入json

python - EC2、bottle.py连接

amazon-web-services - 创建具有键架构上不存在的属性的表时出现问题

ruby-on-rails - Ruby On Rails 与 Windows Vista - 最佳设置?

ruby - 未初始化的常量 AdminController

ruby - Ruby 中的 RDF 现状

Ruby 数组 reverse_each_with_index

php - MySQL:错误#2002

ruby-on-rails - "rvm requirements"给出的依赖项有什么用?

amazon-web-services - 使用 Code Pipeline 编排云形成