【发布时间】:2015-03-30 08:25:27
【问题描述】:
有一个奇怪的问题需要帮助。
我正在尝试在生产服务器上启动 rails 控制台,它的行为就像 rails c 命令不存在一样。
FWIW,我作为 Rails 开发人员已经 4 年了,并且一直在大量其他服务器上执行此操作,没有任何问题。在这台服务器上,我可以毫无问题地删除、创建、迁移、播种数据库(使用 RAILS_ENV=production),并且该应用程序可以正常运行,没有任何问题。
设置:
Ubuntu 14.04(racksapce 第二代性能 1 服务器)
带乘客的 Nginx(我通常使用 Unicorn,但在我使用乘客部署的任何应用程序上都没有遇到过问题)
Ruby 2.1.5(使用 rvm)
Rails 4.1.7
Postgres
Capistrano 3(使用 rvm、迁移、资产预编译等扩展)
我的尝试:
cd 进入应用目录:
cd /home/deployer/app_name/current
加载 .rvmrc 并显示我在正确的 gemset 中,运行 bundle 只是为了好玩。
rails c production # (which usually works no problem)
bundle exec rails c production # (sometimes have to do this on older apps that do not have the newer capistrano 3 and rvm setup)
rails c production RAILS_ENV=production # (getting desperate here)
RAILS_ENV=production rails c production # (haha, surely this won't work, but out of options)
RAILS_ENV=production bundle exec rails console
每次,我都会收到一条暗示“rails c”不是有效命令的通知:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
..... yada yada, shows the rest of the rails options (oddly enough does not show 'c' or 'console' as options?)
再次,我已经登录了数百个 nginx/apache 上的生产控制台,这些控制台部署了 Unicorn 的新旧版本以及大部分旧版本的 Passenger。
这是我第一次收到此消息,并且控制台是唯一似乎坏了的东西 - 其他一切正常!该应用已上线并且运行良好。
我知道要建议的第一件事是我没有从 app 目录运行 rails c production - 我已经 cd 到正确的目录至少 10 次并手动加载了正确的 gemset,这不是问题。
无法弄清楚为什么它在开发中运行良好,但在生产中却不行。我知道不久前曾经有一个脚本目录(可能是 rails 2?)- 是否还有一个目录包含可能已损坏的 rails 的脚本命令?
有没有人遇到过这种情况或有什么建议?
我觉得我错过了什么。
【问题讨论】:
-
其他命令是否按预期工作? (
rails server...) rails -v 告诉你什么?是4.1.7吗? -
不,rails s 和 rails server 都显示我上面描述的相同的“Usage:”消息。 rails -v 返回:Rails 4.1.7
标签: ruby-on-rails ruby ruby-on-rails-4 console production