Rails cap production doctor error

Steps to reproduce Not sure, I just ran cap production doctor for the first time on my project. Deploys are working as usual. Your configuration cap production doctor --trace ** Invoke production (...

Steps to reproduce

Not sure, I just ran cap production doctor for the first time on my project.
Deploys are working as usual.

Your configuration

cap production doctor --trace

** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
Please enter ‘production’ if you know what you’re doing (): production
** Invoke rbenv:validate (first_time)
** Execute rbenv:validate
** Invoke rbenv:map_bins (first_time)
** Execute rbenv:map_bins
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_linked_dirs (first_time)
** Execute deploy:set_linked_dirs
** Invoke deploy:set_rails_env
** Invoke doctor (first_time)
** Invoke doctor:environment (first_time)
** Execute doctor:environment

Environment

Ruby     ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Rubygems 2.5.1
Bundler  N/A
Command  /home/zavan/.rbenv/versions/2.3.1/bin/cap production doctor

** Invoke doctor:gems (first_time)
** Execute doctor:gems

Gems

capistrano              3.5.0
airbrussh               1.0.2
rake                    11.1.2
sshkit                  1.10.0
capistrano-bundler      1.1.4
capistrano-harrow       0.5.1
capistrano-rails        1.1.6
capistrano-rbenv        2.0.4
capistrano3-delayed-job 1.7.2
capistrano3-puma        1.2.1

** Invoke doctor:variables (first_time)
** Execute doctor:variables

Variables

cap aborted!
ArgumentError: comparison of Symbol with String failed
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.5.0/lib/capistrano/doctor/variables_doctor.rb:23:in sort' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.5.0/lib/capistrano/doctor/variables_doctor.rb:23:incall’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.5.0/lib/capistrano/tasks/doctor.rake:17:in block (2 levels) in <top (required)>' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:248:inblock in execute’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:243:in each' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:243:inexecute’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/airbrussh-1.0.2/lib/airbrussh/rake/context.rb:62:in execute' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:187:inblock in invoke_with_call_chain’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/monitor.rb:214:in mon_synchronize' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:180:ininvoke_with_call_chain’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:209:in block in invoke_prerequisites' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:207:ineach’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:207:in invoke_prerequisites' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:186:inblock in invoke_with_call_chain’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/monitor.rb:214:in mon_synchronize' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:180:ininvoke_with_call_chain’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:173:in invoke' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:150:ininvoke_task’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:106:in block (2 levels) in top_level' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:106:ineach’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:106:in block in top_level' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:115:inrun_with_threads’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb💯in top_level' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:78:inblock in run’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:176:in standard_exception_handling' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:75:inrun’
/home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.5.0/lib/capistrano/application.rb:14:in run' /home/zavan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.5.0/bin/cap:3:in<top (required)>’
/home/zavan/.rbenv/versions/2.3.1/bin/cap:23:in load' /home/zavan/.rbenv/versions/2.3.1/bin/cap:23:in


Tasks: TOP => doctor => doctor:variables

Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

Anthony Candaele

Hi, I’m following the Deploy Rails guide.

However, when I run

cap production deploy

I’m getting this error message:

$cap production deploy
DEBUG[be6b6bd6] Running /usr/bin/env [ -d ~/.rbenv/versions/2.0.0-p451 ] on 95.85.5.6
DEBUG[be6b6bd6] Command: [ -d ~/.rbenv/versions/2.0.0-p451 ]
DEBUG[be6b6bd6] Finished in 1.060 seconds with exit status 1 (failed).
ERRORrbenv: 2.0.0-p451 is not installed or not found in ~/.rbenv/versions/2.0.0-p451
cap aborted!

Not sure what’s going on. I guess it has something to do with incompatible versions of Ruby, but is it the Ruby version on my local machine or on the VPS?

thanks for your help,

Anthony

Chris Oliver

That error says that on the server the ruby version you have doesn’t match the one you set in your Capfile. You’ll want to make sure the version in this file matches the version of Ruby on the server.

Anthony Candaele

I see,

I changed the version in my Capfile to :

set :rbenv_ruby, '2.1.2-p95'

but now, when I run

cap production deploy

I get the error:

$cap production deploy
DEBUG[d2d51431] Running /usr/bin/env [ -d ~/.rbenv/versions/2.1.2-p95 ] on 95.85.5.6
DEBUG[d2d51431] Command: [ -d ~/.rbenv/versions/2.1.2-p95 ]
DEBUG[d2d51431] Finished in 0.980 seconds with exit status 1 (failed).
ERRORrbenv: 2.1.2-p95 is not installed or not found in ~/.rbenv/versions/2.1.2-p95
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 95.85.5.6: exit
/Users/acandael/Sites/posplus/vendor/bundle/bundler/gems/rbenv-2332dba20ec1/lib/capistrano/tasks/rbenv.rake:12:in `exit'
/Users/acandael/Sites/posplus/vendor/bundle/bundler/gems/rbenv-2332dba20ec1/lib/capistrano/tasks/rbenv.rake:12:in `block (3 levels) in     <top (required)>'
/Users/acandael/Sites/posplus/vendor/bundle/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/acandael/Sites/posplus/vendor/bundle/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/acandael/Sites/posplus/vendor/bundle/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'

SystemExit: exit
/Users/acandael/Sites/posplus/vendor/bundle/bundler/gems/rbenv-2332dba20ec1/lib/capistrano/tasks/rbenv.rake:12:in exit'
/Users/acandael/Sites/posplus/vendor/bundle/bundler/gems/rbenv-2332dba20ec1/lib/capistrano/tasks/rbenv.rake:12:in
block (3 levels) in ‘
/Users/acandael/Sites/posplus/vendor/bundle/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in instance_exec'
/Users/acandael/Sites/posplus/vendor/bundle/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in
run’
/Users/acandael/Sites/posplus/vendor/bundle/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute’
Tasks: TOP => rbenv:validate
(See full trace by running task with —trace)

I don’t understand this, I ran ‘ruby -v’ on my Digital Ocean vps and it told me the Ruby version is:

ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

greetings,

Anthony

Chris Oliver

If you type this command, what is the output? ls ~/.rbenv/versions/2.1.2-p95

Also, type which ruby and make sure the output is /home/deploy/.rbenv/shims/ruby

Anthony Candaele

Hi Chris,

when I run the command as deploy user on the vps

which ~/.rbenv/versions/2.1.2-p95

I get no output, just a new cursor line

when I run

which ruby

I get

/home/deploy/.rbenv/shims/ruby

when I run

ruby -v

I get

ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

I also try to solve the issue by changing the line in my Capfile from

set :rbenv_ruby, '2.1.2-p95'

to

set :rbenv_ruby, '2.1.2p95'

but that didn’t fix it.

Chris Oliver

The second answer is good, shows that it’s loaded rbenv correctly.

My bad on that first one, I meant ls ~/.rbenv/versions/2.1.2-p95

Anthony Candaele

when I run

ls ~/.rbenv/versions/2.1.2-p95

on the vps, I get

ls: cannot access /home/deploy/.rbenv/versions/2.1.2-p95: No such file or directory

Chris Oliver

Well hmm, that’s potentially your problem. That folder should exist to store your Ruby version in. I’m also running 2.1.2p25 on my machine, but I only have a ~/.rbenv/versions/2.1.2 folder.

Try using this instead:

set :rbenv_ruby, '2.1.2'

Anthony Candaele

ok,

using

set :rbenv_ruby, '2.1.2'

fixed it.

However now I’m running in this error:

[62800640]  Warning: Permanently added 'github.com,some id' (RSA) to the list of known hosts.
DEBUG[62800640]     Permission denied (publickey).
DEBUG[62800640]     fatal: Could not read from remote repository.
DEBUG[62800640]     
DEBUG[62800640]     Please make sure you have the correct access rights
DEBUG[62800640]     and the repository exists.
DEBUG[62800640] Finished in 0.745 seconds with exit status 128 (failed).

Chris Oliver

Cool, so that’s fixed. You’ll need to check your git repo in the config to make sure it exists and/or add the forward_agent option to use your local keys for grabbing the code to the server from Github.

Anthony Candaele

ok, again one step further

I ran

ssh-add ~/.ssh/id_rsa

in the terminal

and ran a new

cap deploy production

the deploy proces moved on, but then it failed with

Finished in 0.029 seconds with exit status 1 (failed).
ERRORlinked file /home/deploy/posplus/shared/config/database.yml does not exist on 95.85.5.6

I guess this has to do with the issue about creating the Postgres user which I reported about on this forum under the thread ‘setup Postgres user fails’

Chris Oliver

You’ll need to create the database.yml with a production config on the server in the folder that it mentions there since you don’t have it in your repository. And yes, it’ll need the configuration to postgres that you mentioned in the other thread.

Anthony Candaele

Moved on again with the deployment proces, but the deployment still fails. Now there seems to be a problem with the bundle command

DEBUG[020e32cd] Command: cd /home/deploy/posplus/releases/20140904144347 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2    ~/.rbenv/bin/rbenv exec bundle install --binstubs /home/deploy/posplus/shared/bin --path /home/deploy/posplus/shared/bundle --without   development test --deployment --quiet )
DEBUG[020e32cd]     rbenv: bundle: command not found

cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 95.85.5.6: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: rbenv: bundle: command not found

Chris Oliver

Install bundler on the server:

gem install bundler
rbenv rehash

Anthony Candaele

this is harder then I thought, I installed the bundler gem and now the next error is:

DEBUG[a18e2f6c]     rake aborted!
DEBUG[a18e2f6c]     ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
DEBUG[a18e2f6c]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/execjs-2.2.1/lib/execjs/runtim

Googled this issue, seems I have to install Node.js with:

sudo apt-get install nodejs

Anthony Candaele

ok, now I guess I ran into the Posgres issue, I reported on:

DEBUG[00c3d123]     rake aborted!
DEBUG[00c3d123]     ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: []

I tried to solve this by adding settings for the production server in my local config.database.yml file

production:
  database: <database>
  adapter: postgresql
  encoding: unicode
  pool: 5
  username: <username> 
  password: <password>

but I keep getting the same error message:

rake aborted!
DEBUG[ffcbeda7]     ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: []
DEBUG[ffcbeda7]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/activerecord-    4.1.1/lib/active_record/connection_adapters/connection_specification.rb:257:in `resolve_symbol_connection'

Anthony Candaele

I configured the production database and now the capistrano script is passing the production database error.

Now I’m bumping into another error:

rake aborted!
DEBUG[53a69508]     ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
DEBUG[53a69508]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/fog-core-1.22.0/lib/fog/core/service.rb:237:in `validate_options'

I guess this errror is related to the fact that my app is using Carrierwave and Fog and is storing uploaded images to Amazon S3.

Does this errror mean I should create Environment Variables for aws_access_key_id and aws_secret_access_key?

thanks for your help,

Anthony

Anthony Candaele

I tried to add the environment variables to my vps environment with:

export S3_KEY=’my key …’
export S3_SECRET=’my secret key’

but I’m keep getting the same error when I run ‘cap production deploy’:

