ydkn/capistrano-rails-console

Error: No such file or directory

Closed this issue · 10 comments

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 👍

ydkn commented

Hi,

I'm not using rbenv myself so it is a bit difficult to check what the real problem is. I think it has something to do with the following line https://github.com/capistrano/rbenv/blob/master/lib/capistrano/tasks/rbenv.rake#L40 which sets the rbenv path to $HOME/.rbenv but the HOME variable is evaluated locally.
I'm concerned if escaping $ will introduce other problem... so for now can you please try manually setting the rbenv path in your deploy.rb like this (not tested):

before 'rails:console', :set_remote_rbenv_path

task :set_remote_rbenv_path do
  set :rbenv_path, '/your/remote/rbenv/install/path'
end

@ydkn Thanks for the replied. I will try once i am free.
I forgot to provide the deploy.rb
here it is:

...
set :rbenv_type, :user
set :rbenv_map_bins, %w(rake gem bundle ruby rails sidekiq sidekiqctl)
set :rbenv_roles, :all
set :rbenv_ruby, File.read('.ruby-version').strip

set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')

set :pty, false
...

And also, how do i get the path from my remote? I mean, what sort of command should i run on my server? Thanks

ydkn commented

Without much knowledge regarding rbenv I can only guess... but as far as I understand it rbenv is a shell function so this is not as easy as if it were a binary. If you installed it yourself you may remember where you put it, if not try checking your profile, bashrc etc. (or equivalent for shell in case you're not using bash) you may also need to check the system files not only the user files.

I have tried to use what you suggested... still does not work..

I will try to check again and will update again
Thanks

I am reverting to gem version '1.0.2' which is working for me. I am also using rbenv.

I am receiving the same problem. When I run cap production rails:console it returns with this error:

00:00 rails:console 01 $HOME/.rbenv/bin/rbenv exec bundle exec rails console production deploy@xxx.xxx.xx.xx's password: /bin/bash: /Users/xxxx/.rbenv/bin/rbenv: No such file or directory Connection to xxx.xxx.xx.xx closed.

ydkn commented

afeld/sshkit-interactive#16 should fix this. This was released as Version 0.2.2 of sshkit-interactive - updating the gem should help. The PR introduced a new bug and the fix will be released soon (afeld/sshkit-interactive#18) - will update this issue accordingly.

ydkn commented

New version of sshkit-interactive is released. It would be great if any of the rbenv users can verify if it works now.

tkz79 commented

Verified for me... thank you!

Unfortunately I cant verify this since I am not working on that project anymore.
Thanks for the update @ydkn and @tkz79

I am happy to close this issue

Cheers