【问题标题】:Unable to access rails console无法访问 Rails 控制台
【发布时间】:2016-09-10 07:09:15
【问题描述】:

我已将我的应用程序部署到 openshift 上,一切正常,直到我尝试访问 rails 控制台。

ssh openshiftsshlogin
cd ~/app-root/repo/
rails c

当我运行上面的命令时,我得到了这个错误。

bash: rails: command not found

我的 Web 应用程序是开源的,这可能有助于诊断错误。 Link to the Github repository.

当我跑步时...

bundle exec rails c

我收到以下错误,

bundler: command not found: rails
Install missing gem executables with `bundle install`
/usr/lib/ruby/gems/1.8/gems/bundler-1.5.2/lib/bundler/friendly_errors.rb:10:in `with_friendly_errors': uninitialized constant Thor::AmbiguousTaskError (NameError)
from /usr/lib/ruby/gems/1.8/gems/bundler-1.5.2/bin/bundle:20
from /usr/bin/bundle:19:in `load'
from /usr/bin/bundle:19

我不相信我需要手动安装 rails gem,因为齿轮正在运行 rails 应用程序就好了。

【问题讨论】:

    标签: ruby-on-rails-4 rubygems openshift rails-console


    【解决方案1】:

    试试RAILS_ENV=production bundle exec rails console

    【讨论】:

    • 我在 /app-root/repo 中运行了这个并得到了这个错误。 “捆绑器:找不到命令:rails 使用bundle install /usr/lib/ruby/gems/1.8/gems/bundler-1.5.2/lib/bundler/friendly_errors.rb:10:in 安装缺少的gem可执行文件with_friendly_errors': uninitialized constant Thor::AmbiguousTaskError (NameError) from /usr/lib/ruby/gems/1.8/gems/bundler-1.5.2/bin/bundle:20 from /usr/bin/bundle:19:in load ' 来自 /usr/bin/bundle:19"
    • 为什么?为什么设置此环境变量有效?
    【解决方案2】:

    太奇怪了,我只是通过运行“gem install rails”解决了这个问题,即使我不需要这样做。因此,如果未来的人遇到此问题,请运行...

    gem install rails
    RAILS_ENV=production bundle exec rails console
    

    这应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 2019-07-29
      • 1970-01-01
      • 1970-01-01
      • 2013-06-23
      • 1970-01-01
      • 2020-06-04
      • 2021-10-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多