Rails控制台无法在服务器上运行

Erw*_*ers 25 ruby ssh rails-console ruby-on-rails-4

当我在Capistrano部署文件夹中的服务器上运行bundle exec rails console productionrails console production通过SSH时,Current我得到:

Usage:
     rails new APP_PATH [options]

Options:
    (...)
Run Code Online (Sandbox Code Playgroud)

解释开始一个新的应用程序.在当地它的工作原理.为什么我不能远程启动控制台?

小智 62

我假设您rails 4从版本3 更新到您的应用程序无法在bin目录中找到可执行文件.运行此命令以查看您的rails版本:

$ rails -v
Run Code Online (Sandbox Code Playgroud)

如果您的rails版本是4或更高版本,请尝试运行:

$ rake rails:update:bin
Run Code Online (Sandbox Code Playgroud)

来源:Rails 4发行说明

6.1值得注意的变化

  • 您的应用程序的可执行文件现在位于bin/目录中.运行rake rails:update:bin来获得bin/bundle,bin/railsbin/rake.

  • 这对我有帮助.非常感谢. (2认同)

Tro*_*roy 21

我正在使用capistrano进行部署,包括capistrano/bundler gem.由于./ bin目录在Rails 4中受版本控制,因此我们需要阻止Capistrano通过删除bin来在部署中链接它set :linked_dirs.

现在,为了防止bundler覆盖版本控制的binstub,我们可以添加一行set :bundle_binstubs, nil,这将阻止capistrano-bundler在运行bundle install时设置--binstubs选项.

我的config/deploy.rb文件现在有这些行:

# 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 :bundle_binstubs, nil
Run Code Online (Sandbox Code Playgroud)

注意行中缺少bin目录:linked_dirs.


max*_*gry 15

我有同样的问题,当你通过cap部署shared/binsymlink 时,结果是current/bin.

这对我有用:

  • rm current/bin
  • mkdir current/bin
  • rake rails:update:bin

这应该有所帮助,但它有点暂时的解决方案,我试图找出如何使cap不自动符号化current/bin.


Man*_*ava 7

如果是Rails 5.2

我必须通过在项目根目录下运行以下命令来删除bin目录。

 rm -rf bin
Run Code Online (Sandbox Code Playgroud)

然后我在项目根目录中运行了另一个命令:

 rake app:update:bin
Run Code Online (Sandbox Code Playgroud)

它会显示如下输出:

  create  bin
  create  bin/bundle
  create  bin/rails
  create  bin/rake
  create  bin/setup
  create  bin/update
  create  bin/yarn
Run Code Online (Sandbox Code Playgroud)

而已。