2015-11-05 64 views
1

我有一個EC2實例Amazon運行Ubuntu 14.4.3。 這將運行Vagrant並使用vagrant-aws插件部署一些虛擬機。 但每次我嘗試安裝插件給我的跟隨誤差:如何在Ubuntu 14.04中爲Vagrant安裝Ruby版本> = 2.0?

[email protected]:~$ 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但仍然給出相同的錯誤。

編輯

[email protected]:~$ ruby -v 
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux] 

流浪安裝ruby1.9,即使我已經安裝了新版本!

[email protected]:/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) ... 

,然後再次相同的錯誤:

[email protected]:/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>' 
+0

這是不可能的:)'ruby -v'返回什麼? –

+0

好吧,看起來vagrant對ruby 1.9有很強的依賴性,所以你需要手動安裝ruby 2.2並確保2.2在PATH中首先出現。所以當你運行'vagrant插件安裝vagrant-aws'時,'ruby -v'應該返回'2.2.3', –

+0

你最近流浪的版本是什麼? –

回答

0

看來,流浪者對紅寶石1.9(由ruby -v檢查)的硬依賴。

所以你需要手動安裝ruby 2.2並確保2.2首先在PATH。然後嘗試通過以下方式再次安裝該插件:

vagrant plugin install vagrant-aws 
0

遇到完全相同的問題。通過從官方下載頁面安裝最新的流浪者解決。

看起來,ubuntu 14上的流浪者似乎非常依賴於ruby 1.9,正如kenorb所說的。 Vagrant官方安裝頁面還建議您不要通過OS軟件包回購安裝vagrant。