Closed philsturgeon closed 3 years ago
I've used install_if
before, even having to fix it in bundler to get it to work. I'll use an example from that to demonstrate a workaround.
In Gemfile:
if respond_to?(:install_if)
install_if -> { !ENV['DISPLAY'] && RUBY_PLATFORM =~ /linux/ } do
gem "headless"
end
end
Then in Appraisals, at the end of the file:
if !ENV['DISPLAY'] && RUBY_PLATFORM =~ /linux/
each do |spec|
spec.gem "headless"
end
end
Normal if
works for the appraisal evaluator, and since it doesn't respond to install_if
the guard in Gemfile works.
Note that #151 applies here as well, so if you're doing this trick then make sure to generate the appraisal gemfiles right before you use them, in the same context in which you're going to use them.
I've made a PR for this issue : https://github.com/thoughtbot/appraisal/pull/176
It seems like the BundlerDSL is missing install_if.
I'm working on a PR to typhoeus (https://github.com/typhoeus/typhoeus/pull/583) which uses a lot of if's in the Gemfile.
When I run
appraisal generate
it's running the conditions at the time and building thegemfiles/*
with whatever gems it should have based on my ruby version or my ENV vars. This is failing everything when it runs on travis.If appraisal could support install_if then it would evaluate when
bundle check --gemfile=gemfiles/foo || bundle check --gemfile=gemfiles/foo
is run instead.I'll try and get a PR done for this, but im 5 levels deep on this yak shave already.