DEBUG[4f41f85f]     rake aborted!
DEBUG[4f41f85f]     ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
DEBUG[4f41f85f]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/fog-core-1.22.0/lib/fog/core/service.rb:237:in `validate_options'

Chris Oliver

Anthony Candaele

thanks Chris, will try this out

greetings,

Anthony

Anthony Candaele

man this is hard, I put the environment variable S3_KEY and S3_SECRET in different files:

~/.bashrc
/etc/default/nginx
home/deploy/posplus/shared/config/secrets.yml

but none solved the problem, I’m stil getting this error message when I try to do ‘cap production deploy’:

DEBUG[ff424d92]     rake aborted!
DEBUG[ff424d92]     ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
DEBUG[ff424d92]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/fog-core-1.22.0/lib/fog/core/service.rb:237:in `validate_options'

James Dullaghan

Anthony Candaele

Hi James, thanks for the help,

I did put the hard coded keys in the secrets.yml file and also sourced the ~/.bashrc file. But it didn’t solve the issue. Capistrano keeps giving me the error:

INFO[97d4f95a] Running ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile on 95.85.5.6
DEBUG[97d4f95a] Command: cd /home/deploy/posplus/releases/20140913135409 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2     RAILS_ENV=production ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
DEBUG[97d4f95a]     rake aborted!
DEBUG[97d4f95a]     ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key

If this could clear things up, my config/initializers/carrier_wave.rb file looks like this:

CarrierWave.configure do |config|
  if Rails.env.staging? || Rails.env.production?
    config.storage = :fog
    config.fog_credentials = {
      :provider               => 'AWS',                        # required
      :aws_access_key_id      => ENV['S3_KEY'],                        # required
      :aws_secret_access_key  => ENV['S3_SECRET'],                        # required
    }
    config.fog_directory  = 'posplus'                     # required
  else
    config.storage = :file
    config.enable_processing = Rails.env.production?
  end
end

I always worked on Heroku, where I set the environment variables with the ‘heroku set:config ….’ command.

greetings,

Anthony

Chris Oliver

If you use secrets.yml, you don’t access them through the ENV anymore. Instead you want to use Rails.application.secrets.key_name to retrieve your values.

Take a look here for a blog post on it: http://richonrails.com/articles/the-rails-4-1-secrets-yml-file

I’ll also be sure to do a screencast on this topic because I think it’s not documented too well. :)

Anthony Candaele

Hi Chris, thanks, I wasn’t aware of that and changed the carrier_wave.rb initializer:

CarrierWave.configure do |config|
  if Rails.env.staging? || Rails.env.production?
    config.storage = :fog
    config.fog_credentials = {
      :provider               => 'AWS',                        # required
      :aws_access_key_id      => Rails.application.secrets.S3_KEY,                        # required
      :aws_secret_access_key  => Rails.application.secrets.S3_SECRET,                        # required
    }
    config.fog_directory  = 'posplus'                     # required
  else
    config.storage = :file
    config.enable_processing = Rails.env.production?
  end
end

and my secrets.yml file looks like this:

production:
  S3_KEY: <%= ENV['S3_KEY'] %>
  S3_SECRET: <%= ENV['S3_SECRET'] %>

Then it also struck my that I working in a feature branch called ‘capistrano’ so I added

set :branch, 'capistrano'

to my config/deploy.rb file and I pushed the feature branch to a remote branch on Github

But I’m still getting the same error when doing ‘cap production deploy’:

