cap deploy:migrations fails with Could not locate Gemfile - ruby-on-rails-3

I'm working on my first rails deployment and having a problem I can't figure out.
mac osx 10.8.2
ruby 1.8.7
Rails 3.2.6
rvm 1.17.2
I've been following this tutorial http://brandnewrails.wordpress.com/ and got stuck on 7c.
I set it all up in RVM, got git running on the server, ran bundle install in the app, and wrote the Capistrano recipe in my_app/config/deploy.rb
Then I ran:
$ capify . no problem
$ cap deploy:setup no errors
$ cap deploy:check returned You appear to have all necessary dependencies installed
$ cap deploy:migrations is where the problem happens. After successfully running a bunch of the commands, capistrano fails. See below:
2012-12-10 00:43:56 executing `bundle_install'
* executing "cd /home/{servername}/party/releases/20121209134354 && bundle install --path vendor/bundle"
servers: ["{servername}"]
[{servername}] executing command
** [out :: {servername}] Could not locate Gemfile
command finished in 694ms
failed: "sh -c 'cd /home/alexchee/party/releases/20121209134354 && bundle install --path vendor/bundle'" on {servername}
Does anyone know what to do? When I check the app directory, the Gemfile is there. Any ideas or further questions?

The inability of capistrano to locate a Gemfile in this case seems to be a symptom of not having initiated git in the app locally, that is on my own computer.
My hunch is that since Gemfile is the first file in the list above, that is why it created an error first. If the program had continued, it would have probably had other errors as well.
Even if git is running on the server and the app is bundled up correctly, you must also initiate git locally and direct it to the appropriate files on your server in order for the deploy to work.
Great instructions are listed here: http://brandnewrails.wordpress.com/2012/10/14/lesson-7b/

Related

Changing Ruby and Rails version with capistrano and rvm

What are the correct steps for changing the configuration of my project when change the ruby and rails version, using rmv.
For example, I have to change in deploy.rb set :rvm_ruby_version, '2.4.0#5.1', but what else?
I can't get Capistrano use the correct rvm gemset, and allways tries to bundle install with the old rvm gemset
Do I have to change something in the production server? I think so, but in some order, before deploy and then after deploy some other changes...¿?
I have tried capistrano-rvm , rvm-capistrano, and finally rvm1-capistrano3
When I run cap production depoly, I get these errors, all arround "Could not determine which Ruby to use"
DEBUG [e2eccae9] Running /home/rails/www/digitalshelving/rvm1scripts/rvm-auto.sh . bundle check --path /home/rails/www/digitalshelving/shared/bundle as rails#46.101.100.14
DEBUG [e2eccae9] Command: cd /home/rails/www/digitalshelving/releases/20180303130204 && /home/rails/www/digitalshelving/rvm1scripts/rvm-auto.sh . bundle check --path /home/rails/www/digitalshelving/shared/bundle
DEBUG [e2eccae9] Could not determine which Ruby to use; . should contain .rvmrc or .versions.conf or .ruby-version or .rbfu-version or .rbenv-version, or an appropriate line in Gemfile.
DEBUG [e2eccae9] Can not find ruby for '.'.
DEBUG [e2eccae9] Finished in 0.684 seconds with exit status 103 (failed).
INFO [c22dc933] Running /home/rails/www/digitalshelving/rvm1scripts/rvm-auto.sh . bundle install --path /home/rails/www/digitalshelving/shared/bundle --without development test --deployment --quiet as rails#46.101.100.14
DEBUG [c22dc933] Command: cd /home/rails/www/digitalshelving/releases/20180303130204 && /home/rails/www/digitalshelving/rvm1scripts/rvm-auto.sh . bundle install --path /home/rails/www/digitalshelving/shared/bundle --without development test --deployment --quiet
DEBUG [c22dc933] Could not determine which Ruby to use; . should contain .rvmrc or .versions.conf or .ruby-version or .rbfu-version or .rbenv-version, or an appropriate line in Gemfile.
DEBUG [c22dc933] Can not find ruby for '.'.
Thanks
In Rails.root create file with name .ruby-version and following content:
2.3.3
or whatever version you want. When you or capistrano cd to root folder rvm will change ruby version according to file's content

Capistrano & jruby & rvm - Bundler::GemNotFound: Could not find rake-0.9.2.2 in any of the sources

I encountered Bundler::GemNotFound: Could not find rake-0.9.2.2 in any of the sources during deploying my application using capistrano, and when processing deploy:assets:precompile.
The command is:
cd /opt/app/deploy/entercamp/releases/20120627132117 && /usr/local/rvm/rubies/jruby-1.6.7/bin/jruby --1.9 -S bundle exec rake RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile
I tried the command manually on the server and it works quite ok. And I could see that rake-0.9.2.2 is installed in the result output of bundle:install in the deploy process.
Where could be the problem?
Detailed information is in: https://gist.github.com/3005237
This just got fixed with help of Michal from rvm-capistrano project.
It raises this error is because jruby is install with version 1.8 by default and it tries to switch to 1.9 when deploying and that causes the problem.
The solution is to install jruby with version 1.9 by default: rvm install jruby-1.6.7.2 --1.9 and then it works.

git://github.com/ryanb/nested_form.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)

I have deployed my application on linux server with passenger and apache, I have done bundle install run successfully still i get
( git://github.com/ryanb/nested_form.git (at master) is not checked out. Please run bundle install (Bundler::GitError) ) error while i try to run my application
FYI, i am using rails 3.2.3 and ruby 1.9.3
This works fine on my development machine
Any Idea ?
I have currently solved the issue by running below
bundle pack
bundle install --path vendor/cache
This solves my problem, but it stores whole gems in the vendor directory
But still if anybody have better solution then please let me know
I had the same problem, I always installed my gems as system-wide gems (including the ones from github).
$ sudo bundle install
When I ran rails, I got the same error:
$ rails s
http://github.com/Sija/garb.git (at master) is not checked out. Please run `bundle install`
So when I ran:
$ bundle install
This installed the gems from github locally, but otherwise used all the other system-wide gems.
Then when I ran rails again, it worked.
Are you running bundle install as root? If yes, try running bundle install without "sudo", anyway this seems to be a permissions problem (as Google suggests [google => (at master) is not checked out. Please run bundle install (Bundler::GitError)])1

Capistrano + RVM rvm_install_ruby with Rubinius

I am trying to fully automate the setup of my deployment host, and so avoiding manual install of Ruby.
I am using capistrano-rvm as it promises to do the job, but I have a problem when RVM compiles Rubinius:
** [out] rbx-2.0.0pre - #configuring
** [out] rbx-2.0.0pre - #compiling
*** [err] Error running '/home/app/.rvm/wrappers/ruby-1.8.7-p358/rake install', please read /home/app/.rvm/log/rbx-2.0.0pre/rake.log
The content of /home/app/.rvm/log/rbx-2.0.0pre/rake.log is:
ERROR: Gem rake is not installed, run `gem install rake` first.
How could I? That should have been done by RVM, no?
Does anyone already met & get out of this issue?
EDIT
I forgot to mention that RVM did load & compile 1.8.7 before rbx, seems like a dependence for build. Maybe RVM is running in a gem set which is badly initialized?
I thought the 2.0.0pre was removed from rbx already, it looks like you have older RVM installation, make sure you update RVM:
curl -L get.rvm.io | bash -s stable --auto
rvm reload
This will run the installer which also makes update.
To make sure everything works properly use rbx-2.0.testing which is supposed to work version of rbx.

RVM error with deploying Rails app via Capistrano

History:
Read into Deploying Rails3 app to a
Mediatemple DV server.
Installed RVM on the server, ruby, and essential gems.
Site works fine if I FTP it up.
All good.
I then decided to do a proper deployment and setup for GIT/cap deploy as per "Agile Web Development with Rails".
Attempted deploy with cap, but had errors with gems not available to the production site.
Read around and realised I should probably go for a system wide RVM install.
Removed all gems and RVM.
Installed RVM system wide.
Error on cap deploy "bash: /home/foo/.rvm/bin/rvm-shell: No such file or directory", which makes sense - there is no .rvm/ in the home directory.
Thinking something was hanging over from initially installing RVM to use as a user, I removed the user, deleting the home directory, and recreated the user with permissions.
Same error on cap deploy "bash: /home/foo/.rvm/bin/rvm-shell: No such file or directory"
The situation now is:
For foo, .bashrc contains the last line:
[[ -s '/usr/local/lib/rvm' ]] && source '/usr/local/lib/rvm'
When I issue:
type rvm | head -1
the response is "rvm is a function".
/etc/rvmrc contains
if [[ ! -s "$HOME/.rvm/scripts/rvm" ]]; then
umask g+w
export rvm_selfcontained=0
export rvm_prefix="/usr/local/"
fi
Running out of ideas here, and hoping for some suggestions.
Next time try to add this in your capistrano:
set :rvm_type, :system
It seems like rvm-shell is not in your rvm install directory. Run this command
rvm get head
Then you'll get it right in your rvm bin directory.
I just wanted to add to #imonyse's comment.
the head branch of rvm might be a tad too unstable for some deploys. I know our deprecated SLES boxes have a tendency to choke on it. It might be advisable to get the most recent stable version.
rvm get stable
Also don't do this on a really old server running production code as it may have undesired consequences.