ydkn / capistrano-rails-console Goto Github PK
View Code? Open in Web Editor NEWCapistrano plugin which adds a remote rails console and dbconsole
Capistrano plugin which adds a remote rails console and dbconsole
Hi, I got this strange error. It seems similar to this issue #27
~/D/S/W/m/api ❯❯❯ bundle exec cap staging rails:console
00:00 rails:console
01 $HOME/.rbenv/bin/rbenv exec bundle exec rails console staging
/bin/bash: /Users/rizalmuthi/.rbenv/bin/rbenv: No such file or directory
Connection to 52.xxx.xxx.42 closed.
here is my setup.
Gemfile
...
group :development do
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'annotate'
gem 'capistrano', '~> 3.6'
gem 'capistrano-bundler', '~> 1.2'
gem 'capistrano-db-tasks', require: false
gem 'capistrano-rails', '~> 1.2'
gem 'capistrano-rails-console', '~> 2.1.1'
gem 'capistrano-rbenv'
gem 'capistrano-rbenv-install'
gem 'capistrano-sidekiq'
gem 'capistrano3-nginx'
gem 'capistrano3-puma', git: "git://github.com/seuros/capistrano-puma"
end
...
Capfile
# Load DSL and set up stages
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/scm/git'
install_plugin Capistrano::SCM::Git
require 'capistrano/rbenv'
require 'capistrano/rbenv_install'
require 'capistrano/bundler'
require 'capistrano/rails/migrations'
require 'capistrano-db-tasks'
require 'capistrano/sidekiq'
require 'capistrano/rails/console'
require 'whenever/capistrano'
require 'capistrano/puma'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
Let me know if you need the staging.rb and deploy.rb
just FYI, i didnt add anything special in staging.rb and deploy.rb
Thanks
And GREAT GEM 👍
So I just converted a repository that I use capistrano-rails-console on from a staging to production situation. As part of this we're using a hard linked ssh key, as opposed to inheriting one from the ssh-agent/user keys.
We just spent a couple of hours trying to figure out what was going on, but basically the gem is not accepting whatever is set under:
ssh_options, {..., keys: <code to produce keypath here>, ...}
What actually seems to be happening is that if the local capistrano users keychain can't get into a system (such as in our test) it tries to use this setting, but for some reason only trys to send whatever is the first character of the path as a key. So if you have:
keys: File.expand_path('~')<<"/.ssh/my_special_key"
Returns: Load key "/": Is a directory
But if you send: keys: 'config/my_special_key
then you get:
Warning: Identity file c not accessible: No such file or directory.
And if you send keys: './config/my_special_key
You get: Load key ".": bad permissions
In the first example it's reading the "/" in the Dir.file_expand and trying to use it as the key. In the second it's reading the 'c' in the string, where the line begins 'config' and in the third it's reading the first '.' in the string as the argument and calling bad permissions on it....
Very confusing. I took a look at the code for the gem but it seems that in version 1.0.2 a lot of the code was reworked, and I'm thinking perhaps the author has some insight as to what's happening here.
I have to say this is also pretty mysterious, because if you're using a config/deploy/.rb configuration that's also your users ssh key, it appears as if it's using the config to work... but it's not.
Hope this makes sense - truly baffling, any ideas?
I think that this is an issue with capistrano 3.4.0 but It will be better to track it here to. capistrano/capistrano#1401
Just getting this on starting puma or local rails console:
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'capistrano-rails-console'.
Gem Load Error is: undefined method `namespace' for main:Object
Backtrace for gem load error is:
/usr/local/lib/ruby/gems/2.3.0/gems/capistrano-rails-console-2.0.0/lib/capistrano/rails/console/tasks/remote.cap:1:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/capistrano-rails-console-2.0.0/lib/capistrano/rails/console/remote.rb:3:in `load'
/usr/local/lib/ruby/gems/2.3.0/gems/capistrano-rails-console-2.0.0/lib/capistrano/rails/console/remote.rb:3:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/capistrano-rails-console-2.0.0/lib/capistrano/rails/console.rb:2:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/capistrano-rails-console-2.0.0/lib/capistrano/rails/console.rb:2:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/capistrano-rails-console-2.0.0/lib/capistrano-rails-console.rb:1:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/capistrano-rails-console-2.0.0/lib/capistrano-rails-console.rb:1:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:91:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:86:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:86:in `block in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:75:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:75:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.13.1/lib/bundler.rb:106:in `require'
/Users/path/to/app/config/application.rb:18:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:82:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:82:in `preload'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:143:in `serve'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
I have used this gem and it runs flawlessly in several projects, but in one particular project I get this after running cap production rails:console
:
00:00 rails:console
01 ~/.rvm/bin/rvm ruby-2.3.1 do bundle exec rails console production
/bin/sh: 26: [[: not found
Loading production environment (Rails 5.0.0.1)
It works, but that /bin/sh: 26: [[: not found
line keeps nagging me.
SSHing into the server and running ~/.rvm/bin/rvm ruby-2.3.1 do bundle exec rails console production
directly in the current/bin
folder does not show the error
Any ideas what could be causing it?
How do I change the port?
Whenever I try to run rails c
locally (development env), I receive this error:
$ rails c
Could not find sshkit-interactive-0.2.0 in any of the sources
Run `bundle install` to install missing gems.
The culprit seems to be that you're overwriting the console task and forcing an interactive session. Any idea on how to fix? Removing the gem from the Gemfile
fixes the issue, of course.
Running Rails 5. Let me know if you need more info.
Console command doesnt it output the permission denied (public key), which i dont think is a case since rest of the capistrano tasks are working without any kind of issue
I followed the few instructions in the readme and came up with this error. Any suggestions to to get over with it?
I am new to Cap and not sure if the cap is even properly done. Deployment seems a little hackish to me. With some of your help I might be able to pinpoint and fix the issue.
textbook-valet|f12_capistrano_rails_console ⇒ cap staging rails:console
DEBUG [fa312e75] Running /usr/bin/env true on 162.243.148.96
DEBUG [fa312e75] Command: ( PATH=/usr/local/rvm/gems/ruby-2.0.0-p451/bin:/usr/local/rvm/gems/ruby-2.0.0-p451@global/bin:/usr/local/rvm/rubies/ruby-2.0.0-p451/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games /usr/bin/env true )
DEBUG [fa312e75] Finished in 3.916 seconds with exit status 0 (successful).
INFO [acd9d5ae] Running /usr/bin/env rails console staging on 162.243.148.96
DEBUG [acd9d5ae] Command: ( PATH=/usr/local/rvm/gems/ruby-2.0.0-p451/bin:/usr/local/rvm/gems/ruby-2.0.0-p451@global/bin:/usr/local/rvm/rubies/ruby-2.0.0-p451/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games /usr/bin/env rails console staging )
cap aborted!
undefined method `environment_string' for #<SSHKit::Command:0x00000002a4a540>
/home/ziyan/.rvm/gems/ruby-2.0.0-p451@textbook_valet_project/gems/capistrano-rails-console-0.5.2/lib/capistrano/rails/console/tasks/remote.cap:30:in `block (3 levels) in <top (required)>'
/home/ziyan/.rvm/gems/ruby-2.0.0-p451@textbook_valet_project/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/home/ziyan/.rvm/gems/ruby-2.0.0-p451@textbook_valet_project/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `run'
/home/ziyan/.rvm/gems/ruby-2.0.0-p451@textbook_valet_project/gems/sshkit-1.1.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => rails:console
(See full trace by running task with --trace)
After run cap production rails:console
DEBUG [2861c711] Running ~/.rvm/bin/rvm version as [email protected]
DEBUG [2861c711] Command: ~/.rvm/bin/rvm version
DEBUG [2861c711] rvm 1.26.11 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
DEBUG [2861c711] Finished in 1.110 seconds with exit status 0 (successful).
rvm 1.26.11 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
DEBUG [fd77c9e8] Running ~/.rvm/bin/rvm current as [email protected]
DEBUG [fd77c9e8] Command: ~/.rvm/bin/rvm current
DEBUG [fd77c9e8] ruby-2.2.2
DEBUG [fd77c9e8] Finished in 0.316 seconds with exit status 0 (successful).
ruby-2.2.2
DEBUG [95abef44] Running ~/.rvm/bin/rvm 2.2.2 do ruby --version as [email protected]
DEBUG [95abef44] Command: ~/.rvm/bin/rvm 2.2.2 do ruby --version
DEBUG [95abef44] ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
DEBUG [95abef44] Finished in 0.506 seconds with exit status 0 (successful).
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
DEBUG [cbe7b1bf] Running /usr/bin/env true as [email protected]
DEBUG [cbe7b1bf] Command: /usr/bin/env true
DEBUG [cbe7b1bf] Finished in 0.071 seconds with exit status 0 (successful).
INFO [76ebbc2f] Running ~/.rvm/bin/rvm 2.2.2 do bundle exec rails console production as [email protected]
DEBUG [76ebbc2f] Command: ~/.rvm/bin/rvm 2.2.2 do bundle exec rails console production
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /home/deploy/.rvm/rubies/ruby-2.2.2/bin/ruby
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
-B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install
-G, [--skip-git], [--no-skip-git] # Skip .gitignore file
[--skip-keeps], [--no-skip-keeps] # Skip source control .keep files
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
-S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files
[--skip-spring], [--no-skip-spring] # Don't install Spring application preloader
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
-j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library
# Default: jquery
-J, [--skip-javascript], [--no-skip-javascript] # Skip JavaScript files
[--dev], [--no-dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge], [--no-edge] # Setup the application with Gemfile pointing to Rails repository
[--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem
-T, [--skip-test-unit], [--no-skip-test-unit] # Skip Test::Unit files
[--rc=RC] # Path to file containing extra configuration options for rails command
[--no-rc], [--no-no-rc] # Skip loading of extra configuration options from .railsrc file
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend], [--no-pretend] # Run but do not make any changes
-q, [--quiet], [--no-quiet] # Suppress status output
-s, [--skip], [--no-skip] # Skip files that already exist
Rails options:
-h, [--help], [--no-help] # Show this help message and quit
-v, [--version], [--no-version] # Show Rails version number and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.
Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
Connection to x.x.x.x closed.
This error I have to all my servers on this provider, but I don't have this error on another provider.
What happened?
When I do "cap production rails:console" I get:
00:00 rails:console
01 $HOME/.rbenv/bin/rbenv exec bundle exec rails console production
/bin/bash: /Users/matt/.rbenv/bin/rbenv: No such file or directory
Connection to xxx.xxx.xxx.xxx closed.
The "No such file" error points to my local folder ... isn't that strange ?
Rails 5.2.0
Ruby 2.5.1
DEPRECATION WARNING: Passing the environment's name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -e option instead. (called from require at bin/rails:9)
What about an aliasing rails:c
to rails:console
just in the same way rails does? (and rails:db
already does as well)
Would be a nice addition, I think.
Hi, I installed the gem as gem 'capistrano-rails-console', require: false
and my task is
desc "Remote console" task :console do on roles(:app) do |h| run_interactively "bundle exec rails console #{fetch(:rails_env)}", h.user end end
And I'm getting the error ArgumentError: wrong number of arguments (given 1, expected 2)
How can I fix it?
Thanks!
I got an following error:
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: Rails binary not found!
Thank you for wonderful gem !
When I do "cap production rails:console" I get:
"ssh: connect to host XXXXX port 22: Connection timed out"
I am not using default port 22 of course, I set port number in my deploy/production.rb and deploy works well.
How and where should I put port number for this gem?
I get Don't know how to build task 'rails:console'
error.
When I tun with --trace, I get these. Any clue how I can fix this?
[myProject (master)]$ cap production rails:console --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rvm:hook (first_time)
** Invoke passenger:rvm:hook (first_time)
** Invoke passenger:test_which_passenger (first_time)
** Execute passenger:test_which_passenger
[email protected]'s password:
** Execute passenger:rvm:hook
** Execute rvm:hook
** Invoke rvm:check (first_time)
** Execute rvm:check
rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]
ruby-2.3.1
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
** Invoke bundler:map_bins (first_time)
** Invoke passenger:bundler:hook (first_time)
** Execute passenger:bundler:hook
** 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
cap aborted!
Don't know how to build task 'rails:console' (see --tasks)
/Users/user/.rvm/gems/ruby-2.3.1/gems/rake-12.0.0/lib/rake/task_manager.rb:58:in `[]'
/Users/user/.rvm/gems/ruby-2.3.1/gems/rake-12.0.0/lib/rake/application.rb:151:in `invoke_task'
/Users/user/.rvm/gems/ruby-2.3.1/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/user/.rvm/gems/ruby-2.3.1/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/Users/user/.rvm/gems/ruby-2.3.1/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/Users/user/.rvm/gems/ruby-2.3.1/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/Users/user/.rvm/gems/ruby-2.3.1/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/Users/user/.rvm/gems/ruby-2.3.1/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/Users/user/.rvm/gems/ruby-2.3.1/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/user/.rvm/gems/ruby-2.3.1/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/Users/user/.rvm/gems/ruby-2.3.1/gems/capistrano-3.8.0/lib/capistrano/application.rb:14:in `run'
/Users/user/.rvm/gems/ruby-2.3.1/gems/capistrano-3.8.0/bin/cap:3:in `<top (required)>'
/Users/user/.rvm/gems/ruby-2.3.1/bin/cap:23:in `load'
/Users/user/.rvm/gems/ruby-2.3.1/bin/cap:23:in `<main>'
It always connects me to port 22 even if I set the port other than 22.
# For example
set :ssh_options, {
port: "xxx",
user: "apps"
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.