I am trying to deploy a ruby app through chef. I have installed ruby and rubygems through rvm.
When I do a bundle install --deployment manually on the shell I get all the bundles downloaded to vendor/bundle location and everything works fine.
But when I do the same with chef using bash resource I get error messages mentioned below. I feel like some issue with the PATH or environmental variables. Through chef also it downloads all the gems but when I open the shell and check I get errors. Please note - chef recipes executes without any errors.
*bundle exec rake db:create RAILS_ENV=production
(in /home/xyz)
rake aborted!
undefined method `[]' for nil:NilClass
/home/xyz/Rakefile:4:in `require'
(See full trace by running task with --trace)*
# ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
# gem -v
1.8.1
bundle -v
Bundler version 1.0.15
# gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.1
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-1.9.2-p290
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-1.9.2-p290/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/rvm/gems/ruby-1.9.2-p290
- /usr/local/rvm/gems/ruby-1.9.2-p290@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
bash "bundle install" do
user "root"
cwd "/home/xyz/"
code <<-EOH
source /etc/profile.d/rvm.sh
rvm use 1.9.2-p290 --default
/usr/local/rvm/gems/ruby-1.9.2-p290/bin/bundle install --path vendor/bundle
/usr/local/rvm/gems/ruby-1.9.2-p290/bin/bundle exec rake db:create RAILS_ENV=production
EOH
end
This is the first time I am deploying any ruby app, I have googled a lot and tried many solutions but I get more and more errors but no solutions. Any kind of help would be greatly appreciated.
Thanks, Imran