【问题标题】:rails console on openshiftopenshift上的rails控制台
【发布时间】:2014-11-25 17:23:41
【问题描述】:

我将我的 rails 应用程序部署到 openshift,它运行良好,但我无法在生产服务器上运行“rails 控制台”。它给了我这个错误。我该如何解决这个问题?我尝试更新 ruby​​gems,但它也给出了权限被拒绝错误,我也无法做到。

rails c 错误:

Warning: You're using Rubygems 1.8.24 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
/opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/commands.rb:33:in `<module:Spring>'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/commands.rb:4:in `<top (required)>'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application.rb:77:in `preload'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application.rb:140:in `serve'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from -e:1:in `<main>'

rubygems 更新错误:

[appname.rhcloud.com repo]\> update_rubygems
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /opt/rh/ruby193/root/usr/local/share/ruby

【问题讨论】:

  • 您使用的命令是什么?我对 openshift 不太了解,但一些快速谷歌搜索建议以下 cmds
  • cd app-root/repo &amp;&amp; bundle exec rails console RAILS_ENV=production
  • 当我使用“rails c”命令时,它会忽略“c”并返回,就好像我只写“rails”一样。当写“bundle exec rails c”时,它给出了上面的错误。在第二部分“gem install ruby​​gems-update”工作正常并安装 gem。但随后“update_rubygems”给出了第二个错误。

标签: ruby-on-rails ruby console openshift


【解决方案1】:

我遇到了同样的问题,试试这样运行:

RAILS_ENV=production bundle exec rails console

同时确保在运行时在 ~/app-root/repo 中运行它

【讨论】:

  • 我试过了,没用。但是我今天使用 ruby​​-2.0 墨盒部署了我的应用程序,控制台可以正常工作。这时出现了其他问题。
【解决方案2】:

要更新 ruby​​gems:

gem update --system

如果这不能解决问题,请尝试 Spring 的建议并运行:

gem pristine --all

【讨论】:

  • gem update --system 在一行中执行了两个命令,最后给出了相同的错误。 gem pristine --all give this 将 gems 恢复到原始状态... ZenTest-4.8.1 的缓存 gem 未找到,正在尝试获取... 获取:ZenTest-4.8.1.gem (100%) 错误:执行 gem 时... (Gem::FilePermissionError) 您没有写入 /opt/rh/ruby193/root/usr/share/gems 目录的权限。这是什么写权限我怎么得到这个?人们说在 paas 上不需要 root 访问权限。
  • 那我的回答没有帮助,抱歉。这是所有权问题,而不是执行问题。您是否以管理员身份登录?糟糕的解决方案可能是 sudo gem update --system,但正确的方法是 chown ruby​​gems 所以你确实有权限,但我对 bash 不够好,无法引导你完成。
  • 我猜 redhat 不允许我以 root 身份登录,但我不确定我找不到它。没有人对此发表任何评论。 stackoverflow.com/questions/13296732/…每个人都说另一种方法。
【解决方案3】:

问题在于有多个捆绑可执行文件,而系统使用了错误的一个。

找到正确的bundle 可执行文件。就我而言,它位于~/.gem/bin/bundle

如果找不到,请安装gem install bundler

然后在~/app-root/repo中运行~/.gem/bin/bundle exec rails console production

【讨论】:

    【解决方案4】:

    在 OpenShift 上运行 4.1.4 Rails 盒式磁带时,我无法使用任何 gem installbundle exec 解决方案。我的解决方案是在app-root/repo 中运行RAILS_ENV=production bin/rails c

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多