How to add bundler to gemset with rvm (single user)? - ruby-on-rails

There is error in Capistrano rails 3.1.3 deployment saying:
[176.195.225.93] executing command
** [out :: 176.195.225.93] ←[31mERROR: Gem bundler is not installed, run `gem install bundler` first.←[m←(B
However gem list shows bundler 1.0.22. Our server is running rvm. It seems that the bundler was not added to the ruby gemset. Is there a way to add bundler to ruby gemset so the rvm will find bundler?
Thanks so much!

I suspect your path is not getting set, meaning that bundle cannot be found. You should be able to do something like this...
set :default_environment, {
'PATH' => "/usr/local/bin:/bin:/usr/bin:/bin:/<ruby-dir>/bin",
'GEM_HOME' => '<ruby-dir>/lib/ruby/gems/1.8',
'GEM_PATH' => '<ruby-dir>lib/ruby/gems/1.8',
'BUNDLE_PATH' => '<ruby-dir>/lib/ruby/gems/1.8/gems'
}
as per this Stack Overflow answer
Alternatively, it is possible to configure your server to execute a profile when executing remote commands via ssh as per this answer

Related

Rake, bundle, rails command not found on rvm

I just installed rvm + rails 3+ on centos 6.0 at Rackspace cloud server. Everything works fine, but sometimes when i ssh to server i can't use rake, bundle or any other rails related commands it always shows me errors like:
bash: rake: command not found
when i try to run bundle install it shows me this error:
ERROR: Gem bundler is not installed, run `gem install bundler` first.
but i do have it installed for sure and it worked before.I can use rvm rake db:migrate - but it used to without rvm prefix...Please help i dont know why is that happening - maybe something wrong with bash profile...
have you used a ruby ?
rvm use 1.9.3
this will select properly environment and make all commands working properly.
to make this setting permanent for new sessions also use:
rvm use 1.9.3 --default

Rails 3.2.1 - Could not find rake-0.9.2.2 in any of the sources

I'm brand new to rails and am trying to dive in to my first project on my Mac, but am running in to an issue when I run Rake -T inside my project's root dir:
Could not find rake-0.9.2.2 in any of the sources
Run 'bundle install' to install missing gems.
After I run 'bundle install' I get:
Your bundle is complete! It was installed into ./rake
But I still get the same error when I call Rake again. My gemfile lists rake as:
gem 'rake', '0.9.2.2'
If I run 'bundle list' I can see:
* rake (0.9.2.2)
I've looked at other posts on stackoverflow and google, but none of the solutions have worked for me. I'd also really appreciate any background on what's going on here, for instance, should rake be installed in to the project directory like this?
I'm not sure what else I should include to help troubleshoot?
Thank you!
Go to https://rvm.io
instal rvm, rvm install 1.9.3, rvm use 1.9.3 --default
then you can manage your gems through rvm
It is the best solution to manage your gems.
please check if rvm is configured correctly - read about .rvmrc and setup_and_load_paths.rb http://blog.ninjahideout.com/posts/the-path-to-better-rvm-and-passenger-integration, also check lines at your nginx(i suppose you use it, cause, i just had exactly same problem) configs passenger_root and passenger_ruby (this one should include smth like output of which ruby + #your_gem_set)
good luck
Have you tried Gem install rake ?
Bundle will not install anything to your path I do not think but you may also get it working by bundle exec rake. If that doesn't work, try bundle exec rake -v0.9.2.2.2
I don't fully understand how bundle works either as running Rails commands on my computer runs Rails 3.2.2 while the bundle runs Rails 3.1.1

"Gem bundler is not installed" in Capistrano deployment - Error message UPDATED

Here is the error caused by rake in Capistrano deployment. The error also causes the rollback and failure of the rails 3.1.3 deployment (with rvm for single user installed).
** [out :: 76.195.225.93] ←[31mERROR: Gem bundler is not installed, run `gem in
command finished in 54ms
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/byop/releases/20120302230229; true"
gem list shows bundler 1.0.22. Also bundler was added to default.gems and global.gems under .rvm/gemset/. What could cause the error? Thanks so much.
You need to install bundler in the server gemset.
Set the default environment in deployment recipe:
set :default_environment, {
'RUBY_VERSION' => 'ruby-1.9.2-p320',
'LANG' => 'en_US.UTF-8',
'GEM_HOME' => '/usr/local/rvm/gems/ruby-1.9.2-p320',
'GEM_PATH' => '/usr/local/rvm/gems/ruby-1.9.2-p320:/usr/local/rvm/gems/ruby-1.9.2-p320#global',
'BUNDLE_PATH' => '/usr/local/rvm/gems/ruby-1.9.2-p320:/usr/local/rvm/gems/ruby-1.9.2-p320#global'
}
You can have just bundle path in your case!
I had the same problem. Check and see if there is a file called rvm.sh in your /etc/profile.d directory. If so, then you installed rvm in multiuser mode. I fixed it on my server (Ubuntu 12.04) by adding source /etc/profile to my .bashrc file in my home directory on that machine.
If you have bundler installed in an RVM gemset on the remote server, be sure to:
require 'rvm/capistrano'
if your config/deploy.rb
If you get an error for that require, you might need to fix your rvm path as well in deploy.rb using:
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
I prefer that to just installing gems as system gems. RVM is your friend.

rails, new ubuntu install, capistrano, rvm issues

I'm a new user to Capistrano and using it to deploy a rails 3.1 app. There seems to be an issue with gem installation on the remote server.
I have the following questions:
It looks like cap runs bundle install on the gemfile? Are there any dependencies for this to work successfully? I have rvm and bundler on my server. Does it need rails installed already?
I have manually set the bundle_cmd in my deploy.rb like this:
set :bundle_cmd, '/usr/local/rvm/gems/ruby-1.9.2-p290/bin/bundle'
Should this be correct?
Is there a way to have confirmation on a cap deploy that ALL the required gems are there? Or what is the best way to debug a failed bundle install on the remote server? Can you call something like cap gem-list; was hoping something like cap invoke=gem list would do it but doesn't look like it.
Edit #1
I'm getting the following error:
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'default' -c 'cd /data/sites/myserver/apps/myapp/releases/20111204181321 && bundle install --gemfile /data/sites/myserver/apps/myapp/releases/20111204181321/Gemfile --path /data/sites/myserver/apps/myapp/shared/bundle --deployment --quiet --without development test'" on 173.230.xxx.xxx
If I go into a previous release, and run bundle install, it says that everything installed correctly which it didn't.
It says:
Your bundle is complete! It was installed into /data/sites/myserver/apps/myapp/shared/bundle
but if I go in there, there is nothing other than the ruby 1.9.1 which to the best of my knowledge I didn't install (using ruby 1.9.2-p290)
Is there a way in capistrono to specify it not to delete the deployed release so that I can debug that explicitly? Shoud I need to hardcode the path to my bundler in my deploy.rb script?
thx again
EDIT 2
If I go into the current release at:
/data/sites/myserver/apps/myapp/current
and run:
$ which bundle
/usr/local/rvm/gems/ruby-1.9.2-p290/bin//bundle
I get:
$ bundle install
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [minitest-1.6.0,rake-0.8.7, rdoc-2.5.8] (Gem::LoadError)
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
from /usr/local/rvm/gems/ruby-1.9.2-p290/bin/bundle:18:in `<main>'
You dont need to have rails installed already, but I do think that you need to have bundler installed. gem install bundler
You can use RVM and bundler integration from capistrano. In that case you dont have to set the path to bundler.
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
require "bundler/capistrano" # Load RVM's capistrano plugin.
set :rvm_type, :system
set :rvm_ruby_string, '1.9.2#gemset_name'
You can use 'cap shell' to run commands through Capistrano on the server. You could use this to check the installation of all your gems. Use cap -T to see all possibilities.
On a side note, do you really need rvm gemsets for your app? I use RVM to install and update my rubies on my production server, but I let Bundler handle the separation of my gems. Since the default bundler settings in production put all your gems in vendor/bundle, this already separates your gems from each other. This works great with Capistrano too.
See a similar question and answer here. Some more information a capistrano/bundler/rvm/passenger setup can be find in this tutorial.

Do I need to install Bundler manually on my server before being able to deploy with Capistrano?

The title pretty much says it all.
I've just set up my web server with Ruby 1.9.2. It is a clean install -- no gems have been installed yet. Additionally, I've just configured Capistrano for my Rails application.
When I run cap deploy, it fails with the following error message:
*** [err :: bogusip.com] bash: bundle: command not found
Given that all I've done is install Ruby 1.9.2 onto my server, Bundler does not exist at this point. Is Capistrano supposed to install the Bundler gem for me or am I supposed to do that myself?
Yes.
Bundler is not included with ruby by default, it is included by rails. This will be why you have never installed it manually.

Resources