2

Here's the relevant part of my gemspec:

spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 2.13.0"
spec.add_dependency "addressable"
spec.add_dependency "activesupport", "> 3.0.11"

Travis is failing for ruby 1.8.7 because it tries to install ActiveSupport 4.0, but Rails 4 does not support ruby 1.8.7. I'm afraid this might be an issue when users try to use the gem, even though it might be compatible with 1.8.7.

How can I fix this, while also keeping Rails 4 support? I don't want to use "~> 3.0.11" on my gemspec.

Pedro Nascimento
  • 11,336
  • 4
  • 30
  • 63

2 Answers2

0

I would suggest altering the contents of your gemspec to something like:

  if RUBY_VERSION < "1.9"
    spec.add_dependency "activesupport", "~> 3.0.11"
  else
    spec.add_dependency "activesupport", "> 3.0.11"
  end

Technically this does use the syntax you don't want, but it does so in a constrained way, and should not adversely impact users. In fact, it only affects the build process of the gem, and will make Travis use a restricted version of the dependency (as an end user would have to anyway) without placing any constraints on the gem in general - provided you package and release the gem whilst using a more recent Ruby.

Neil Slater
  • 25,116
  • 5
  • 71
  • 90
0

I'd suggest using the appraisal gem for this. It allows you to generate multiple Gemfiles for the project and then you can specify the gemfiles like this:

language: ruby
rvm:
  - 1.9.3
  - 2.0.0
gemfiles:
  - gemfile/3.0.gemfile
  - gemfile/4.0.gemfile
matrix:
  include:
    - rvm: 1.8.7
      gemfile: gemfile/3.0.gemfile

This will generate five builds:

  • 1.9.3 + 3.0
  • 2.0.0 + 3.0
  • 1.9.3 + 4.0
  • 2.0.0 + 4.0
  • 1.8.7 + 3.0

Hope something like this helps.

sarahhodne
  • 9,042
  • 2
  • 37
  • 44