I'd like to conditionally set require:
in my Gemfile definition depending on the environment to work in conjunction with Bundler.require
. E.g. i'd like pry to be available in all environments but only have require: true
set in development and test. I'm currently doing something like this:
# make pry available for anyone who wants it
# but not automatically required
# e.g. in a console
gem 'pry', require: false
# automatically require pry
# for easy usage in tests
group :development, :test do
gem 'pry', require: true
end
Which works but results in a nice warning regarding a duplicate gem definition:
Your Gemfile lists the gem pry (>= 0) more than once. You should probably keep only one of them. While it's not a problem now, it could cause errors if you change the version of just one of them later.
Alternately, I can try to do something like this:
gem 'pry', require: ENV["RACK_ENV"] != "production"
but that feels much less declarative (and a little gross).
Edit:
To clarify,
- I want to be to have pry available via
Bundler.require
in the development and test environments - Be available in production (e.g. for use in a console) without being automatically required via
Bundler.require