Reputation: 4809
This rails app's puma/runit service has been working up until I tried to deploy the Sidekiq 3.5.3 gem with my app via chef
In my recipe I've installed 2.0.0p576 via ruby_build recipe
which ruby #gives me /usr/bin/ruby
/usr/bin/ruby -v #return 2.0.0p576
templates/default/sv-myapp-run.erb
echo "$(ruby -e 'print RUBY_VERSION')" >> check_ruby.txt #returns 2.0.0
exec chpst -u root:root bundle exec puma --config config/puma.rb
Inside the log of the runit service I get this message below
2015-11-04_06:23:50.99541 /var/lib/gems/1.9.1/gems/sidekiq-3.5.3/lib/sidekiq.rb:3:in `<top (required)>': Sidekiq 3.5.3 does not support Ruby 1.9. (RuntimeError)
As this doesn't occur locally - I'm led to believe it has something to do with Chef and how I'm setting up Ruby on the host
I've also tried installing rvm , purging system ruby and have confirmed the default (global and local) as > 2.0 - none of this has made a difference yet.
I noticed in /usr/local/bin/puma the declaration is
#!/usr/bin/env ruby1.9.1
I edited this to just be ruby - then restarted the service but no change. Is there a way I can force Puma to run under ruby +>2.0 ?
ruby_build_ruby '2.0.0-p576'
link "/usr/bin/ruby" do
to "/usr/local/ruby/2.0.0-p576/bin/ruby"
end
gem_package 'bundler' do
options '--no-ri --no-rdoc'
end
include_recipe "runit"
deploy_revision("/opt/deploy") do
revision "develop"
repository "removed"
user "root"
action :deploy
shallow_clone true
keep_releases 3
rollback_on_error true # remove release if callbacks failed
migrate true
migration_command "rake db:migrate"
before_migrate do
execute "bundle install" do
command "bundle install"
cwd "#{release_path}"
user "root"
end
end
#restart_command "rails server -b 0.0.0.0"
# disable default behavior
symlink_before_migrate.clear
create_dirs_before_symlink.clear
purge_before_symlink.clear
symlinks.clear
end
Ubuntu 14.04 , Bundler 1.10.6
Thanks!
Upvotes: 1
Views: 248
Reputation: 2825
I don't think the ruby you've installed is the default for the system (or at least, not when Chef executes bundler). I'm basing that on /var/lib/gems/1.9.1/gems/sidekiq-3.5.3
which seems to indicate you've installed the gem under 1.9.1 as well.
I don't know if you have a preference for rvm or rbenv, but each has a popular community cookbook that can set the default system ruby to the one you want to use, or even just for a particular user (since you're using root, I'd say just set the system ruby as the one you want).
If you were using the rbenv cookbook, it would look like this:
include_recipe 'ruby_build'
include_recipe 'ruby_rbenv'
rbenv_global '2.0.0p576'
You would also be able to omit these resources you were using before:
ruby_build_ruby '2.0.0-p576'
link "/usr/bin/ruby" do
to "/usr/local/ruby/2.0.0-p576/bin/ruby"
end
Also, I'd recommend running as another user than root, so you can only break that user's default ruby instead of the entire system's ruby. Cheers!
Upvotes: 2