问题
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?
回答1:
Wrap the conditional in a group and try to BUNDLE_WITHOUT
on deployment. ref
group :byebug do
if ENV["USE_DEBUGGER"]
gem "pry-byebug"
gem "byebug"
end
end
heroku config:add BUNDLE_WITHOUT="byebug"
回答2:
Alright so after juggling with RubyMine I realised the problem occurs when require
ing 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.
来源:https://stackoverflow.com/questions/28172715/deploying-to-heroku-with-environment-variables-in-gemfile