DEBUG[e90c10e8] Command: cd /home/deploy/posplus/releases/20140914000558 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2     RAILS_ENV=production ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
DEBUG[e90c10e8]     rake aborted!
DEBUG[e90c10e8]     ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
DEBUG[e90c10e8]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/fog-core-1.24.0/lib/fog/core/service.rb:237:in     `validate_options'

sigh : (

I don’t know why Capistranno isn’t picking up the changes. Right now I’m not sure if this could be related to the problems I had with the creation of a postgres user.

Maybe you guys are seeing things I don’t see? My remote feature branch is at:

https://github.com/acandael/posplus-rails/tree/capistrano

greetings,

Anthony

Chris Oliver

Well, the point about using secrets.yml is that you don’t need to put them in the ENV anymore. Just make sure the file is not in your repository.

Create secrets.yml on the server in the shared directory like you did with database.yml and then write your keys in it directly. Then add the file to your config/deploy.rb to make sure it gets symlinked on deploy.

After that, you can use those secrets without having to go through ENV. They did this so that you wouldn’t have to deal with this annoying system configuration and you can manage it a lot easier!

Anthony Candaele

Hi Chris, thanks a lot, adding the secrets.yml file to config/deploy.rb solved the issue : )

I’m still not there, as a couple of other challenges await me like dealing with these failure messages:

DEBUG[f06a4082] Finished in 0.081 seconds with exit status 1 (failed).
DEBUG[09ba02b5] Running /usr/bin/env [ -f /home/deploy/posplus/releases/20140914083548/config/database.yml ] on <my-ip>

I’m getting a couple of these error messages when deploying with Capistrano.

Also there seem to be some issues with assets:

    DEBUG[da33561d]     I, [2014-09-14T04:36:06.122787 #24469]  INFO -- : Writing           /home/deploy/posplus/releases/20140914083548/public/assets/belfort-081a4bbefd8f4ed5f27bbb624d48f379.png
   DEBUG[da33561d]  I, [2014-09-14T04:36:06.125691 #24469]  INFO -- : Writing     /home/deploy/posplus/releases/20140914083548/public/assets/jigsaw-puzzle-1c07a986767187bd9961fe69651705c8.jpg
   DEBUG[da33561d]  I, [2014-09-14T04:36:06.127459 #24469]  INFO -- : Writing /home/deploy/posplus/releases/20140914083548/public/assets/logo-posplus-72x61-c0cc65a8684ac8d9da5d402fcbc58c6e.png
   DEBUG[da33561d]  I, [2014-09-14T04:36:06.129307 #24469]  INFO -- : Writing /home/deploy/posplus/releases/20140914083548/public/assets/logo-posplus-a0276666c4cf6aaeb387a2580cdefc71.png
   DEBUG[da33561d]  I, [2014-09-14T04:36:06.139111 #24469]  INFO -- : Writing /home/deploy/posplus/releases/20140914083548/public/assets/member_placeholder-66af4d62c5dc83d72c054cf50caea6d5.png

But again I’m a step further in my quest to deploy a Rails app on a VPS

thanks for your patience,

Anthony

Anthony Candaele

Hi Chris, James,

Just successfully deployed my Rails app on a Digital Ocean VPS ( a small step for mankind but a giant leap for a devops newbie):

http://95.85.5.6

thanks a lot for your help and patience,

greetings,

Anthony

Chris Oliver

Congrats Anthony!! :) After what seemed like a ton of issues, I’m glad you finally got it all running. I’m sure it will be way quicker next time!

James Dullaghan

This is awesome news! Getting that first one setup after debugging for what seems like endless amounts of time is a great feeling. Hopefully you learned quite a bit along the way.

Anthony Candaele

@Chris, @James

The first deploy is a bit swimming in the ocean, lot’s of new stuff, and not sure about what’s going on. But I’m starting to feel more comfortable right now, and I’m glad I made the switch from Heroku to a Digital Ocean vps. The Rails Deploy Guide on GoRails was an awesome help, and I would recommend it to anybody having to deploy a Rails app for the first time.

Just a question (@Chris) about the the Rails Deploy Guide, is there a special reason that you use Passenger over Unicorn?

greetings, and again thanks a lot for your help!

Anthony

Chris Oliver

Mostly just because it’s very simple and easy to get up and running. From some recent benchmarks I read, it also performs comparatively to Unicorn and some other solutions out there. Seemed to be a good mix of convenience to learn and performance.

Anthony Candaele

shakycode

+1 on using Passenger over Unicorn. I’ve tried both but I prefer Passenger. Plus it’s bundled natively with Nginx which is nice. Configuration takes 30 seconds and you’re done. And Chris is right, benchmarks point out that it performs just as good as Unicorn. There is some tuning you can do to make it run even better. If you need some help let me know, I’m very familiar with Nginx/Passenger and use it on all my apps.

Gareth Gomersall

If ever any one comes up with an issue with activeadmin and it failing with : NameError: uninitialized constant ActiveAdmin
— I added

require ‘activeadmin’

— to the top of the initializers/active_admin.rb file, not sure if this breaks anything else but that fixed an issue for me see post — https://github.com/activeadmin/activeadmin/issues/1992

I then ran into the javascript problem and installed nodes, as per Anthony’s reply above and that worked and it seems to have finished the deployment with out any other issue…. about to restart everything and check it out….

Gareth Gomersall

So after my wishful thinking of everything running smoothly i’ve tried the command — RAILS_ENV=production bundle exec rake db:create under the /home/deploy/myapp/current folder (i changed the mayor to my app name ) but i got the error — PG::InsufficientPrivilege: ERROR: permission denied to create database

Any help on this would be great!

Chris Oliver

Gareth — It is probably because your Postgres user doesn’t have create database rights. You may want to either fix permissions on the user you are connecting with, or login as the postgres user and create the db manually.

Gareth Gomersall

Hey Chris,

Yeah i’ve been googling it and came across a couple of resources, most say i should run the following command —

psql -U your_username postgres

psql postgres
ALTER ROLE that_username CREATEDB

but that didn’t seem to work as i still get that error… I’m not entirely sure how to create a db manually as the postgres user…. i’ll google it a bit…. so close i can smell the cogs on the server burning! haha

Chris Oliver

Gareth Gomersall

ok i’ve followed that somewhat haha (i was actually looking at that same link before you sent it through)

so i did the following

template1=# CREATE USER deploy WITH PASSWORD ‘somepassword’ SUPERUSER;

then made my way over to — /home/deploy/myapp/current
and ran — RAILS_ENV=production bundle exec rake db:create

seems to have worked a treat… i’ll finish off the rest of your tutorial, and fingers crossed no more errors! :)

Cheers again for all the help
Gareth

Gareth Gomersall

Gareth Gomersall

ok so i’ve edited the secrets.yml file from —

production:
secret_key_base: <%= ENV[«SECRET_KEY_BASE»] %>
to
production:
secret_key_base: 1fa75cf22906eaa8bc9a9ebd43dfa80731morestuff

restarted everything and now i get server 500 error — We’re sorry, but something went wrong.

I don’t want to give up, but i checked the logs in appname/shared/logs/production.log but can’t see anything there, maybe i’m looking in the wrong place…

Gareth Gomersall

Hey Guys…..

I’ve still got this dastardly «We’re sorry, but something went wrong.» error with my nibli site (chris you’ll remember doing the code cast for me:) )
I’ve check the production.log under app/current/log but nothing there, i’ve also checked the /var/log/nginx/error.log and it’s got something to do with the table lead (i’m guessing

App 2163 stdout: Processing by PagesController#index as HTML
App 2163 stdout: PG::UndefinedTable: ERROR: relation «leads» does not exist
App 2163 stdout: LINE 5: WHERE a.attrelid = ‘»leads»‘::regclass
App 2163 stdout: ^
App 2163 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 2163 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 2163 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 2163 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 2163 stdout: WHERE a.attrelid = ‘»leads»‘::regclass
App 2163 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 2163 stdout: ORDER BY a.attnum
App 2163 stdout:
App 2163 stdout: PG::UndefinedTable: ERROR: relation «leads» does not exist
App 2163 stdout: LINE 5: WHERE a.attrelid = ‘»leads»‘::regclass
App 2163 stdout: ^
App 2163 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 2163 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 2163 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 2163 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 2163 stdout: WHERE a.attrelid = ‘»leads»‘::regales
App 2163 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 2163 stdout: ORDER BY a.attnum
App 2163 stdout:
App 2163 stdout: Completed 500 Internal Server Error in 2ms

I thought that when we do the created the database it would do all the tables, how do i create them? do i have to do rake db:migrate?

Chris Oliver

So creating the database and creating the tables are separate. The migrations are what tells the database which tables and columns to add and the database is just the one place to store everything. You’ll want to make sure the migrations run on the server.

You should be able to do that with cap deploy:migrate

Gareth Gomersall

I GOT IT WORKING!!!!! haha
sorry for all the spam in this forum post over the last couple of days….

I figured out how to create the table leads and the site is working a treat! (fingers crossed)

check it out — http://46.101.34.7

Gareth Gomersall

i spoke too soon, my form isn’t working! :(

shakycode

I tried hitting the URL and it gives

We’re sorry, but something went wrong.

If you are the application owner check the logs for more information.

Can you provide some logs from your production server?

Gareth Gomersall

So Chris where do i run the cap deploy:migrate? on my local machine or on the server?

when run on the server

WARNING:root:could not open file ‘/etc/apt/sources.list.d/passenger.list’

The program ‘cap’ is currently not installed. You can install it by typing:
sudo apt-get install capistrano

Gareth Gomersall

James this is the latest log — (it was working a moment ago, but my form didn’t work — i got a 404 error when i submitted it, so i deleted the table)

pp 5028 stdout: Completed 500 Internal Server Error in 7ms
App 5028 stdout:
App 5028 stdout: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation «leads» does not exist
App 5028 stdout: LINE 5: WHERE a.attrelid = ‘»leads»‘::regclass
App 5028 stdout: ^
App 5028 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 5028 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 5028 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 5028 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 5028 stdout: WHERE a.attrelid = ‘»leads»‘::regclass
App 5028 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 5028 stdout: ORDER BY a.attnum
App 5028 stdout: ):
App 5028 stdout: app/controllers/pages_controller.rb:4:in index'
App 5028 stdout:
App 5028 stdout:
App 5028 stdout:
App 5028 stdout: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "leads" does not exist
App 5028 stdout: LINE 5: WHERE a.attrelid = '"leads"'::regclass
App 5028 stdout: ^
App 5028 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 5028 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 5028 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 5028 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 5028 stdout: WHERE a.attrelid = '"leads"'::regclass
App 5028 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 5028 stdout: ORDER BY a.attnum
App 5028 stdout: ):
App 5028 stdout: app/controllers/pages_controller.rb:4:in
index’
App 5028 stdout:
App 5028 stdout:

shakycode

ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "leads" does not exist

Are you sure you ran cap deploy:migrations? Also does your model have any relations since this is what AR is reporting as a problem. It could also be an issue in your view/form so if you could post the code for that too that’d be helpful.

Gareth Gomersall

Well i tried running cap deploy:migrations on my local machine and server (not sure which is the correct one to run it on)

my server produced this —
WARNING:root:could not open file ‘/etc/apt/sources.list.d/passenger.list’

The program ‘cap’ is currently not installed. You can install it by typing:
sudo apt-get install capistrano

my local machine produced this —
Stage not set, please call something such as cap production deploy, where production is a stage you have defined.

so i ran it as cap production deploy:migrate — and got this —
DEBUG [c6d7d298] Running /usr/bin/env [ -d ~/.rvm ] as deploy@46.101.34.7
DEBUG [c6d7d298] Command: [ -d ~/.rvm ]
DEBUG [c6d7d298] Finished in 1.270 seconds with exit status 0 (successful).
DEBUG [9ad5298d] Running ~/.rvm/bin/rvm version as deploy@46.101.34.7
DEBUG [9ad5298d] Command: ~/.rvm/bin/rvm version
DEBUG [9ad5298d] rvm 1.26.11 (latest) by Wayne E. Seguin wayneeseguin@gmail.com, Michal Papis mpapis@gmail.com [https://rvm.io/]
DEBUG [9ad5298d] Finished in 0.279 seconds with exit status 0 (successful).
rvm 1.26.11 (latest) by Wayne E. Seguin wayneeseguin@gmail.com, Michal Papis mpapis@gmail.com [https://rvm.io/]
DEBUG [dc47bb01] Running ~/.rvm/bin/rvm current as deploy@46.101.34.7
DEBUG [dc47bb01] Command: ~/.rvm/bin/rvm current
DEBUG [dc47bb01] ruby-2.1.2
DEBUG [dc47bb01] Finished in 0.275 seconds with exit status 0 (successful).
ruby-2.1.2
DEBUG [a69e5613] Running ~/.rvm/bin/rvm default do ruby —version as deploy@46.101.34.7
DEBUG [a69e5613] Command: ~/.rvm/bin/rvm default do ruby —version
DEBUG [a69e5613] ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
DEBUG [a69e5613] Finished in 0.633 seconds with exit status 0 (successful).
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

this is my git repo — https://github.com/ggomersall/Nibli_leads

shakycode

You would run cap deploy:migrate or cap deploy:migrations from your local machine since this is a deployment callback.

shakycode

If you deleted the table, then that’s a part of the problem. I would start fresh, login to the production server, drop the database, recreate it manually and assign ownership to the db user (as Chris said you may have to create that user) that you have in your database.yml file. Then after you’ve manually created the database run cap deploy:migrate.

Gareth Gomersall

Hey James,
ok so just to clarify, i’m going to drop the database (nibli_leads), recreate it manually, and assign it to the db user…

when i’m recreating the database, do i have to manually create the table as well? i.e. table called «leads», with —
t.string «name»
t.string «email»
t.string «device»
t.string «country»
t.datetime «created_at»
t.datetime «updated_at»

and then run cap deploy:migrate?
or just create the database, without the table of «leads» and run cap deploy:migrate on my local machine?

shakycode

Hey Gareth,

You don’t have to recreate the table manually. Drop the database, recreate it, alter owner to your db user, then just run cap deploy:migrate This should get your database all squared away. Once this happens if your form does not work, please provide a snapshot of the production log and I’ll take a look.

Gareth Gomersall

Hey again James,

Well i did what was recommended, dropped the database (i even recreated the db user), recreated the db and then granted the access to the db user…. ran the command from my local machine — cap production deploy:migrate

No joy!

checked my production.log in the following locations /appname/current/log and /appname/shared/log but nothing printed in those.

my /var//var/log/nginx/error.log produces this —

App 10656 stdout: Completed 500 Internal Server Error in 2ms
App 10656 stdout:
App 10656 stdout: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation «leads» does not exist
App 10656 stdout: LINE 5: WHERE a.attrelid = ‘»leads»‘::regclass
App 10656 stdout: ^
App 10656 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 10656 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 10656 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 10656 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 10656 stdout: WHERE a.attrelid = ‘»leads»‘::regclass
App 10656 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 10656 stdout: ORDER BY a.attnum
App 10656 stdout: ):
App 10656 stdout: app/controllers/pages_controller.rb:4:in index'
App 10656 stdout:
App 10656 stdout:
App 10656 stdout:
App 10656 stdout: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "leads" does not exist
App 10656 stdout: LINE 5: WHERE a.attrelid = '"leads"'::regclass
App 10656 stdout: ^
App 10656 stdout: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
App 10656 stdout: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
App 10656 stdout: FROM pg_attribute a LEFT JOIN pg_attrdef d
App 10656 stdout: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
App 10656 stdout: WHERE a.attrelid = '"leads"'::regclass
App 10656 stdout: AND a.attnum > 0 AND NOT a.attisdropped
App 10656 stdout: ORDER BY a.attnum
App 10656 stdout: ):
App 10656 stdout: app/controllers/pages_controller.rb:4:in
index’
App 10656 stdout:
App 10656 stdout:

I don’t want to give up (quitting is for quitters), but it seems as though heroku is a much easier option (for a newbie, but i don’t want to be a newbie forever!)… so any help is much appreciated

Gareth Gomersall

ok so i’ve retraced all my steps in the documents for setting up this VPS on digitalocean i couple of things i changed (not sure if it had anything to do with the cap production deploy — but they are as follows —

  • config/deploy/production.rb — i added the db part

set :stage, :production
server ‘46.101.34.7’, user: ‘deploy’, roles: %w{web app db}

  • Capfile — i added the rails/assets and rails/migrations

require ‘capistrano/rvm’
set :rvm_type, :user
set :rvm_ruby_version, ‘2.1.2-p95’

require ‘capistrano/bundler’
require ‘capistrano/rails’
require ‘capistrano/rails/assets’
require ‘capistrano/rails/migrations’

I’ve managed to get the site up… on http://46.101.34.7, but now it seems when i fill out my form it takes me to a 404 error

i’ve checked the production logs and it’s showing this —
I, [2015-04-03T11:56:52.639873 #30093] INFO — : Migrating to CreateLeads (20150327183722)
I, [2015-04-03T11:56:52.696744 #30093] INFO — : Migrating to CreateActiveAdminComments (20150330091152)
I, [2015-04-03T12:05:28.394905 #31343] INFO — : Started GET «/» for 81.138.164.169 at 2015-04-03 12:05:28 -0400
I, [2015-04-03T12:05:28.430379 #31343] INFO — : Processing by PagesController#index as HTML
I, [2015-04-03T12:05:28.519323 #31343] INFO — : Rendered layouts/_leadsform.html.erb (59.3ms)
I, [2015-04-03T12:05:28.519556 #31343] INFO — : Rendered pages/index.html.erb within layouts/application (62.4ms)
I, [2015-04-03T12:05:28.522403 #31343] INFO — : Rendered layouts/_header.html.erb (0.4ms)
I, [2015-04-03T12:05:28.523556 #31343] INFO — : Rendered layouts/_footer.html.erb (0.3ms)
I, [2015-04-03T12:05:28.524008 #31343] INFO — : Completed 200 OK in 93ms (Views: 71.2ms | ActiveRecord: 10.7ms)
I, [2015-04-03T12:09:18.540633 #31343] INFO — : Started GET «/» for 81.138.164.169 at 2015-04-03 12:09:18 -0400
I, [2015-04-03T12:09:18.549313 #31343] INFO — : Processing by PagesController#index as HTML
I, [2015-04-03T12:09:18.620812 #31343] INFO — : Rendered layouts/_leadsform.html.erb (61.1ms)
I, [2015-04-03T12:09:18.621050 #31343] INFO — : Rendered pages/index.html.erb within layouts/application (65.1ms)
I, [2015-04-03T12:09:18.623674 #31343] INFO — : Rendered layouts/_header.html.erb (0.5ms)
I, [2015-04-03T12:09:18.625089 #31343] INFO — : Rendered layouts/_footer.html.erb (0.5ms)
I, [2015-04-03T12:09:18.625501 #31343] INFO — : Completed 200 OK in 76ms (Views: 72.1ms | ActiveRecord: 0.0ms)

i’ve checked my app on local machine and works fine and redirects to root_path when completing the form, but on the server it tries to redirect to /leads
i’ve check code matches on both aswell and all seems legit…. strange… maybe James or Chris you know why this is?

Cheers
Gareth

shakycode

Let me look at your repo, give me a second.

shakycode

Gareth Gomersall

Hi James,

Thanks mate… apologies i turned it private, but i’ve made it public again… same link

Cheers

shakycode

Got it, I’m taking a look and your create action in leads looks right. I’d like to see what the production server is doing in realtime. If you want me to login to your droplet I’d be happy to. I’ll leave that up to you.

Gareth Gomersall

Yeah sure i don’t mind giving you access to the production server…
Do you want the deploy account or would you like me to setup a new user with sudo access?

Also do you want me to post those details direct on this thread?

shakycode

Do you have google chat? If so add me: jelinek at gmail dot com. Or you can email me directly. All I would need is the deploy credentials to take a look for you. I won’t need sudo.

Gareth Gomersall

awesome! thanks James, emailing you now….

shakycode

This is fixed. Your nginx configuration was wrong with the location directive and server name being set to local host in the same namespace as your FQDN. Your app now serves on 46.101.34.7 and the form submits properly and saves the record from what I can see. Next step is to setup an A record to point nibliapp.com to 46.101.34.7 and you’ll be done!

This was a simple fix but we were looking in the wrong spots, focusing too much on Rails and not enough on the infrastructure layer. :) It’s happened to me before too.

Let me know how I can be of assistance.

Gareth Gomersall

Hey James, that’s awesome!

I’ve also setup the a record now so it’s accessible via nibliapp.com

Thanks for all the help from you and Chris

Cheers
Gareth

shakycode

No problem, glad to see that your app is working now. Cheers!

Chris Oliver

Paulo Sousa

I’m Brazilian, sorry by my inglish… I’m using bitbucket.
In my case capistrano run all commands ok, but in server no created any file its all empty in folder suppose deploy my project.

Я пытаюсь использовать Capistrano (3.6) для развертывания своего приложения, но некоторые задачи не работают и ничего не возвращают.

Когда я выполняю cap production deploy, релиз правильно загружается с моего сервера git, установка пакета работает, и файлы связываются. Но некоторые задачи вроде «развертывание: миграция» пропускаются.

Я попытался выполнить отладку, создав эти две задачи, чтобы увидеть, что происходит во время развертывания:

namespace :deploy do
  before :migrate, :debug do
    puts "BEFORE"
  end

  after :migrate, :debug do
    puts "AFTER"
  end
end

И я увидел, что мои задачи правильно подключены сразу после установки пакета:

00:03 bundler:install
      01 ~/.rvm/bin/rvm 2.3.0 do bundle install --path /home/myuser/app/shared/bundle --without development test --deployment --qui…
    ✔ 01 [email protected] 2.380s
BEFORE
AFTER
00:05 deploy:symlink:release

Но, как вы можете видеть, между BEFORE и AFTER ничего не происходит, однако у меня есть ожидающие миграции.

И если я запускаю задачу в одиночку cap production deploy:migrate, ничего не выводится и ничего не происходит.

Когда я запускаю команду прямо на удаленном хосте RAILS_ENV=production bundle exec rails db:migrate, все в порядке!

То же самое для некоторых других задач, таких как puma: x, deploy: compile_asset и т. Д.

Моя среда

Я использую RVM (однопользовательский) с Ruby 2.3.0 (обе стороны). Мое приложение — Rails 5 (только api)

В моем Gemfile

gem 'capistrano', '~> 3.6.0'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-rvm', '~> 0.1.1'
gem 'capistrano3-puma', github: "seuros/capistrano-puma"

В моем файле Capfile

require 'capistrano/rvm'
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/puma'
require 'capistrano/puma/nginx'

Мой deploy.rb

set :rvm_ruby_version, '2.3.0'

set :application, 'myapp'
set :repo_url, '[email protected]:me/myapp.git'
set :deploy_to, '/home/myuser/app'

append :linked_files, 'config/database.yml', 'config/secrets.yml'
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets'

set :nginx_config_name, 'myapp'
set :nginx_server_name, 'myapp.mydomain.com'

Мой production.rb

server 'myhost', user: 'myuser', roles: %(app web db)

set :rails_env, 'production'

Спасибо за помощь!

Я впервые пытаюсь развернуть приложение Rails 5 в Amazon EC2 с помощью Capistrano, но все время получаю ошибку аутентификации. Я использую ключи SSH, которые находятся на сервере в каталоге /home/deploy/.shh. Ошибка следующая:

Matts-MacBook-Pro-2:byc-master matt$ cap production deploy

Thread:0x00007ff6731b0500@/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
1: from /Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/runners/parallel.rb:11:in block (2 levels) in execute'
    /Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute: Exception while executing as deploy@xx.xxx.xxx.xxx: Authentication failed for user deploy@xx.xxx.xxx.xxx (SSHKit::Runner::ExecuteError)
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@xx.xxx.xxx.xxx: Authentication failed for user deploy@xx.xxx.xxx.xxx

Caused by:
Net::SSH::AuthenticationFailed: Authentication failed for user deploy@xx.xxx.xxx.xxx

Tasks: TOP => rvm:check

Я перепробовал почти все решения этой проблемы, которые нашел здесь, и ничего не помогло. Я попытался запустить ssh-agent и запустить ssh-add. Это не сработало и дало мне ошибку, как показано ниже.

deploy@ip-xxx-xx-xx-xx:~/.ssh$ eval ssh-agent -s
SSH_AUTH_SOCK=/tmp/ssh-krRyWfHkGxEp/agent.7443; export SSH_AUTH_SOCK;
SSH_AGENT_PID=7444; export SSH_AGENT_PID;
echo Agent pid 7444;
deploy@ip-xxx-xx-xx-xx:~/.ssh$ ssh-add /home/deploy/.ssh

Could not open a connection to your authentication agent.

Если бы кто-нибудь мог мне помочь с этим, я не могу сказать вам, насколько я был бы признателен. Это заняло все мои выходные, и я не приблизился к решению проблемы.

Deploy.rb

lock "~> 3.10.1"

set :application, 'site'
set :repo_url, 'git@github.com:name/site.git' 
set :branch, :master
set :deploy_to, '/home/deploy/site'
set :pty, true
set :linked_files, %w{config/database.yml config/application.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
set :keep_releases, 5
set :rvm_type, :user
set :rvm_ruby_version, 'ruby-2.5.0'

set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 8]
set :puma_workers, 0
set :puma_worker_timeout, nil
set :puma_init_active_record, true
set :puma_preload_app, false

set :ssh_options, {
  user: "deploy",      
  keys: ["home/deploy/.ssh/id_rsa.pub"] 
}

namespace :deploy do
  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything
    end
  end
end

Database.yml

development: 
  adapter: postgresql
  encoding: unicode
  database: byc-master_db
  pool: 5
  username: [username]
  password: [password]
  timeout: 5000

production:
  adapter: postgresql
  encoding: unicode
  database: byc_production
  username: [username]
  password: [password]
  host: localhost
  port: 5432

Production.rb

server 'xx.xxx.xxx.xxx', user: 'deploy', roles: %w{web app db}

Capfile

require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

require "capistrano/rvm"
require "capistrano/bundler"
require "capistrano/rails/assets"
require "capistrano/rails/migrations"
require 'capistrano/puma'

Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

Я также запустил —trace при развертывании и получил сообщение

Matts-MacBook-Pro-2:byc-master matt$ cap production deploy --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rvm:hook (first_time)
** Execute rvm:hook
** Invoke rvm:check (first_time)
** Execute rvm:check
Thread:0x00007fb69e1416d8@/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
1: from /Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/runners/parallel.rb:11:in block (2 levels) in execute
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as deploy@xx.xxx.xxx.xxx:         Authentication failed for user deploy@xx.xxx.xxx.xxx    (SSHKit::Runner::ExecuteError)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@18.220.132.211: Authentication failed for user deploy@18.220.132.211
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'

Caused by:
Net::SSH::AuthenticationFailed: Authentication failed for user    deploy@xx.xxx.xxx.xxx
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/net-ssh-4.2.0/lib/net/ssh.rb:254:in `start'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/backends/connection_pool.rb:59:in `call'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/backends/connection_pool.rb:59:in `with'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/backends/netssh.rb:176:in `with_ssh'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/backends/netssh.rb:129:in `execute_command'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/backends/abstract.rb:141:in `block in    create_command_and_execute'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/backends/abstract.rb:141:in `tap'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/backends/abstract.rb:60:in `capture'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:9:in `block (3 levels) in <top (required)>'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/backends/abstract.rb:29:in `run'
/Users/matt/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.16.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => rvm:check

