sh: bundle: error - ruby-on-rails-3

I'm really frustrated - issue of capistrano not finding bundle has alot of questions & answers. but they don't seem to work for me... so sad :(
situation is - i'm using host which has system wide rvm installed.
$ bundle -v
Bundler version 1.2.4
$ rvm -v
rvm 1.18.8 (stable) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
$ ruby -v
ruby 1.9.3p385 (2013-02-06 revision 39114) [i686-linux]
and error is it can't execute sh: bundle: http://community.webfaction.com/questions/5186/capistrano-cant-find-bundle
Ive tried setting rvm variables
set :rvm_ruby_string, "1.9.3"
set :rake, "rvm use #{rvm_ruby_string} do bundle exec rake"
set :bundle_cmd, "rvm use #{rvm_ruby_string} do bundle "
Then i tried setting :default_environment like so http://community.webfaction.com/questions/5186/capistrano-cant-find-bundle
Tried setting to combined output of which ruby & ecno $HOME it still doesn't work.
Any ideas? The problem seems quite widespread... but i can't fix it!
UPDATE 1
tried using rvm solution https://rvm.io/integration/capistrano/
set :default_environment, {
'PATH' =>"/home/h41319/data/www/.rvm/gems/ruby-1.9.3-p385#global/bin/bundle::/home/h41319/data/www/.rvm/gems/ruby-1.9.3-p385#global/bin/ruby:PATH",
'RUBY_VERSION' => 'ruby 1.9.3',
'GEM_HOME' => '/home/h41319/data/.rvm/gems/ruby-1.9.3-p385',
'GEM_PATH' =>
'/home/h41319/data/.rvm/gems/ruby-1.9.3-p385#global',
'BUNDLE_PATH' => '/home/h41319/data/www/.rvm/gems/ruby-1.9.3-p385#global/bin/bundle' # If you are using bundler. }
No luck !

Have a look on rvm-capistrano gem, the documentation should be clear about how to use it => https://github.com/wayneeseguin/rvm-capistrano#readme

Related

Passenger module fails to install

On Mac OSX 10.8.4, I'm running:
sudo passenger-install-apache2-module
which suggested:
Your RVM wrapper scripts are too old, or some wrapper scripts are missing. Please update/regenerate them first by running:
rvmsudo rvm get stable && rvm reload && rvmsudo rvm repair all
If that doesn't seem to work, please run:
rvmsudo rvm wrapper [] --no-prefix --all
I did the first bit, re-ran the passenger-install-apache2-module but got the same problem. Then I did the second part. This gave:
awk: nonterminated character class ^[]=
source line number 1
context is
>>> /^[]=/ <<<
sed: 1: "s#^[]=##
": unbalanced brackets ([])
Unknown ruby interpreter string component: '[]'.
Could not load ruby [].
Any suggestions on where I go from here?
just run passenger-install-apache2-module do not prefix it with sudo.
the command will tell you what to do if it has no write access into required locations.
using sudo losses all environment variables - which basically breaks what rvm set up.
if you would really need root privileges you should use rvmsudo which does preserve all required environment variables.

RVM not changing loaded ruby

I have an .rvmrc file:
rvm use 1.9.3-p286#refinery --create
and changing to that folder yields:
Using /Users/neil/.rvm/gems/ruby-1.9.3-p286 with gemset refinery
$ ~/code/visioneng/ master* ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
$ ~/code/visioneng/ master*
However, this clearly isn't what I asked for. What gives?
check if you do not overwrite PATH in any of your shell scripts/functions/aliases

Rails 3 - Whenever gem error: /usr/bin/env: ruby: No such file or directory

When using the 'whenever gem', I get an error in the log:
/usr/bin/env: ruby: No such file or directory
It works when I run the job manually. I've installed everything with RVM.
I've used the which command to find where my Ruby installation is, and I get:
kevin#lovely:/opt/personal$ which ruby
/home/kevin/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
and I've checked my $PATH variable, where it returns:
kevin#lovely:/opt/personal$ echo $PATH
/home/kevin/.rvm/gems/ruby-1.9.2-p290/bin:/home/kevin/.rvm/gems/ruby-1.9.2-p290#global/bin:/home/kevin/.rvm/rubies/ruby-1.9.2-p290/bin:/home/kevin/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
I believe this should be set up right, but I'm probably wrong since it doesn't work. Can anyone point me in the right direction?
If you're interested, this is what my whenever crontab output is:
# Begin Whenever generated tasks for: rss
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /opt/personal && script/rails runner -e development '\''FeedEntry.update_from_feed("http://lovely/blog/feed/")'\'' >> /opt/personal/log/feedzirra.log 2>&1'
You're probably long past this issue but for future reference:
I had a similar problem only I was getting
/usr/bin/env: ruby: No such file or directory
It turned out the first line of the file script\rails was #!/usr/bin/env ruby1.9.1, which tells the system to invoke it with ruby1.9.1 as explained here. But it should have been #!/usr/bin/env ruby1.9.3 since that was the version I had installed.
Hope this helps someone in the future :)
My issue was that ruby is in /usr/local/bin which is not in the path of a headless bash. So I just made my rake task line in schedule.rb:
job_type :rake, "cd :path && PATH=/usr/local/bin:$PATH RAILS_ENV=:environment bundle exec rake :task :output"
I am successfully using whenever with RVM and bundler in production. Here are the relevant pieces of my capistrano setup that may help you:
# rvm and bundler integration
require 'rvm/capistrano'
require 'bundler/capistrano'
# RVM environment
set :rvm_ruby_string, "ruby-1.9.2#mygemset"
# crontab
set :whenever_roles, :cron
set :whenever_command, "bundle exec whenever"
set :whenever_environment, defer { stage }
require 'whenever/capistrano'
The :whenever_environment setting is because I am using a multi-stage deployment setup. You can ignore that or set it to a string that matches your setup if needed.
Most of this information can be found at the whenever github page under the "Capistrano integration" and "RVM Integration" section headers in the README.
I hope that helps.
I solved the problem about the same as Duke. Except I figure out that $PATH variable is not working for me.
sys_path = '/home/[user]/.rbenv/versions/[ruby_version]/bin'
job_type :runner, "cd :path && PATH=#{sys_path} bin/rails runner -e :environment ':task' :output"
job_type :rake, "cd :path && PATH=#{sys_path} :environment_variable=:environment bin/bundle exec rake :task --silent :output"
If none of these worked for you, try:
gem install rails
This did the job for me, hope it helps!

"uninitialized constant Encoding" using rvm, ruby 1.9.2, bundler and passenger

I am at wit's end here and am turning to you all for some help on this f*#$^ encoding issue.
I am running on a private server with root permissions on Dreamhost. Here is a bit about my environment and versions.
$ `which ruby` -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
$ `which bundle` -v
Bundler version 1.0.15
$ `which rails` -v
Rails 3.0.9
Aside from this error, my rails app runs fine without issue. However, when I try to change the encoding a string by using the encode method it:
NoMethodError: undefined method `encode' for "foobar":String
encode should be defined but it is not! Encoding is found if I try in irb:
$ irb
ruby-1.9.2-p180 :001 > Encoding
=> Encoding
ruby-1.9.2-p180 :002 > "foobar".encode('utf-8')
=> "foobar"
But if I try using the rails console through bundle exec, Encoding is not found:
$ bundle exec rails c staging
Loading staging environment (Rails 3.0.9)
ruby-1.9.2-p180 :001 > Encoding
NameError: uninitialized constant Encoding
from /[REDACTED]/shared/bundle/ruby/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
from (irb):1
ruby-1.9.2-p180 :002 > "foobar".encode('utf-8')
NoMethodError: undefined method `encode' for "foobar":String
Obviously the setup is not loading something correctly but I am not sure where to look to figure it out. What am I missing here?
UPDATE 6/19/2011
As Ryan Bigg pointed out, it is curious that the directory path for the gems is 1.8. However, running bundle exec shows that bundler is using the correct ruby and rails versions:
$ bundle exec which ruby
/path/to/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
$ bundle exec `which ruby` -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
$ bundle exec which rails
/path/to/shared/bundle/ruby/1.8/bin/rails
$ bundle exec `which rails` -v
Rails 3.0.9
Clearly something is wonky here… I just don't know what.
UPDATE 6/26/2011
Seamus asked for the $LOAD_PATH…
UPDATE 6/26/2011 (later)
Seamus asked for the Gemfile.lock and the pp ENV… In the ENV output, I found that the GEM_PATH was not correct. In my staging.rb environment file, I have:
GEM_HOME = "/home/[REDACTED]/.rvm/gems/ruby-1.9.2-p180#[REDACTED]"
GEM_PATH = "/home/[REDACTED]/.rvm/gems/ruby-1.9.2-p180#[REDACTED]:/home/[REDACTED]/.rvm/gems/ruby-1.9.2-p180#global"
…which is obviously not being honored. Nowhere else in my code is there a mention of GEM_HOME or GEM_PATH
UPDATE 6/27/2011
Seamus asked for the .bundle/config contents…
UPDATED same idea (that GEM_HOME is messed up), but more suggestions
Your GEM_HOME is messed up, possibly because your PATH is messed up. You could try setting the following environment variable in your shell
$ export PATH=[your current path but with rvm's ruby 1.9 at the front]
Then run
$ bundle install
If that doesn't work, try also setting this in your shell
$ export GEM_HOME=[your ruby 1.9 gem home]
and then re-run
$ bundle install
New ideas from this answer: Using RVM, bundler does not install in proper gemset when gems are installed in a different ruby version

RVM & Unicorn deploy

My RVM is installed as root.
When I'm trying to start unicorn socket, it prints
user#9001-3:~$ /etc/init.d/unicorn start
Starting myapp app: /usr/bin/env: ruby: No such file or directory
unicorn.
But if I type
user#9001-3:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
/usr/local/rvm/gems/ruby-1.9.2-p180/bin/unicorn path exists.
My unicorn config: https://gist.github.com/1010519
/etc/init.d/unicorn doesn't know where to find Ruby because it's managed via RVM. Normally, your .bashrc or similar file is executed and sets up the environment; this doesn't happen in init scripts (or likely anything else executed by root).
The solution is to use wrappers. For example, to create a binary called system_ruby that loads up RVM's 1.9.2p180 environment and then executes ruby, execute the following:
rvm wrapper ruby-1.9.2-p180 system ruby
For more information and more details, check out this answer of mine, which addresses a similar problem.
Symlink also works,
which ruby<your version>
ln-s /ruby/path/ruby<your version> /ruby/path/ruby
Type :
which ruby (show the ruby bin path) then type this : ln -s (change_to_ruby_path) /usr/bin/env/ruby (construct the correct access for your system)
I had the same problem and this for me
rvm --default use <version>