使用Gemfile中的环境变量部署到Heroku [英] Deploying to Heroku with environment variables in Gemfile

查看:223
本文介绍了使用Gemfile中的环境变量部署到Heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将Gemfile更新为 pry-byebug bye-bug 导致Rubymine崩溃一些同事。因为我们中有些人使用其他编辑器,所以我在Gemfile中添加了一个环境变量:



pre $ 如果ENV [USE_DEBUGGER ]
gempry-byebug
gembyebug
结束

这在我们的本地机器上运行良好,但部署到Heroku会导致以下错误: gist



我试着运行 bundle install 并提交一个新的 Gemfile.lock code>但这并没有改变。摆脱控制流声明或简单地删除宝石可以解决问题。在同一个提交中,我将所需的ruby版本提升到了2.2.0,这是值得的。



是有没有办法在 Gemfile 中使用条件语句,而不吹捧Heroku?

解决方案

好吧,在与RubyMine玩弄后,我意识到当需要 ing pry和任何其他相关的调试宝石时会发生问题。我设法通过更新我的Gemfile来解决这个问题:

 如果ENV [USE_DEBUGGER] 
gem pry-byebug
gembyebug
else
gempry-byebug,要求:false
gembyebug,要求:false
结束

我希望这可以帮助任何面临类似问题的人。


I've recently updated our Gemfile as pry-byebug and bye-bug were causing Rubymine to crash for some of my colleagues. Since there are some of us that use other editors I've added an environment variable to our Gemfile:

if ENV["USE_DEBUGGER"]
  gem "pry-byebug"
  gem "byebug"
end

This worked fine in our local machines but deploying to Heroku causes the following error: gist

I've tried running bundle install and committing a new Gemfile.lock but that changes nothing. Getting rid of the control flow declaration or simply removing the gems fixes the issue.It's worth nothing that in that same commit I bumped the required ruby version to 2.2.0

Is there any way to use conditional statements in the Gemfile without blowing Heroku up?

解决方案

Alright so after juggling with RubyMine I realised the problem occurs when requireing pry and any other related debugging gems. I managed to fix this by updating my Gemfile to the following:

  if ENV["USE_DEBUGGER"]
    gem "pry-byebug"
    gem "byebug"
  else
    gem "pry-byebug", require: false
    gem "byebug", require: false
  end

I hope this helps anybody facing a similar issue.

这篇关于使用Gemfile中的环境变量部署到Heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