1
我是Chef
的新手,我試了好幾個小時,弄清楚如何安裝紅寶石並安裝寶石bundler
,我也是ruby
的新手。如何通過Chef安裝ruby和bundler?
我想克隆我的倉庫,並執行這樣的:
$ bundle install
$ bundle exec rackup
通過Shell腳本
簡單,但似乎,現在,大廚非常困難。 雖然,我創造了這個偏方:
metadata.rb
depends 'apt'
depends 'git'
# depends 'rbenv' -> # very old version
depends 'ruby_rbenv' # -> new version
depends 'application'
depends 'application_ruby'
depends 'build-essential'
metadata.rb
include_recipe 'git'
include_recipe 'ruby_rbenv::system'
include_recipe 'build-essential'
rbenv_global 'system'
group 'sinatra_app'
user 'sinatra_app' do
group 'sinatra_app'
system true
shell '/bin/bash'
end
# DON'T WORK
# rbenv_gem "bundler" do
# action :install
# end
# DON'T WORK
# rbenv_gem "bundler" do
# ruby_version "2.4.0"
# end
directory '/srv/sinatra-app' do
owner 'sinatra_app'
group 'sinatra_app'
mode '0755'
recursive true
end
application '/srv/sinatra-app' do
# Application resource properties.
owner 'sinatra_app'
group 'sinatra_app'
# Subresources, like normal recipe code.
package 'ruby'
git "/srv/sinatra-app" do
repository "git://github.com/tnh/sinatra-app.git"
reference "master"
action :sync
end
# DON'T WORK
bundle_install do
deployment true
end
end
但我不知道是否被正確安裝紅寶石。同時,也是bundle_install
似乎沒有正常工作..
這是我的錯誤輸出:
node1-ubuntu ================================================================================
node1-ubuntu Error executing action `install` on resource 'application_bundle_install[/srv/sinatra-app]'
node1-ubuntu ================================================================================
node1-ubuntu
node1-ubuntu Mixlib::ShellOut::ShellCommandFailed
node1-ubuntu ------------------------------------
node1-ubuntu Expected process to exit with [0], but received '1'
node1-ubuntu ---- Begin output of ["/usr/bin/ruby", "/usr/local/bin/bundle", "install", "--deployment"] ----
node1-ubuntu STDOUT:
node1-ubuntu STDERR: /usr/bin/ruby: No such file or directory -- /usr/local/bin/bundle (LoadError)
node1-ubuntu ---- End output of ["/usr/bin/ruby", "/usr/local/bin/bundle", "install", "--deployment"] ----
node1-ubuntu Ran ["/usr/bin/ruby", "/usr/local/bin/bundle", "install", "--deployment"] returned 1
node1-ubuntu
node1-ubuntu Cookbook Trace:
node1-ubuntu ---------------
node1-ubuntu /var/chef/cache/cookbooks/poise-languages/files/halite_gem/poise_languages/command/mixin.rb:207:in `tap'
node1-ubuntu /var/chef/cache/cookbooks/poise-languages/files/halite_gem/poise_languages/command/mixin.rb:207:in `language_command_shell_out!'
node1-ubuntu /var/chef/cache/cookbooks/poise-languages/files/halite_gem/poise_languages/command/mixin.rb:222:in `block in language_command_mixin'
node1-ubuntu /var/chef/cache/cookbooks/poise-ruby/files/halite_gem/poise_ruby/resources/bundle_install.rb:160:in `run_bundler'
node1-ubuntu /var/chef/cache/cookbooks/poise-ruby/files/halite_gem/poise_ruby/resources/bundle_install.rb:119:in `action_install'
node1-ubuntu
node1-ubuntu Resource Declaration:
node1-ubuntu ---------------------
node1-ubuntu # In /var/chef/cache/cookbooks/sinatra-app/recipes/default.rb
node1-ubuntu
node1-ubuntu 68: bundle_install do
node1-ubuntu 69: deployment true
node1-ubuntu 70: end
node1-ubuntu 71:
node1-ubuntu
node1-ubuntu Compiled Resource:
node1-ubuntu ------------------
node1-ubuntu # Declared in /var/chef/cache/cookbooks/sinatra-app/recipes/default.rb:68:in `block in from_file'
node1-ubuntu
node1-ubuntu application_bundle_install("/srv/sinatra-app") do
node1-ubuntu action [:install]
node1-ubuntu retries 0
node1-ubuntu retry_delay 2
node1-ubuntu default_guard_interpreter :default
node1-ubuntu declared_type :application_bundle_install
node1-ubuntu cookbook_name "sinatra-app"
node1-ubuntu recipe_name "default"
node1-ubuntu parent application[/srv/sinatra-app]
node1-ubuntu deployment true
node1-ubuntu parent_ruby nil
node1-ubuntu gem_binary "/usr/bin/gem"
node1-ubuntu timeout 900
node1-ubuntu path "/srv/sinatra-app"
node1-ubuntu end
node1-ubuntu
node1-ubuntu Platform:
node1-ubuntu ---------
node1-ubuntu x86_64-linux
任何幫助將非常感謝!
另一個需要考慮的選擇是安裝ChefDK軟件包。它包含一個完整的Ruby環境 –