我在Ubuntu 14.04上使用Rbenv安装Ruby版本时遇到问题(在Vagrant,Berkshelf,在Windows 10上运行的VirtualBox)。
这是Berksfile:
source "https://supermarket.chef.io"
cookbook 'apt'
cookbook 'build-essential'
cookbook 'mysql', '5.5.3'
cookbook 'postgresql', '~> 4.0.6'
cookbook 'ruby_build'
#cookbook 'rbenv', git: 'https://github.com/aminin/chef-rbenv.git'
#cookbook 'rbenv', git: 'https://github.com/chef-rbenv/chef_rbenv'
cookbook 'ruby_rbenv', git: 'https://github.com/chef-rbenv/ruby_rbenv' #'~> 1.0.1'
cookbook 'vim'
cookbook 'nodejs', '~> 2.4.4'
cookbook 'chef-vagrant-frontback', path: 'chef-vagrant-frontback'
Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version '>= 1.5'
# Change these two paths to folders
# FRONTEND = "../linkip-frontend/"
BACKEND_PATH = "../linkip-backend/"
BACKEND_NAME = "linkip-backend"
def require_plugins(plugins = {})
needs_restart = false
plugins.each do |plugin, version|
next if Vagrant.has_plugin?(plugin)
cmd =
[
'vagrant plugin install',
plugin
]
cmd << "--plugin-version #{version}" if version
system(cmd.join(' ')) || exit!
needs_restart = true
end
exit system('vagrant', *ARGV) if needs_restart
end
require_plugins \
'vagrant-bindfs' => '0.4.8',
#'vagrant-librarian-chef-nochef' => '0.2.0',
'vagrant-berkshelf' => '4.1.0',
'vagrant-vbguest' => '0.12.0'
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.network "forwarded_port", guest: 4567, host: 4567
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
config.vm.synced_folder "#{BACKEND_PATH}", "/project/#{BACKEND_NAME}",
# Tell Vagrant to use rsync for this shared folder.
type: "rsync",
rsync__auto: "true",
rsync__exclude: ".git/",
owner: "vagrant",
group: "vagrant",
id: "shared-folder-id"
# config.vm.synced_folder "#{FRONTEND}", "/project/#{FRONTEND}",
# # Tell Vagrant to use rsync for this shared folder.
# type: "rsync",
# rsync__auto: "true",
# rsync__exclude: ".git/",
# owner: "vagrant",
# group: "vagrant",
# id: "shared-folder-id"
config.berkshelf.enabled = true
# Use Chef Solo to provision our virtual machine
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
chef.add_recipe "apt"
chef.add_recipe "nodejs"
chef.add_recipe "ruby_build"
chef.add_recipe "ruby_rbenv::user"
#chef.add_recipe "rbenv::vagrant"
chef.add_recipe "vim"
chef.add_recipe "mysql::server"
chef.add_recipe "mysql::client"
chef.add_recipe "chef-vagrant-frontback"
# Install Ruby 2.2.1 and Bundler
# Set an empty root password for MySQL to make things simple
chef.json = {
rbenv: {
user_installs: [{
user: 'vagrant',
rubies: ["2.2.1"],
global: "2.2.1",
gems: {
"2.2.1" => [
{ name: "bundler" },
{ name: "rake" },
{ name: "rails",
version: "4.2.4"
}
]
}
}]
},
mysql: {
server_root_password: ''
}
}
end
end
这是日志开始显示错误的部分:
==> default: [2016-07-12T02:53:13+00:00] INFO: Building ruby_rbenv_ruby[2.2.1 (vagrant)] (vagrant), this could take a while...
==> default:
==> default: * ruby_rbenv_script[rbenv install 2.2.1 (vagrant)] action run
==> default:
==> default: * script[rbenv install 2.2.1 (vagrant)] action run
==> default:
==> default: [execute] Downloading ruby-2.2.1.tar.bz2...
==> default: -> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.1.tar.bz2
==> default: Installing ruby-2.2.1...
==> default:
==> default: BUILD FAILED
==> default: (Ubuntu 14.04 using ruby-build 20160602)
==> default:
==> default: Inspect or clean up the working tree at /tmp/ruby-build.20160712025313.30196
==> default:
==> default: Results logged to /tmp/ruby-build.20160712025313.30196.log
==> default:
==> default:
==> default: Last 10 log lines:
==> default: make[3]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1/ext/fiddle/libffi-3.2.1'
==> default: linking shared-object fiddle.so
==> default: /usr/bin/ld: ./libffi-3.2.1/.libs/libffi.a(raw_api.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
==> default: ./libffi-3.2.1/.libs/libffi.a: error adding symbols: Bad value
==> default: collect2: error: ld returned 1 exit status
==> default: make[2]: *** [../../.ext/x86_64-linux/fiddle.so] Error 1
==> default: make[2]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1/ext/fiddle'
==> default: make[1]: *** [ext/fiddle/all] Error 2
==> default: make[1]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1'
==> default: make: *** [build-ext] Error 2
==> default:
==> default:
==> default:
==> default: ================================================================================
==> default:
==> default: Error executing action `run` on resource 'script[rbenv install 2.2.1 (vagrant)]'
==> default: ================================================================================
==> default:
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default: ------------------------------------
==> default: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of "bash" "/tmp/chef-script20160712-29543-1b85p2w" ----
==> default: STDOUT:
==> default: STDERR: Downloading ruby-2.2.1.tar.bz2...
==> default: -> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.1.tar.bz2
==> default: Installing ruby-2.2.1...
==> default:
==> default: BUILD FAILED (Ubuntu 14.04 using ruby-build 20160602)
==> default:
==> default: Inspect or clean up the working tree at /tmp/ruby-build.20160712025313.30196
==> default: Results logged to /tmp/ruby-build.20160712025313.30196.log
==> default:
==> default: Last 10 log lines:
==> default: make[3]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1/ext/fiddle/libffi-3.2.1'
==> default: linking shared-object fiddle.so
==> default:
==> default:
==> default: /usr/bin/ld: ./libffi-3.2.1/.libs/libffi.a(raw_api.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
==> default:
==> default: ./libffi-3.2.1/.libs/libffi.a: error adding symbols: Bad value
==> default: collect2: error: ld returned 1 exit status
==> default:
==> default: make[2]: *** [../../.ext/x86_64-linux/fiddle.so] Error 1
==> default: make[2]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1/ext/fiddle'
==> default: make[1]: *** [ext/fiddle/all] Error 2
==> default: make[1]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1'
==> default: make: *** [build-ext] Error 2
==> default: ---- End output of "bash" "/tmp/chef-script20160712-29543-1b85p2w" ----
==> default: Ran "bash" "/tmp/chef-script20160712-29543-1b85p2w" returned 1
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default: /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'
==> default: /var/chef/cache/cookbooks/ruby_rbenv/providers/ruby.rb:78:in `perform_install'
==> default: /var/chef/cache/cookbooks/ruby_rbenv/providers/ruby.rb:38:in `block in class_from_file'
==> default: /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'
==> default:
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /var/chef/cache/cookbooks/ruby_rbenv/providers/script.rb
==> default:
==> default: 40: script new_resource.name do
==> default: 41: interpreter 'bash'
==> default: 42: code script_code
==> default: 43: user new_resource.user if new_resource.user
==> default: 44: creates new_resource.creates if new_resource.creates
==> default: 45: cwd new_resource.cwd if new_resource.cwd
==> default: 46: group new_resource.group if new_resource.group
==> default: 47: returns new_resource.returns if new_resource.returns
==> default: 48: timeout new_resource.timeout if new_resource.timeout
==> default: 49: umask new_resource.umask if new_resource.umask
==> default: 50:
==> default: 51: environment(script_environment)
==> default: 52: end
==> default: 53: end
==> default:
==> default:
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /var/chef/cache/cookbooks/ruby_rbenv/providers/script.rb:40:in `run_script'
==> default:
==> default: script("rbenv install 2.2.1 (vagrant)") do
==> default: action [:run]
==> default: retries 0
==> default: retry_delay 2
==> default: default_guard_interpreter :default
==> default: command "rbenv install 2.2.1 (vagrant)"
==> default: backup 5
==> default: environment {"RBENV_ROOT"=>"/home/vagrant/.rbenv", "USER"=>"vagrant", "HOME"=>"/home/vagrant"}
==> default: returns [0]
==> default: user "vagrant"
==> default: code "export RBENV_ROOT=\"/home/vagrant/.rbenv\"\nexport PATH=\"${RBENV_ROOT}/bin:$PATH\"\neval \"$(rbenv init -)\"\nrbenv install 2.2.1 \n"
==> default: interpreter "bash"
==> default: declared_type :script
==> default: cookbook_name "ruby_rbenv"
==> default: end
==> default:
==> default: Platform:
==> default: ---------
==> default: x86_64-linux
==> default:
==> default:
==> default: [2016-07-12T03:17:44+00:00] INFO: Running queued delayed notifications before re-raising exception
==> default:
==> default:
==> default:
==> default: ================================================================================
==> default:
==> default: Error executing action `run` on resource 'ruby_rbenv_script[rbenv install 2.2.1 (vagrant)]'
==> default: ================================================================================
==> default:
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default: ------------------------------------
==> default: script[rbenv install 2.2.1 (vagrant)] (/var/chef/cache/cookbooks/ruby_rbenv/providers/script.rb line 40) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of "bash" "/tmp/chef-script20160712-29543-1b85p2w" ----
==> default: STDOUT:
==> default: STDERR: Downloading ruby-2.2.1.tar.bz2...
==> default: -> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.1.tar.bz2
==> default: Installing ruby-2.2.1...
==> default:
==> default: BUILD FAILED (Ubuntu 14.04 using ruby-build 20160602)
==> default:
==> default:
==> default: Inspect or clean up the working tree at /tmp/ruby-build.20160712025313.30196
==> default: Results logged to /tmp/ruby-build.20160712025313.30196.log
==> default:
==> default: Last 10 log lines:
==> default: make[3]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1/ext/fiddle/libffi-3.2.1'
==> default: linking shared-object fiddle.so
==> default: /usr/bin/ld: ./libffi-3.2.1/.libs/libffi.a(raw_api.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
==> default: ./libffi-3.2.1/.libs/libffi.a: error adding symbols: Bad value
==> default: collect2: error: ld returned 1 exit status
==> default: make[2]: *** [../../.ext/x86_64-linux/fiddle.so] Error 1
==> default: make[2]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1/ext/fiddle'
==> default: make[1]: *** [ext/fiddle/all] Error 2
==> default: make[1]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1'
==> default: make: *** [build-ext] Error 2
==> default: ---- End output of "bash" "/tmp/chef-script20160712-29543-1b85p2w" ----
==> default: Ran "bash" "/tmp/chef-script20160712-29543-1b85p2w" returned 1
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default: /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'
==> default: /var/chef/cache/cookbooks/ruby_rbenv/providers/ruby.rb:78:in `perform_install'
==> default: /var/chef/cache/cookbooks/ruby_rbenv/providers/ruby.rb:38:in `block in class_from_file'
==> default: /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'
==> default:
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /var/chef/cache/cookbooks/ruby_rbenv/providers/ruby.rb
==> default:
==> default: 72: rbenv_script "#{command} #{which_rbenv}" do
==> default: 73: code command
==> default: 74: user rbenv_user if rbenv_user
==> default: 75: root_path rbenv_prefix if rbenv_prefix
==> default: 76: environment rbenv_env if rbenv_env
==> default: 77: action :nothing
==> default: 78: end.run_action(:run)
==> default: 79:
==> default: 80: Chef::Log.debug("#{new_resource} build time was " \
==> default: 81: "#{(Time.now - install_start) / 60.0} minutes")
==> default:
==> default: 82:
==> default:
==> default:
==> default: 83: new_resource.updated_by_last_action(true)
==> default:
==> default:
==> default: 84: end
==> default:
==> default: 85: end
==> default:
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /var/chef/cache/cookbooks/ruby_rbenv/providers/ruby.rb:72:in `perform_install'
==> default:
==> default: ruby_rbenv_script("rbenv install 2.2.1 (vagrant)") do
==> default: action [:nothing]
==> default: retries 0
==> default: retry_delay 2
==> default: default_guard_interpreter :default
==> default: declared_type :rbenv_script
==> default: cookbook_name "ruby_rbenv"
==> default: user "vagrant"
==> default: code "rbenv install 2.2.1 "
==> default: returns [0]
==> default: end
==> default:
==> default: Platform:
==> default: ---------
==> default: x86_64-linux
==> default:
==> default:
==> default:
==> default:
==> default: ================================================================================
==> default: Error executing action `install` on resource 'ruby_rbenv_ruby[2.2.1 (vagrant)] (vagrant)'
==> default: ================================================================================
==> default:
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default: ------------------------------------
==> default: ruby_rbenv_script[rbenv install 2.2.1 (vagrant)] (/var/chef/cache/cookbooks/ruby_rbenv/providers/ruby.rb line 72) had an error: Mixlib::ShellOut::ShellCommandFailed: script[rbenv install 2.2.1 (vagrant)] (/var/chef/cache/cookbooks/ruby_rbenv/providers/script.rb line 40) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of "bash" "/tmp/chef-script20160712-29543-1b85p2w" ----
==> default: STDOUT:
==> default: STDERR: Downloading ruby-2.2.1.tar.bz2...
==> default: -> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.1.tar.bz2
==> default: Installing ruby-2.2.1...
==> default:
==> default: BUILD FAILED (Ubuntu 14.04 using ruby-build 20160602)
==> default:
==> default: Inspect or clean up the working tree at /tmp/ruby-build.20160712025313.30196
==> default: Results logged to /tmp/ruby-build.20160712025313.30196.log
==> default:
==> default: Last 10 log lines:
==> default: make[3]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1/ext/fiddle/libffi-3.2.1'
==> default: linking shared-object fiddle.so
==> default:
==> default: /usr/bin/ld: ./libffi-3.2.1/.libs/libffi.a(raw_api.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
==> default:
==> default:
==> default: ./libffi-3.2.1/.libs/libffi.a: error adding symbols: Bad value
==> default: collect2: error: ld returned 1 exit status
==> default: make[2]: *** [../../.ext/x86_64-linux/fiddle.so] Error 1
==> default: make[2]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1/ext/fiddle'
==> default: make[1]: *** [ext/fiddle/all] Error 2
==> default: make[1]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1'
==> default:
==> default: make: *** [build-ext] Error 2
==> default:
==> default:
==> default: ---- End output of "bash" "/tmp/chef-script20160712-29543-1b85p2w" ----
==> default:
==> default: Ran "bash" "/tmp/chef-script20160712-29543-1b85p2w" returned 1
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default: /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'
==> default: /var/chef/cache/cookbooks/ruby_rbenv/providers/ruby.rb:78:in `perform_install'
==> default: /var/chef/cache/cookbooks/ruby_rbenv/providers/ruby.rb:38:in `block in class_from_file'
==> default: /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'
==> default:
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /var/chef/cache/cookbooks/ruby_rbenv/recipes/user.rb
==> default:
==> default: 47: rbenv_ruby "#{rubie} (#{rbenv_user['user']})" do
==> default: 48: definition rubie
==> default: 49: user rbenv_user['user']
==> default: 50: root_path rbenv_user['root_path'] if rbenv_user['root_path']
==> default: 51: end
==> default: 52: end
==> default:
==> default:
==> default:
==> default:
==> default:
==> default: Compiled Resource:
==> default:
==> default: ------------------
==> default: # Declared in /var/chef/cache/cookbooks/ruby_rbenv/recipes/user.rb:47:in `block (2 levels) in from_file'
==> default:
==> default: ruby_rbenv_ruby("2.2.1 (vagrant)") do
==> default: action [:install]
==> default: retries 0
==> default: retry_delay 2
==> default: default_guard_interpreter :default
==> default: declared_type :rbenv_ruby
==> default: cookbook_name "ruby_rbenv"
==> default: recipe_name "user"
==> default: definition "2.2.1"
==> default: user "vagrant"
==> default: rbenv_action "install"
==> default: end
==> default:
==> default: Platform:
==> default: ---------
==> default: x86_64-linux
==> default:
==> default:
==> default: [2016-07-12T03:17:44+00:00] INFO: Running queued delayed notifications before re-raising exception
==> default:
==> default: Running handlers:
==> default: [2016-07-12T03:17:44+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default: [2016-07-12T03:17:44+00:00] ERROR: Exception handlers complete
==> default: Chef Client failed. 3 resources updated in 27 minutes 25 seconds
==> default: [2016-07-12T03:17:44+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2016-07-12T03:17:44+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> default: [2016-07-12T03:17:44+00:00] ERROR: ruby_rbenv_ruby[2.2.1 (vagrant)] (vagrant) (ruby_rbenv::user line 47) had an error: Mixlib::ShellOut::ShellCommandFailed: ruby_rbenv_script[rbenv install 2.2.1 (vagrant)] (/var/chef/cache/cookbooks/ruby_rbenv/providers/ruby.rb line 72) had an error: Mixlib::ShellOut::ShellCommandFailed: script[rbenv install 2.2.1 (vagrant)] (/var/chef/cache/cookbooks/ruby_rbenv/providers/script.rb line 40) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of "bash" "/tmp/chef-script20160712-29543-1b85p2w" ----
==> default: STDOUT:
==> default: STDERR: Downloading ruby-2.2.1.tar.bz2...
==> default: -> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.1.tar.bz2
==> default: Installing ruby-2.2.1...
==> default:
==> default: BUILD FAILED (Ubuntu 14.04 using ruby-build 20160602)
==> default:
==> default: Inspect or clean up the working tree at /tmp/ruby-build.20160712025313.30196
==> default: Results logged to /tmp/ruby-build.20160712025313.30196.log
==> default:
==> default: Last 10 log lines:
==> default: make[3]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1/ext/fiddle/libffi-3.2.1'
==> default: linking shared-object fiddle.so
==> default: /usr/bin/ld: ./libffi-3.2.1/.libs/libffi.a(raw_api.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
==> default: ./libffi-3.2.1/.libs/libffi.a: error adding symbols: Bad value
==> default: collect2: error: ld returned 1 exit status
==> default: make[2]: *** [../../.ext/x86_64-linux/fiddle.so] Error 1
==> default: make[2]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1/ext/fiddle'
==> default: make[1]: *** [ext/fiddle/all] Error 2
==> default: make[1]: Leaving directory `/tmp/ruby-build.20160712025313.30196/ruby-2.2.1'
==> default: make: *** [build-ext] Error 2
==> default: ---- End output of "bash" "/tmp/chef-script20160712-29543-1b85p2w" ----
==> default: Ran "bash" "/tmp/chef-script20160712-29543-1b85p2w" returned 1
==> default: [2016-07-12T03:17:44+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
我尝试使用不同版本的rbenv cookbook,但似乎错误是相同的。以前有人遇到过这个错误吗?
答案 0 :(得分:0)
好的,经过一番挖掘后,我在官方ruby-build github page
上找到了这个信息因为我想使用配置并且不希望用户自己安装任何东西,所以我在Berksfile中添加了这本食谱:
cookbook 'libffi-dev', git: 'https://github.com/zchee/libffi-dev-cookbook'
abd到Vagrantfile这一行:
chef.add_recipe "libffi-dev"
紧跟apt。
如果有人想玩它,整个项目是here。