【问题标题】:Capistrano not opening rails consoleCapistrano 未打开导轨控制台
【发布时间】:2015-07-03 02:32:28
【问题描述】:

我正在尝试使用 Capistrano 打开 Rails 控制台,但它关闭了连接 以下脚本我正在使用并打开 rails 控制台

代码

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

详情

我使用这个脚本打开 Rails 控制台很多次,但在这几个月里,rails 控制台打开脚本失败了,不知道该怎么办。

输出

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.

任何热门的建议都会起作用

【问题讨论】:

标签: ruby-on-rails ruby capistrano3


【解决方案1】:

您的 binstub 有问题。 您必须做两件事。

1) 在您的deploy.rb:linked_dirs 中不应包含bin 目录

2) 这应该在你的deploy.rb

set :bundle_binstubs, nil

然后你可以在本地机器上运行:

rake rails:update:bin

这将包括你的 repo 中的 binstubs。

告诉我进展如何。

【讨论】:

  • 会有很大帮助的。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-05-08
  • 2020-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多