2016-10-30 43 views
0

我想5應用程序推導軌Heroku的,我相信我也跟着Heroku的頁面上的說明: https://devcenter.heroku.com/articles/ruby-versionsHeroku的版本沒有設置,儘管下面的指南

$ ruby --version 
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu] 

$ cat Gemfile 
..... 
ruby "2.3.1" 

$ heroku run bash 
$ env | grep PATH 
PATH=/app/bin:/usr/local/bin:/usr/bin:/bin 

$ git push heroku master 
remote: Compressing source files... done. 
remote: Building source: 
remote: 
remote: -----> Ruby app detected 
remote: -----> Compiling Ruby/Rails 
remote: -----> Using Ruby version: ruby-2.2.4 

與錯誤終止:

remote: -----> Preparing app for Rails asset pipeline 
remote:  Running: rake assets:precompile 
remote:  rake aborted! 
remote:  NoMethodError: undefined method `symbolize_keys' for #  <String:0x007fac0655feb0> 
remote:   /tmp/build_39bfaebc9acd5a6bcb91a69f2b13c171/vendor/bundle/ruby/2.2.0/gems /railties-5.0.0.1/lib/rails/application.rb:393:in `secrets' 

我猜這是因爲它使用2.2而不是2.3。

/bin中的版本是1.9.3,所以萬一找不到,應該使用1.9.3而不是2.2.4。

上面的錯誤消息是在spickermann的幫助下修復的。從git跟蹤中移除secret.yml文件可以讓應用程序無錯地部署。

不過,錯的Ruby版本仍然存在,而Heroku的什末返回警告:

remote: ###### WARNING: 
remote:  You have not declared a Ruby version in your Gemfile. 
remote:  To set your Ruby version add this line to your Gemfile: 
remote:  ruby '2.2.4' 
remote:  # See https://devcenter.heroku.com/articles/ruby-  versions for more information. 

大約還有什麼可以做什麼建議?

謝謝!

+0

我忘了提及bin/bundle與指南中所述完全相同 – shaolintl

+0

$ bundler --version Bundler版本1.13.6 – shaolintl

回答

0

您的部署失敗,因爲您的config/secret.yml不符合預期的格式。該公司預計在生產環境中的嵌套哈希是這樣的:

production: 
    secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 

config/secrets.yml返回鍵production的字符串。因此部署失敗,您永遠無法部署新版本。

+0

謝謝spickermann,感謝您的回覆。 按照你的建議,我發現問題確實是在secret.yml文件中。 雖然原因有點不同。雖然格式很好,但它不應該被git跟蹤。顯然,被git跟蹤的secret.yml可能會導致發生此錯誤。 儘管如此,ruby的版本仍然是2.2.4。我甚至現在得到一個警告,我的Gemfile應該包含這個字符串。它包含2.3.1。是否可以忽略Gemfile? – shaolintl

+0

它包含哪個字符串?在'source'定義下的第二行頂部? – spickermann

相關問題