Trying to deploy app via Capistrano for first time, having problems - ruby-on-rails

I am trying to deploy a Rails app via Capistrano but am having problems. The messages that get returned in Terminal are as follows:
victor$ cap deploy
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
executing locally: "git ls-remote git#github.com:victory/PUM.git HEAD"
/Library/Ruby/Gems/1.8/gems/capistrano-2.5.19/lib/capistrano/recipes/deploy.rb:98: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
/Library/Ruby/Gems/1.8/gems/capistrano-2.5.19/lib/capistrano/recipes/deploy.rb:98: command not found: git ls-remote git#github.com:victory/PUM.git HEAD
*** [deploy:update_code] rolling back
* executing "rm -rf /passenger/nginx/pumpl/releases/20101020025555; true"
servers: ["188.126.236.269"]
Password:
I tried to do a Google search but am having a bit of trouble finding a good answer

Would seem your remote installation lacks git.
Have you tried doing a
cap deploy:check
To check the environment and a
cap deploy:setup
To setup the required files?

I finally figured it out.
I just switched to a new Mac that didn't have Xcode installed. This is why Macports was not working correctly. I installed Xcode and after that, I am now able to deploy just fine.

Related

A branch named 'deploy' already exists

In a capistrano deploy of a Ruby-on-Rails project the deployment fails and aborts with a fatal error. The message is
A branch named 'deploy' already exists.
Of course the branch already exists, because we are trying to deploy that branch. Any idea what goes wrong? This is the log, we are using Git, the capistrano branch is set to deploy, the capistrano version is 2.15.9, ruby version is 2.3.1
$ cap staging deploy
triggering load callbacks
* 2016-09-13 12:12:38 executing `staging'
triggering start callbacks for `deploy'
* 2016-09-13 12:12:38 executing `multistage:ensure'
* 2016-09-13 12:12:38 executing `deploy'
* 2016-09-13 12:12:38 executing `deploy:update'
** transaction: start
* 2016-09-13 12:12:38 executing `deploy:update_code'
executing locally: "git ls-remote git#git.my-company.com:developer-group/my-site.git deploy"
command finished in 615ms
* executing "git clone -q -b deploy --depth 1 git#git.my-company.com:developer-group/my-site.git /home/my-user/sites/my-domain.de/releases/20160913101239 && cd /home/my-user/sites/my-domain.de/releases/20160913101239 && git checkout -q -b deploy fe7bd80727d9cce1a275a531c6e21b84e15ab0cd && rm -Rf /home/my-user/sites/my-domain.de/releases/20160913101239/.git && (echo fe7bd80727d9cce1a275a531c6e21b84e15ab0cd > /home/my-user/sites/my-domain.de/releases/20160913101239/REVISION)"
servers: ["my-server"]
[my-server] executing command
** [my-server :: err] fatal: A branch named 'deploy' already exists.
command finished in 2481ms
The command that fails is git checkout -q -b deploy sha_value.
It turns out deploy is a reserved name for Capistrano, so you are not allowed to use it as a branch name. Capistrano apparently tries to create a temporary "deploy" branch if you deploy a Git project.
https://github.com/capistrano/capistrano/issues/359
In general "deploy", "doctor", and "install" are all reserved names in Capistrano, which are also not allowed as stage names (such as "production" or "staging").

Got error while deploy rails code on server

I am getting below error when tried to deploy using capistrano
/usr/local/rvm/bin/rvm-shell - No such file or directory
** [deploy:update_code] exception while rolling back: Capistrano::CommandError, failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-2.0.0-p353' -c 'rm -rf /home/xxx/xxxxxx/releases/20151019095324; true'" on xx.xx.xxx.xxx
Any one have a solution.
Rvm is probably not installed or not accessible from the user "declared" in capistrano.
Refer to https://rvm.io/rvm/install to check if rvm is correctly installed on your server.

capistrano deploy task failing in Yosemite

Here is the command I'm giving to deploy my code to a server.
$ cap production deploy:migrations
* executing `production'
triggering start callbacks for `deploy:migrations'
* executing `multistage:ensure'
* executing `deploy:migrations'
* executing `deploy:update_code'
triggering before callbacks for `deploy:update_code'
* executing `dj:stop'
* executing "RAILS_ENV=production god stop dj"
servers: ["xyz.com"]
connection failed for: xyz.com (ArgumentError: non-absolute home)
I am able to ssh into xyz.com. My capistrano version is
$ cap --version
Capistrano v2.5.19
And it is dependant on net-ssh-2.1.3. The ruby version is ruby 1.9.2p290
Read through similar questions in Stackoverflow, all seem to are suggesting a check on /etc/passwd file in the server. I checked the file and ENV['HOME'] is correctly set for the ssh user.
HOME variable in Server.
$ echo $HOME
/home/deploy
HOME has always been like this from the start. Why would it fail all of a sudden.
Anyone facing the same issue?

Ruby on Rails fails on bundle install when using capistrano

I have not much knowledge of Ruby. I have to host a Ruby website. When I make deploy setup and check, is everything ok. But when I cap deploy I get the following error.
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/lpavisit/releases/20131009211837; true"
servers: ["x.xx.xx.xxx"]
[5.56.61.183] executing command
command finished in 209ms
failed: "sh -c 'cd /var/www/lpavisit/releases/20131009211837 && bundle install --without development test'" on x.xx.xx.xxx
Thanks!!
Setting up a Capistrano-based deploy system is a bit complex. You might want to give Heroku a try until you're more familiar with Ruby. But to continue with Capistrano, first ask it if it has everything it needs to deploy:
$ cap deploy:check
You want to see it say, You appear to have all necessary dependencies installed. Yours probably won't. In that case, you should look for a good capistrano book or online tutorial.

Debugging Capistrano

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.

Resources