Search code examples
ruby-on-rails-4rubygemsactiveadminformtasticsurveyor-gem

Unable to use surveyor gem along with already in use Active Admin gem because of formtastic gem version conflict


It is quite odd, I have come across an issue like this for the first time: from the looks of it, I have conflict that fromtastic for surveyor and activeadmin are trying to use different versions of the same gem, how do you handle such issues?

Bundler could not find compatible versions for gem "formtastic":
  In Gemfile:
    formtastic (~> 2.1.0) ruby

    activeadmin (>= 0) ruby depends on
      formtastic (2.3.0)

I looked more into it: And found this link on SO: Unable to use surveyor gem

I thought just changing the version in gemfile.lock might solve this, but it did not, the error I got now was: Bundler could not find compatible versions for gem "actionpack": In Gemfile: activeadmin (>= 0) ruby depends on formtastic (~> 2.1.0) ruby depends on actionpack (~> 3.0) ruby

rails (= 4.1.0) ruby depends on
  actionpack (4.1.0)

The changed gemfile.lock looks like: specs: activeadmin (1.0.0.pre) arbre (~> 1.0, >= 1.0.2) bourbon coffee-rails formtastic (~> 2.1.0) the command I had to run after making this change was:

Resolving dependencies...
You have requested:
  formtastic ~> 2.1.0

The bundle currently has formtastic locked at 2.3.1.
Try running `bundle update formtastic`

Solution

  • This error means that the versions surveyor and activeadmin you're trying to use together can't be used together — they have incompatible library requirements. (Surveyor wants formtastic in the range [2.1.0, 2.2.0); activeadmin will only work with [2.3.0, 2.3.0].)

    Modifying Gemfile.lock (not recommended) can't get around this because the dependency versions are defined by the gemspecs for the respective libraries. When each library is loaded, rubygems is going to load its dependencies using its specified version constraints (which is what you saw with the "You have requested..." error).

    Things to try:

    • Find different versions of surveyor and activeadmin which are compatible with each other. Bundler will try to do this if you loosen the version constraint for one or the other in your Gemfile. But it's possible that there is no such version that's also compatible with the other gems in your app (including Rails).

    • Fork either surveyor or activeadmin and change the formtastic dependency version. This may break things — they probably have specific version requirements for a reason — but it's worth trying.