1

I am trying to open rails console using Capistrano but its close the connection Following script i am using and open rails console

Code

namespace :rails do
  desc "Start a rails console, for now just with the primary server"
  task :c do
    on roles(:app), primary: true do |role|
      rails_env = fetch(:rails_env)
      execute_remote_command_with_input "#{bundle_cmd_with_rbenv} rails console #{rails_env}"
    end
  end

  def execute_remote_command_with_input(command)
    port = fetch(:port) || 22
    puts "opening a console on: #{host}...."
    cmd = "ssh -l #{fetch(:deploy_user)} #{host} -p #{port} -t 'cd #{deploy_to}/current && #{command}'"
    exec cmd
  end

  def bundle_cmd_with_rbenv
    puts "RBENV_VERSION=#{fetch(:rbenv_ruby)} RBENV_ROOT=#{fetch(:rbenv_path)}  #{File.join(fetch(:rbenv_path), '/bin/rbenv')} exec bundle exec"
    if fetch(:rbenv_ruby)
      "RBENV_VERSION=#{fetch(:rbenv_ruby)} RBENV_ROOT=#{fetch(:rbenv_path)}  #{File.join(fetch(:rbenv_path), '/bin/rbenv')} exec bundle exec"
    else
      "ruby "
    end
  end
end

Details

I am using this script to open rails console so many time ant its work but for the couple of month rails console opening script is fail and don't know what to do with this.

Output

RBENV_VERSION=2.1.2 RBENV_ROOT=/home/deployer/.rbenv  /home/deployer/.rbenv/bin/rbenv exec bundle exec
opening a console on:

Usage:
  rails new APP_PATH [options]

Connection to 45.55.142.39 closed.

Any Suggestion hot it will work

TayyabZahid
  • 187
  • 3
  • 15

1 Answers1

1

Something is wrong with your binstubs. There are two things you have to do.

1) in your deploy.rb:linked_dirs should not contain the bin directory

2) This should be in your deploy.rb:

set :bundle_binstubs, nil

and after that you may run on your local machine:

rake rails:update:bin

This will include the binstubs in your repo.

Let me know how it goes.

Saad Masood
  • 11,036
  • 9
  • 32
  • 40