2014-09-30 77 views
4

我部署我的rails應用程序openshift它工作正常,但我不能在生產服務器上運行'軌道控制檯'。它給了我這個錯誤。我該如何解決這個問題?我試圖更新rubygems,但它也給權限拒絕錯誤,我也做不到。openshift軌道控制檯

導軌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 
+0

你正在使用什麼命令?我不太瞭解openshift,但一些快速的谷歌搜索建議以下cmds – bnjmn 2014-09-30 23:30:06

+0

'cd app-root/repo && bundle exec rails rails RAILS_ENV = production' – bnjmn 2014-09-30 23:30:50

+0

當我使用「rails c」命令時,它忽略了'c'並給出一個回報,就好像我只寫「鐵軌」一樣。當寫「bundle exec rails c」時,它會給出上面的錯誤。 第二部分「gem install ruby​​gems-update」工作正常,並安裝了寶石。但是然後「update_rubygems」給出了第二個錯誤。 – sayginburak 2014-09-30 23:34:39

回答

1

要更新的RubyGems:

gem update --system 

如果不解決這個問題,嘗試Spring的建議,運行:

gem pristine --all 
+0

gem update --system在一行中處理了兩個命令,並在最後給出了相同的錯誤。 寶石原始 - 所有這一切 恢復寶石原始狀態... 未找到ZenTest-4.8.1的緩存寶石,試圖取... 獲取:ZenTest-4.8.1.gem(100%) 錯誤:執行gem時(Gem :: FilePermissionError) 您沒有寫入/ opt/rh/ruby​​193/root/usr/share/gems目錄的權限。 這是什麼寫權限我怎麼得到這個?人們說paas上不需要root權限。 – sayginburak 2014-09-30 23:36:49

+0

然後我的回答沒有幫助,對不起。這是一個所有權問題,而不是執行。你是否以管理員身份登錄?蹩腳的解決方案可能是sudo gem update --system,但正確的方法是chown ruby​​gems,所以你有權限,但是我沒有用bash來引導你。 – beaglebets 2014-09-30 23:41:35

+0

我想redhat不允許我以root身份登錄,但我不確定我找不到它。沒有人對此說過任何話。 http://stackoverflow.com/questions/13296732/root-privileges-on-openshift每個人都說另一種方式來做到這一點。 – sayginburak 2014-09-30 23:51:35

3

我碰到了同樣的問題,嘗試這樣運行它:

RAILS_ENV=production bundle exec rails console 

還要確保您在〜/應用程序根/回購運行它,當你運行它

+1

我試過了,沒有工作。但是今天我用ruby-2.0墨盒部署了我的應用程序,控制檯工作。此時出現了其他問題。 – sayginburak 2014-10-01 19:26:21

+0

爲我工作,謝謝! – olyv 2017-06-04 16:56:10

1

的問題是有多個軟件包可執行文件,並且系統使用了錯誤的文件。

找到正確的bundle可執行文件。在我的情況下,它位於~/.gem/bin/bundle

如果找不到,請將它安裝到gem install bundler

然後運行~/.gem/bin/bundle exec rails console production~/app-root/repo

+1

這一個爲我工作。 – qnsi 2015-07-16 17:08:22

1

我無法得到任何gem installbundle exec解決方案的工作,同時運行在OpenShift的4.1.4 Rails的墨盒。我的解決方案在app-root/repo中運行RAILS_ENV=production bin/rails c