Я испытываю ошибку, пытаясь выполнить «развертывание производства шапки»,

    ERROR rbenv: 2.2.2 is not installed or not found in /usr/local/rbenv/versions/2.2.2

Это мой Gemfile:

    source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'

gem 'turbolinks'

gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do

gem 'byebug'

# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :development do
gem 'capistrano', '~> 3.4.0'
gem 'capistrano-rails', '~> 1.1.3'
gem 'capistrano-rbenv' #'~> 2.2.0'
gem 'capistrano-passenger'
end

Это мой Capfile:

    # Load DSL and set up stages
require 'capistrano/setup'

# Include default deployment tasks
require 'capistrano/deploy'

require 'capistrano/rbenv'
set :rbenv_type, :user # or :system, depends on your rbenv setup
set :rbenv_ruby, '2.2.0'

require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/passenger'

# Load custom tasks from 'lib/capistrano/tasks' if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

Это мой файл deploy.rb:

    # config valid only for current version of Capistrano
lock '3.4.0'

set :application, 'blank1'
set :repo_url, 'git@bitbucket.org:r2artene/blank1.git'

# setup rvm.
set :rbenv_type, :system
set :rbenv_ruby, '2.2.0'

# Default branch is :master
# ask :branch, 'git rev-parse --abbrev-ref HEAD'.chomp

# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/home/deploy/blank1'

# Default value for :scm is :git
# set :scm, :git

# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')

# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')

set :linked_files, %w{config/database.yml config/secrets.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5
# set :keep_releases, 5

namespace :deploy do

after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end

end

при команде «ruby -v» на локальной машине получается результат:

    ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]

при команде «ruby -v» на сервере deploment получается результат:

    ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]

Понравилась статья? Поделить с друзьями:
  • R6034 как исправить gta sa
  • Railgrade fatal error
  • R6030 crt not initialized как исправить windows 7
  • Raidcall ошибка flashctrl error
  • R6030 crt not initialized как исправить fallout