I had a rails app that's was running on heroku, I recently got my VPS and trying to move it to my own server.
So, I deleted my heroku, and added an origin.
I did all the setups for deploy.rb(all looks fine)
but when I run cap deploy:setup, I got:
* 2012-11-24 20:35:21 executing `deploy:setup'
* executing "mkdir -p /var/www/sites/phil88530.com /var/www/sites/phil88530.com/releases /var/www/sites/phil88530.com/shared /var/www/sites/phil88530.com/shared/system /var/www/sites/phil88530.com/shared/log /var/www/sites/phil88530.com/shared/pids"
servers: ["phil88530.com"]
[phil88530.com] executing command
*** [err :: phil88530.com]
*** [err :: phil88530.com] ! Invalid path.
*** [err :: phil88530.com]
*** [err :: phil88530.com] ! Syntax is: git#heroku.com:<app>.git where <app> is your app's name.
command finished in 956ms
I don't want heroku exist anymore, why does it ask for heroku?
And I don't understand the invalid path as well, would be nice if I capistrano can get me more informatinos.
http://phil88530.com/ resolves to heroku... so when capistrano connects to servers: ["phil88530.com"], it's connecting to heroku.
You can either set the server to the IP address of your new VPS, or move the DNS over to the new VPS to correct the problem.
Related
I'm deploying to a VPS using capistrano, based on the guide at RailsCasts.
http://railscasts.com/episodes/335-deploying-to-a-vps?view=asciicast
It's failing on the deploy:cold command, with a conflict with Ruby. I actually can't see what the problem is, as when I shell into the same user the Ruby version looks correct.
$ cap shell
cap> which ruby
[establishing connection(s) to 192.xxx.xxx.xxx]
** [out :: 192.xxx.xxx.xxx] /home/deployer/.rbenv/shims/ruby
cap> ruby -v
** [out :: 192.xxx.xxx.xxx ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
This is the error:
command finished in 655ms
* 2013-07-01 16:40:39 executing `bundle:install'
* executing "cd /home/deployer/rails/assay/releases/20130701144038 && bundle install -- gemfile /home/deployer/rails/assay/releases/20130701144038/Gemfile --path /home/deployer/rails/assay/shared/bundle --deployment --quiet --without development test"
servers: ["192.xxx.xxx.xxx"]
[192.xxx.xxx.xxx] executing command
** [out :: 192.xxx.xxx.xxx] rbenv: version `1.9.3' is not installed
command finished in 662ms
*** [deploy:update_code] rolling back
My question is: how can I debug this? When I read the deploy.rb file I can't see where it even references the Ruby version. Pretty frustrating, I am about ready to ftp the repo up, which is not ideal obviously.
Well I finally got to the bottom of the issue - a mismatch between ruby versions use by Capistrano and what was actually on the server.
To debug Capistrano run it like this:
cap deploy:cold -d
That was you can step through the commands and access the temporary directories on the remote server before they are deleted.
I just had similar issue, the reason was .ruby-version file pointing at 1.9.3 (file was generated by rails-composer), while there was 1.9.3-p392 installed via rbenv on remote machine.
Debug info of capistrano can be shown by tail -f log/capistrano.log.
Occasionally, an error will occur during a Capistrano deployment that doesn't provide enough output to troubleshoot. For example:
* executing "cd /apps/my_app/releases/20121019181838 && bundle exec rake RAILS_ENV=dev RAILS_GROUPS=assets assets:precompile"
servers: ["myserver.com"]
[myserver.com] executing command
*** [err :: myserver.com] rake aborted!
*** [err :: myserver.com] Connection refused - connect(2)
*** [err :: myserver.com]
*** [err :: myserver.com] Tasks: TOP => environment
*** [err :: myserver.com] (See full trace by running task with --trace)
command finished in 2388ms
*** [deploy:update_code] rolling back
* executing "rm -rf /apps/my_app/releases/20121019181838; true"
Something went wrong during the rake task, and it looks like it probably has something to do with the DB. But in order to troubleshoot this, I would need to recreate the conditions of the deploy; alas, the conditions have been rm -rf'ed.
Is there some way to make Capistrano drop to a (Cap or bash) shell here using a before or after hook? Is there an easy way to insert a --trace onto that rake task without overriding Capistrano classes? Other ideas?
I handle situations as such in the following ways:
When I can be fast enough I simply hit CTR+Z (it 'pauses' the cap process) and then I investigate things onsite (over ssh, or the cap console).
I set the debug (cap --debug) flag when running the task - which makes cap prompt me before each remote command execution, so I can investigate the situation before/after every step.
Both ways usually are sufficient for me to handle the most situations quite quickly. Hope they will also help you.
EDIT:
The issue here was that I used RVM on my local machine and rbenv on the server. This is highly not recommended, if you're managing several ruby installation (or upgrading your ruby version but do not want to change the system's) use either RVM or rbenv on all environments!
/EDIT
So I'll start with a bit history:
I'm in the process of upgrading our rails2 website to rails3. Most of the things are working properly by now, except Capistrano's deploy script.
The current setup I have is:
RVM (1.14.1) installed locally
ruby-1.9.3-p194 (set to the project's folder)
Capistrano v2.12.0 (upgraded from 2.6.0, but it doesn't work on 2.6.0 as well) installed as an RVM gem
rvm-capistrano (1.2.2), added to the Gemfile (after doing some reading online and on SO)
rbenv (with ruby 1.9.3p194 used globally) installed on the server
(by now if you see anything that doesn't make sense, please let me know)
Nothing changed in the deploy script, yet when I try to deploy to my testing server (let's call it beta) I get this error:
* executing `deploy:restart'
* executing "cd /home/foo/bar/current && rake RAILS_ENV=beta queue:restart_workers"
servers: ["208.0..."]
[208.0...] executing command
*** [err :: 208.0...] rake aborted!
*** [err :: 208.0...] no such file to load -- bundler/setup
*** [err :: 208.0...] /home/foo/bar/releases/20120630161947/Rakefile:5
*** [err :: 208.0...] (See full trace by running task with --trace)
** [out :: 208.0...] (in /home/foo/bar/releases/20120630161947)
command finished in 1183ms
failed: "sh -c 'cd /home/foo/bar/current && rake RAILS_ENV=beta queue:restart_workers'" on 208.0...
The relevant part on deploy.rb looks like this:
task :restart do
run "cd /home/foo/bar/current && rake RAILS_ENV=#{CAP_ENV} queue:restart_workers"
run "cd /home/foo/bar/current && rake RAILS_ENV=#{CAP_ENV} db:migrate"
run "touch #{deploy_to}/current/tmp/restart.txt"
end
Needless to say, rake RAILS_ENV=beta queue:restart_workers' works perfectly when run manually on the server. Also, the application gets deployed (the code was copied from git, it's just the last part of the deploy fails).
Lastly, the error didn't change since before I installed rvm-capistrano and added to the Gemfile, so I'm not even sure it's related to rvm, I'm just guessing from looking online.
Thanks
In order to work correctly, rbenv must override all the ruby and gem-related executables with the shims it provides.
Usually this is done with a startup script (this is why it works when you login to your server) but Capistrano logs in without shell and thus does not run those scripts.
You must add the following to your deploy.rb :
set :default_environment, {
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}
and do not use anything rvm related on your server, rbenv and rvm really do not like each other
PS : a little more explanation on this topic : http://henriksjokvist.net/archive/2012/2/deploying-with-rbenv-and-capistrano/
I've wasted a few days on this problem and I'm sure it's a simple solution, please help!
When I run $ cap deploy:setup from my user account on my laptop I get the errors I've pasted below. It seems that there's a problem with RVM, but I know that it's installed, and I've pre-installed all the gems my app will need as well. Has anyone else encountered similar errors? Any help would be hugely appreciated!
* executing `deploy:setup'
* executing "mkdir -p /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids && chmod g+w /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids"
servers: ["arbiter.nullpointer.ca"]
[arbiter.nullpointer.ca] executing command
** [out :: arbiter.nullpointer.ca]
** [out :: arbiter.nullpointer.ca] $rvm_path (system_wide) does not exist.
*** [err :: arbiter.nullpointer.ca] /usr/local/rvm/scripts/rvm: line 154: __rvm_teardown: command not found
*** [err :: arbiter.nullpointer.ca] /usr/local/rvm/bin/rvm-shell: line 74: rvm: command not found
*** [err :: arbiter.nullpointer.ca] Error: RVM was unable to use 'default'
command finished
failed: "rvm_path=system_wide /usr/local/rvm/bin/rvm-shell 'default' -c \"mkdir -p /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids && chmod g+w /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids\"" on arbiter.nullpointer.ca
I just ran into this problem though my installation was complaining with:
out :: server]
** [out :: server] $rvm_path (/home/nebula/.rvm/) does not exist.
*** [err :: server] /usr/local/rvm/scripts/rvm: line 185: __rvm_teardown: command not found
*** [err :: server] /usr/local/rvm/bin/rvm: line 52: /home/nebula/.rvm//scripts/rvm: No such file or directory
*** [err :: server] Error sourcing RVM!
*** [err :: server] Error: RVM was unable to use 'ruby-1.9.3-p392'
I am using rvm with a system wide install, (standard install to /usr/local/rvm). Adding the following to my Capfile solved the issue:
set :rvm_type, :system
set :rvm_path, "/usr/local/rvm"
The Error shows: RVM was unable to use 'default' gemset. Means RVM can't find a gemset named 'default' to use. Check the following line in your deploy.rb
set :rvm_ruby_string, 'gemset-name-here' => put a valid gemset here
Here is the error when doing cap deploy:
*** [err :: 11.15.19.46] find: `/var/www/emclab/releases/20111208184942/public/images'
*** [err :: 11.15.19.46] : No such file or directory
*** [err :: 11.15.19.46] find: `/var/www/emclab/releases/20111208184942/public/stylesheets': No such file or directory
*** [err :: 11.15.19.46] find: `/var/www/emclab/releases/20111208184942/public/javascripts'
*** [err :: 11.15.19.46] : No such file or directory
Any thoughts what causes the error? thanks.
I assume you updated to rails 3.1
I run in same problem recently. Solution:
Add this line to deploy.rb
set :normalize_asset_timestamps, false
In fact this question is duplication of: Capistrano and deployment of a website from Github
only post it because found it on google quite high and this one has not got answer
I struggled with this problem also.
Assuming you are using Rails 3.1, the answer is on this webpage: http://guides.rubyonrails.org/asset_pipeline.html
The short answer is your assets (imgs, js, css) haven't been compiled for deployment to production. You can either compile them manually with this command.
bundle exec rake assets:precompile
Or you can uncomment this line from your Capfile:
load 'deploy/assets'
Or you can set your production environment to compile the assets in production, but I found that solution just created more problems and would recommend the two suggestions above.