rails capistano mac os deploy error - ruby-on-rails

When I used linux everything deploy work, but when I deploy from mac os, I have:
> cap production deploy
DEBUG [1330f96c] Running /usr/bin/env [ -d ~/.rvm ] on IP Adress
DEBUG [1330f96c] Command: [ -d ~/.rvm ]
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
user_name#ip_adress's password:
When I wrote password, I get
> DEBUG [de2b7c18] Finished in 4.376 seconds with exit status 0 (successful).
DEBUG [1ca89b99] Running ~/.rvm/bin/rvm version on ip address
DEBUG [1ca89b99] Command: ~/.rvm/bin/rvm version
DEBUG [1ca89b99] rvm 1.26.10 (latest) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
DEBUG [1ca89b99]
DEBUG [1ca89b99] Finished in 1.130 seconds with exit status 0 (successful).
rvm 1.26.10 (latest) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
DEBUG [1c973067] Running ~/.rvm/bin/rvm current on ip address
DEBUG [1c973067] Command: ~/.rvm/bin/rvm current
DEBUG [1c973067] ruby-2.2.0
DEBUG [1c973067]
DEBUG [1c973067] Finished in 2.110 seconds with exit status 0 (successful).
ruby-2.2.0
DEBUG [848d3c3e] Running ~/.rvm/bin/rvm default do ruby --version on ip address
DEBUG [848d3c3e] Command: ~/.rvm/bin/rvm default do ruby --version
DEBUG [848d3c3e] ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
DEBUG [848d3c3e]
DEBUG [848d3c3e] Finished in 1.050 seconds with exit status 0 (successful).
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
INFO [8dbfa807] Running /usr/bin/env mkdir -p /tmp/project/ on ip address
DEBUG [8dbfa807] Command: /usr/bin/env mkdir -p /tmp/project/
INFO [8dbfa807] Finished in 0.381 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/project/git-ssh.sh 0.0%
INFO Uploading /tmp/project/git-ssh.sh 100.0%
INFO [0f9c9d2a] Running /usr/bin/env chmod +x /tmp/project/git-ssh.sh on ip address
DEBUG [0f9c9d2a] Command: /usr/bin/env chmod +x /tmp/project/git-ssh.sh
INFO [0f9c9d2a] Finished in 1.417 seconds with exit status 0 (successful).
INFO [5dfc2373] Running /usr/bin/env git ls-remote --heads git#bitbucket.org:nick_name/project.git on ip address
DEBUG [5dfc2373] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/project/git-ssh.sh /usr/bin/env git ls-remote --heads git#bitbucket.org:nick_name/project.git )
DEBUG [5dfc2373] Enter passphrase for key '/home/nick_name/.ssh/id_rsa':
I install gem HighLine.
Please help me with this problem?

You could try using a key with no password, or make sure that if your user password and the key's passphrase are different that you are using the correct one. The first prompt is for your user account, user_name#ip_adress, and the second is for the passphrase assigned to /home/nick_name/.ssh/id_rsa.

Related

Can't deploy to my EC2 instance with capistrano 3 anymore

When I try to deploy my application with capistrano it stucks after the command:
~/.rvm/bin/rvm default do ruby --version
This is how the console print looks like:
root#srv:/var/www/project# cap staging deploy
(in /var/www/project)
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
system
Nothing happens after this. It worked fine for a long time but since I've started bundle install (or maybe someone else changed anyhting) the deployment doesn't work anymore. Here's an excerpt of the log file:
INFO ---------------------------------------------------------------------------
INFO START 2021-02-11 13:39:04 +0100 cap staging deploy
INFO ---------------------------------------------------------------------------
DEBUG [08de3cd7] Running ~/.rvm/bin/rvm version as deploy#x.xxx.xx.xx
DEBUG [08de3cd7] Command: ~/.rvm/bin/rvm version
DEBUG [08de3cd7] rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
DEBUG [08de3cd7]
DEBUG [08de3cd7] Finished in 0.773 seconds with exit status 0 (successful).
DEBUG [17018c10] Running ~/.rvm/bin/rvm current as deploy#x.xxx.xx.xx
DEBUG [17018c10] Command: ~/.rvm/bin/rvm current
DEBUG [17018c10] system
DEBUG [17018c10]
DEBUG [17018c10] Finished in 0.303 seconds with exit status 0 (successful).
DEBUG [41115234] Running ~/.rvm/bin/rvm default do ruby --version as deploy#x.xxx.xx.xx
DEBUG [41115234] Command: ~/.rvm/bin/rvm default do ruby --version
As you can see I am using rvm 1.29.12 with ruby 2.5.1p5. Maybe someone had the same problem or can give me a hint what to do. I have been searching for a solution since hours...
Please try to check your setup first using the below command and check what the error is
cap staging deploy:check

