Error deploying to rbenv with Capistrano - ruby-on-rails

I'm new to Capistrano and having trouble debugging an error. Searching suggests this error could be an environment issue of picking up the wrong version of ruby (it's almost certainly not the referenced file as it works fine in test). Using a Capistrano task to dump the ruby version everything looks fine. Running the commands directly on the server works fine, too. I'm using rbenv on the server.
The error:
* executing `deploy:assets:precompile'
* executing "cd /home/deployer/apps/happenate/releases/20120424002545 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["happenate.com"]
[happenate.com] executing command
** [out :: happenate.com] rake aborted!
** [out :: happenate.com] /home/deployer/apps/happenate/releases/20120424002545/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end
** [out :: happenate.com] ...sion_store :cookie_store, key: '_happenate_session'
** [out :: happenate.com] ^

Definitely some sort of ruby environment issue. After cleaning everything up with a proper rbenv environment, the error is gone.

Related

Error when trying to deploy: The bundle currently has capybara locked at 2.2.1

I have a Ruby on Rails web application that I am trying to deploy.
When I try to deploy it, it gets a little ways, and then stops with the following error:
** [out :: rails-rn-dev.sandia.gov] You have requested:
** [out :: rails-rn-dev.sandia.gov] capybara = 2.1.0
** [out :: rails-rn-dev.sandia.gov]
** [out :: rails-rn-dev.sandia.gov] The bundle currently has capybara locked at 2.2.1.
I can't figure out how this is happening. I know that both my Gemfile and my Gemfile.lock files specify capybara version 2.1.0 be used.
So, why is the bundle locking capybara at 2.2.1?
Thanks in advance,
Tim

deploying rails app on ubuntu ec2 with capistrano

Several people have asked fairly similar questions to this, so I'm sorry to repeat 'old questions' but I'm completely stuck atm. I'll try to make it as clear as possible what the problem is:
I have a rails app that works locally.
I am using capistrano to try to deploy it on an ubuntu EC2 instance.
After wading through previous problems, I'm coming up against this when running the
'cap deploy' command
(I removed the ec2 server name):
executing "cd -- /u/apps/tweet_app/releases/20130628110910 && bundle exec rake
RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["ec2 server name"]
[ec2 server name] executing command
[out :: ec2 server name] rake aborted!
[out :: ec2 server name]
/u/apps/twitter_app/releases/20130628110910/config/routes.rb:8: syntax error, unexpected ':', expecting kEND
** [out :: ec2 server name] resources :sessions, only: [:new, :create, :destroy]
** [out :: ec2 server name] ^
** [out :: ec2 server name]
/u/apps/tweet_app/releases/20130628110910/config/routes.rb:9: syntax error, unexpected ':', expecting kEND
** [out :: ec2 server name] resources :annotations, only: [:create]
** [out :: ec2 server name] ^
** [ec2 server name]
etc...
Previously, I had an error in my config/initializers/session_store.rb which related to an issue between differences in ruby 1.8.7 and 1.9.2. I was able to resolve it by changing the syntax for hashes. To get to the root of the problem I tried to install ruby 1.9.2 (I also tried 1.9.3) on the ubuntu instance. 1.9.2 is apparently running -
ubuntu#ip-address:~$ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
But the error still doesn't seem to resolve. It feels like it is still trying to use 1.8.7, which would account for the syntax errors. Other things I have tried include
1. Using rvm to install ruby 1.9.2 on ubuntu (after getting nowhere with a standard install)
2. Using a .rvmrc file to specify that 1.9.2 should be used with the app
Any ideas/suggestions?

deploy:assets:precompile Issue

I am trying to deploy a rails application to the rackspace server via capistrano. I have deployed many Rails application to Rackspace and Linode server and never encountered such weird issue. The capistrano is not deploying the application and below is the log :
executing `deploy:assets:precompile'
* executing "cd /home/deployer/apps/latty39/releases/20121023165957 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["50.56.183.16"]
[50.56.183.16] executing command
** [out :: 50.56.183.16] rake aborted!
** [out :: 50.56.183.16] cannot load such file -- Date
** [out :: 50.56.183.16]
** [out :: 50.56.183.16] (See full trace by running task with --trace)
command finished in 7454ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/deployer/apps/latty39/releases/20121023165957; true"
servers: ["50.56.183.16"]
[50.56.183.16] executing command
command finished in 2001ms
failed: "sh -c 'cd /home/deployer/apps/latty39/releases/20121023165957 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on 50.56.183.16
I have no idea why this is failing. I have almost spent 3 hours on this thing and no success so far. Have search stackoverflow and other resources but no help.
Any help to resolve the issue will be highly appreciated
Thanks
I figured it out myself. I was having a custom rake task which was requiring ruby Date Class like:
require 'Date'
Removed it and all fixed. But I do not need to figure out why requiring the date class in production throws error.

How do I fix a bad Capistrano deployment?

Made a large update last night and my site is currently down. I used cap deploy:rollback with no luck. The error logs aren't telling me much. The last error I saw when trying to deploy was:
** [out :: website.com] You are trying to install in deployment mode after changing
** [out :: website.com] your Gemfile. Run `bundle install` elsewhere and add the
** [out :: website.com] updated Gemfile.lock to version control.
** [out :: website.com]
** [out :: website.com] You have deleted from the Gemfile:
** [out :: website.com] * asset_sync
command finished in 934ms
My cap tail just says the following with no errors:
Migrating to AddSessionsTable (20120722094547)
Migrating to AddSlugToUserProjects (20120723204816)
Migrating to AddSlugIndexToUserProjects (20120723205558)
Migrating to CreateFriendlyIdSlugs (20120723210904)
Migrating to AddNameToUsers (20120723221700)
Migrating to AddSlugToUsers (20120723222456)
Migrating to CreateComments (20120724203252)
Any help?
Run bundle install on your development server, then cap deploy. Another possible solution: add asset_sync back to your Gemfile.
As last resort, you can run cap -d deploy. It will run deployment step-by-step, asking you for continue on each step. Login to production server in separate shell and do some adjustments between steps manually.
It looks like the Gemfile change didn't go well. How it was fixed:
logged into server, there were 6 ruby processes that were taking all available things. This is almost certainly the unicorn processes trying to start and couldn't… killall -9 ruby
cd into the app's current directory
RAILS_ENV=production bundle exec rake assets:precompile
service unicorn_whimseybox start
It looks like (in the unicorn.log), the error was:
E, [2012-07-26T17:27:10.552912 #24818] ERROR -- : uninitialized constant AssetSync (NameError)
I had the same error after converting some Gemfile source lines into blocks.
The error was due an old Bundler version on production (1.7.3) vs 1.8.3 on development.

Could not find treetop-1.4.9 in any of the sources - cap deploy:migrate

I am running into an issue when trying to run migrations from capistrano (cap deploy:migrate).
latest => /var/www/site/releases/20110108002015
* executing "cd /var/www/site/releases/20110108002015; rake RAILS_ENV=production db:migrate"
servers: ["www.site.com"]
[www.site.com] executing command
** [out :: www.site.com] (in /var/www/site/releases/20110108002015)
** [out :: www.site.com] Could not find treetop-1.4.9 in any of the sources
** [out :: www.site.com] Try running `bundle install`.
command finished
failed: "sh -c 'cd /var/www/site/releases/20110108002015; rake RAILS_ENV=production db:migrate'" on www.site.com
The facts;
Rails 3.0.0
Ruby 1.9.2 via rvm
The treetop gem is installed, and if I ssh into the remote server and run the command that capistrano is attempting manually, it works without issue.
Anyone else run into this or a similar issue?
When you ssh onto the server and run the command, is it using the same user capistrano is deploying as? Often issues like this are due to the deploy users path not including the same folders as your path might.
Try using cap shell to run the command, then you can test it under the same conditions cap is under.

Resources