capistrano is pulling the wrong ruby version from rvm

I have a rails 5 app. I was trying to hunt down a memory leak and it opened up a can of worms. One of the worms is rvm and deploy. I do not have
rvm_ruby_string
set anywhere in the project. If I go to the directory of the project, and do either
bundle exec ruby --version
or
ruby --version
both result in
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
However, if I do
cap staging deploy
you can see it somehow picks up the wrong version:
DEBUG [778e15cb] Running /usr/bin/env which passenger as deploy#xxxx
DEBUG [778e15cb] Command: /usr/bin/env which passenger
DEBUG [778e15cb] /usr/bin/passenger
DEBUG [778e15cb] Finished in 0.710 seconds with exit status 0 (successful).
DEBUG [0da5c891] Running [ -d ~/.rvm ] as xxx
DEBUG [0da5c891] Command: [ -d ~/.rvm ]
DEBUG [0da5c891] Finished in 0.101 seconds with exit status 0 (successful).
DEBUG [f2734c3e] Running ~/.rvm/bin/rvm version as
xxx
DEBUG [f2734c3e] Command: ~/.rvm/bin/rvm version
DEBUG [f2734c3e] rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski,
Wayne E.
Seguin [https://rvm.io/]
DEBUG [f2734c3e] Finished in 0.268 seconds with exit status 0 (successful).
rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin
[https://rvm.io/]
DEBUG [a2e3d82a] Running ~/.rvm/bin/rvm current as xx
DEBUG [a2e3d82a] Command: ~/.rvm/bin/rvm current
DEBUG [a2e3d82a] ruby-2.5.0
Now if I simply try to mimic what capistrano says it's doing, by copying and pasting the following to the command line:
~/.rvm/bin/rvm current
I get
ruby-2.3.1
So, I'm stumped. Where is Capistrano pulling the rvm var from?
You are probably running cap staging deploy as a different user then when you ran ruby --version.
Based on the capistrano output, you are using deploy user to deploy. If this is the case, you need to install ruby 2.3.1 as deploy user, and set 2.3.1 to "default and current".
You can test this by running ruby --version as both deploy user and the other user you used to run it the first time.

How to enter passphrase for ssh key while deploy rails app via Capistrano?

I tried to deploy my app to digital ocean server following this tutorial.
https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma
So i can clone my apps successfully but when deployed the production one it required me to enter passphrase but when i type it in my terminal it seems like nothing happened like this
cap production deploy:initial
deploy#xxxxxx's password:
deploy#xxxxxx's password:
rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
ruby-2.3.0
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
00:00 git:wrapper
01 mkdir -p /tmp
✔ 01 deploy#139.59.235.223 0.080s
Uploading /tmp/xxxx.sh 100.0%
02 chmod 700 /tmp/xxxx.sh
✔ 02 deploy#139.59.235.223 0.088s
00:00 git:check
01 git ls-remote --heads git#bitbucket.org:xxxx/xxxx.git
01 Enter passphrase for key '/home/deploy/.ssh/id_rsa':
password101
passwordyololo
howtotypepassword
So how can i enter the passphrase in my terminal and pass this kind of security?
Thanks!
SSH key authentication done correctly shouldn't trigger a username-password check.
Try adding your SSH key to the authorized keys on your droplet. You can check your setup by making a SSH connection to your droplet, if it asks for a username-password then redo your setup.
cat ~/.ssh/id_rsa.pub | ssh -p your_port_num deploy#your_server_ip 'cat >> ~/.ssh/authorized_keys'
Also since you added a passphrase to your ssh key, you will need to add your SSH key to the ssh-agent so that it will remember your passphrase without you typing it every deploy.
ssh-add -k ~/.ssh/id_rsa
Additional info in working with ssh keys with passphrases:
https://help.github.com/articles/working-with-ssh-key-passphrases/
You need to setup your keys first. See:
https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma#step-5-—-setting-up-ssh-keys

Capistrano deploy slow due to assets - .sprockets-manifest*

When deploying our API (which doesn't use assets at all), it hangs for about 5 minutes on this line:
DEBUG [985661f8] cannot access /var/www/api.staging/releases/20160208111413/public/assets/.sprockets-manifest*
DEBUG [985661f8] : No such file or directory
We have already disabled assets in config/application.rb:
config.assets.enabled = false
What else needs to be done? We're using these versions:
capistrano (3.4.0)
capistrano-bundler (1.1.4)
capistrano-rails (1.1.3)
capistrano-rails-collection (0.0.3)
Capistrano log:
INFO [42c93c96] Running /usr/local/rvm/bin/rvm 2.1.0#appyapi.staging do bundle exec rake assets:precompile as deploy#139.162.4.97
DEBUG [42c93c96] Command: cd /var/www/appyapi.staging/releases/20160223041856 && ( RAILS_ENV=staging /usr/local/rvm/bin/rvm 2.1.0#appyapi.staging do bundle exec rake assets:precompile )
INFO [42c93c96] Finished in 279.004 seconds with exit status 0 (successful).
DEBUG [f2410fde] Running /usr/bin/env if test ! -d /var/www/appyapi.staging/releases/20160223041856; then echo "Directory does not exist '/var/www/appyapi.staging/releases/20160223041856'" 1>&2; false; fi as deploy#139.162.4.97
DEBUG [f2410fde] Command: if test ! -d /var/www/appyapi.staging/releases/20160223041856; then echo "Directory does not exist '/var/www/appyapi.staging/releases/20160223041856'" 1>&2; false; fi
DEBUG [f2410fde] Finished in 0.081 seconds with exit status 0 (successful).
INFO [fd9b639a] Running /usr/bin/env mkdir -p /var/www/appyapi.staging/releases/20160223041856/assets_manifest_backup as deploy#139.162.4.97
DEBUG [fd9b639a] Command: cd /var/www/appyapi.staging/releases/20160223041856 && /usr/bin/env mkdir -p /var/www/appyapi.staging/releases/20160223041856/assets_manifest_backup
INFO [fd9b639a] Finished in 0.078 seconds with exit status 0 (successful).
DEBUG [462a5734] Running /usr/bin/env ls /var/www/appyapi.staging/releases/20160223041856/public/assets/.sprockets-manifest* as deploy#139.162.4.97
DEBUG [462a5734] Command: cd /var/www/appyapi.staging/releases/20160223041856 && /usr/bin/env ls /var/www/appyapi.staging/releases/20160223041856/public/assets/.sprockets-manifest*
DEBUG [462a5734] ls: cannot access /var/www/appyapi.staging/releases/20160223041856/public/assets/.sprockets-manifest*
DEBUG [462a5734] : No such file or directory
DEBUG [462a5734] Finished in 0.079 seconds with exit status 2 (failed).
OK, first it is important to know that the "No such file or directory" error is benign. Capistrano executes certain commands as tests and takes different code paths based on the results, and it is completely normal that some of those tests result in failures. Unless Capistrano raises an exception, you can safely ignore these "errors".
Second, it seems that rake assets:precompile is being run even though you are not using the asset pipeline, and therefore have no use for it. I'm surprised this step could take so long if you don't have any assets, but let's leave that for another discussion.
The quick solution is to not include the asset pipeline steps of the capistrano-rails plugin. As explained in the README, you can do this by including only the steps you need.
So:
# Put these in your Capfile
require "capistrano/bundler"
require "capistrano/rails/migrations"
# REMOVE these lines so that asset pipeline steps are excluded
# require "capistrano/rails"
# require "capistrano/rails/assets"

Assets Precompile not finding gems

I'm trying to use capistrano 3.0 to fully manage my deploy, from bundle install to precompile. However, I keep running into a problem where "RAILS_ENV=production rake assets:precompile" can't seem to find the gems that bundler installed. Here's the output from capistrano:
DEBUG [8d404b6a] Finished in 1.289 seconds with exit status 0 (successful).
INFO [9eb1acdc] Running ~/.rvm/bin/rvm ruby-2.0.0-p247 do bundle --gemfile /var/www/html/FingertipRails/releases/20131127152604/Gemfile --path /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global --deployment --binstubs /var/www/html/FingertipRails/shared/bin --without development test on 50.112.106.148
DEBUG [9eb1acdc] Command: cd /var/www/html/FingertipRails/releases/20131127152604 && ~/.rvm/bin/rvm ruby-2.0.0-p247 do bundle --gemfile /var/www/html/FingertipRails/releases/20131127152604/Gemfile --path /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global --deployment --binstubs /var/www/html/FingertipRails/shared/bin --without development test
DEBUG [9eb1acdc] Your bundle is complete!
DEBUG [9eb1acdc] Gems in the groups development and test were not installed.
DEBUG [9eb1acdc] It was installed into /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global
INFO [9eb1acdc] Finished in 2.892 seconds with exit status 0 (successful).
DEBUG [0de28eb8] Running if test ! -d /var/www/html/FingertipRails/releases/20131127152604; then echo "Directory does not exist '/var/www/html/FingertipRails/releases/20131127152604'" 1>&2; false; fi on 50.112.106.148
DEBUG [0de28eb8] Command: if test ! -d /var/www/html/FingertipRails/releases/20131127152604; then echo "Directory does not exist '/var/www/html/FingertipRails/releases/20131127152604'" 1>&2; false; fi
DEBUG [0de28eb8] Finished in 1.506 seconds with exit status 0 (successful).
INFO [cb071501] Running ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile on 50.112.106.148
DEBUG [cb071501] Command: cd /var/www/html/FingertipRails/releases/20131127152604 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile )
DEBUG [cb071501] /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
DEBUG [cb071501] :
DEBUG [cb071501] Could not find hashr-0.0.22 in any of the sources
DEBUG [cb071501] (
Here is my staging.rb (I'm using "cap staging deploy"):
set :stage, :staging
set :rails_env, "production"
set :user, "ec2-user"
role :app, %w{50.112.106.148}
role :web, %w{50.112.106.148}
role :db, %w{50.112.106.148}
server '50.112.106.148', user: 'ec2-user', roles: %w{web app}
And here is my deploy.rb:
set :application, 'FingertipRails'
set :repo_url, 'git#github.com:dresources/FingertipRails.git'
set :branch, "master"
set :rvm_type, :user
set :bundle_cmd, "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global/bin/bundle"
set :bundle_dir, "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global"
set :bundle_flags, '--deployment'
Any ideas?
Thank you
EDIT
Here is the output of rvm info on the server:
ruby-2.0.0-p247:
system:
uname: "Linux ip-10-226-137-104 3.4.62-53.42.amzn1.x86_64 #1 SMP Fri Sep 20 07:23:24 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux"
system: "amazon/2013.09/x86_64"
bash: "/bin/bash => GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.23.8 (master) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]"
updated: "1 month 10 days 44 minutes 13 seconds ago"
path: "/home/ec2-user/.rvm"
ruby:
interpreter: "ruby"
version: "2.0.0p247"
date: "2013-06-27"
platform: "x86_64-linux"
patchlevel: "2013-06-27 revision 41674"
full_version: "ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]"
homes:
gem: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247"
ruby: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247"
binaries:
ruby: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin/ruby"
irb: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin/irb"
gem: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin/gem"
rake: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247/bin/rake"
environment:
PATH: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247/bin:/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global/bin:/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin:/home/ec2-user/.rvm/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/bin"
GEM_HOME: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247"
GEM_PATH: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247:/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global"
MY_RUBY_HOME: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247"
IRBRC: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/.irbrc"
RUBYOPT: ""
gemset: ""
In your Capistrano task, try adding the bundle_cmd variable you've set in your config so that rake assets:precompile runs with bundle exec. Without seeing what other variables you have in your deploy.rb, you'll want to get this line:
DEBUG [cb071501] Command: cd /var/www/html/FingertipRails/releases/20131127152604 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile )
... to look more like this:
cd /var/www/html/FingertipRails/releases/20131127152604 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 bundle exec rake assets:precompile )

Resources