Sinatra: Unable to activate dm-serializer-1.2.2, because json-2.0.2 conflicts with json (~> 1.6) (Gem::ConflictError)

Created on 10 May 2017  路  41Comments  路  Source: sinatra/sinatra

After Sinatra update to 2.0.0 version, my project fail to start.
Downgrade to sinatra 1.4.6 solved my issue.
Sinatra + Datamapper 1.2.0

How can i use SInatra 2.0.0 with Datamapper?

feedback

Most helpful comment

@lshep I see

If you create Gemfile with the following content:

# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem "sinatra"
gem "data_mapper"

and issue the commands

gem install bundler
bundle install

you will be able to run irb like this:

$ bundle exec irb
irb(main):001:0> require './main'
=> true

and main.rb like this:

bundle exec ruby main.rb

All 41 comments

Could you provide a stacktrace?

Help... Issue in my Proyect.

`# frozen_string_literal: true
source "https://rubygems.org"

gem "sinatra", "~> 1.4.6"

gem "json", "~> 1.6"`

My Gemfile. Help. I'm sorry for my english.

@smanezItec Could you send us a backtrace please? :bow:

Having the same issue.

/home/landen/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/specification.rb:2288:in raise_if_conflicts': Unable to activate dm-seri alizer-1.2.2, because json-2.0.2 conflicts with json (~> 1.6) (Gem::ConflictError) from /home/landen/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/specification.rb:1408:in activate' from /home/landen/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/specification.rb:1442:in block in activate_dependencies' from /home/landen/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/specification.rb:1428:in each' from /home/landen/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/specification.rb:1428:in activate_dependencies' from /home/landen/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/specification.rb:1410:in activate' from /home/landen/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems.rb:220:in rescue in try_activate' from /home/landen/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems.rb:213:in try_activate' from /home/landen/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:126:in rescue in require' from /home/landen/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in require' from main.rb:4:in <main>'

I have this error too!

Same here

Soluci貌n: utilizar Bundler con un archivo Gemfile

Supongamos que tu aplicaci贸n se llama MiApp, se encuentra en mi_app/app.rb y tiene el siguiente c贸digo:

require 'sinatra'

class MiApp < Sinatra::Base
get "/" do
"Hola mundo!"
end
end

Crea un archivo Gemfile, en el directorio ra铆z de tu aplicaci贸n, con el siguiente contenido:

source "https://rubygems.org"

```

gem 'sinatra', '1.4.8'
gem 'data_mapper', '1.2.0'
gem 'dm-sqlite-adapter', '1.2.0'
gem 'json', '~>1.6'
gem 'thin', '1.7.0'
gem 'slim', '3.0.8'
gem 'shotgun', '0.9.2'

    Crea un archivo configu.ru, tambi茅n en el directorio ra铆z de tu aplicaci贸n, con el siguiente contenido:

   ```
 require 'rubygems'
    require 'bundler'

    Bundler.require

    require './app'
    run MiApp

Donde app se refiere al nombre de tu archivo (i.e. app.rb) y MiApp al nombre de tu clase dentro de ese archivo.

Ejecuta shotgun utilizando bundle exec (para utilizar la versi贸n de rake adecuada):

`$ bundle exec shotgun`

Con esta configuraci贸n garantizas que tu aplicaci贸n utilice las gemas y versiones indicadas en el Gemfile, independientemente de las versiones que tengas instaladas en tu sistema.

I have the same problem >> any solutions yet?

Please remove the gem 'json', '...' from your Gemfile and try again :bow:

I got this error, and I don't have JSON in my Gemfile, but I have plenty of other stuff:

source 'https://rubygems.org'
gem 'sinatra'
gem 'data_mapper'
gem 'webrick'
gem 'dm-sqlite-adapter'
gem 'actionview'
gem 'sinatra-flash'
gem 'rubyzip'
gem 'httparty'
gem 'aws-sdk'
gem 'net-ldap'
gem 'net-ssh'
gem 'duo-api'

Apparently it is necessary to write this gem versions explicitly in the Gemfile and to use a config.ru to configure Rack. Smanezitec's solution with using Ruby 2.3.3 works fine for me:

My Gemfile:

source 'https://rubygems.org'

gem 'sinatra',            '1.4.8'
gem 'data_mapper',        '1.2.0'
gem 'dm-sqlite-adapter',  '1.2.0'
gem 'json',               '~>1.6'
gem 'shotgun',            '0.9.2'
gem 'slim',               '3.0.8'
gem 'thin',               '1.7.0'

my config.ru:

require 'rubygems'
require 'bundler'

Bundler.require

require './app'
run MiApp

my main.rb:

require 'sinatra'
require 'data_mapper'

# setup the database connection
DataMapper.setup(
  :default,
  ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/development.db"
)

# model definitions etc. placed here ...

# check the integrity of the models
DataMapper.finalize

class MiApp < Sinatra::Base
  get '/' do
    "Hello World!"
  end
end

Still an issue for me, used the above gemfile pretty much to the T and still didn't go

Ok, so then change the line

gem 'json', '~>1.6'

into

gem 'json', '1.8.6'

or uninstall json 2.1 if possible, and do a bundle install again.

Even with both JSONs uninstalled, different combinations, etc this still persists.

This issue still persist and Sinatra 2.0 can not be used with data_mapper, am I right?

I'm not sure this is even an issue, or how Sinatra would be at fault.

We don't even specify json as a dependency:
https://github.com/sinatra/sinatra/blob/master/sinatra.gemspec#L28-L31

It must be caused through some transitive dependency that is apart of your application.

If anyone can provide a Gemfile.lock which reproduces the issue, and stacktrace to go with it, we could probably figure out which one.

https://github.com/sinatra/sinatra/issues/1294#issuecomment-313166451 Don't have stack trace off-hand

@mike-bailey could you share your lockfile?

Given this is like a season old I don't still have the project around in that state, but my gemfile at the time was what was linked.

@zzak, thank you for wanting to help, my lockfile: https://hastebin.com/raw/otihuqujib (hastebin because it's pretty long)

I've also been having this exact issue! Has anyone yet found a resolution?

This issue still hasn't been resolved? I currently have the same problem.

@SirKeebz do you have a backtrace for this?

I'm still getting this same issue - I'm trying to use sinatra (2.0.1) and data_mapper (1.2.0) - has there been any resolution yet?

@lshep can you provide a Gemfile.lock and stack trace that reproduces the issue?

So I don't have a Gemfile.lock. I'm admittedly am a notice trying to learn and work thought examples. I am working through
Just Do It Part I and made it through no problem but now when I am working through Just Do It Part II. I haven't installed any specific versions of gems so I assume I am running all the latest. But when I run

> irb
irb(main):006:0> require './main'
Traceback (most recent call last):
       15: from /home/lori/.rbenv/versions/2.5.0/bin/irb:11:in `<main>'
       14: from (irb):6
       13: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
       12: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
       11: from /home/lori/learn-sinatra/JustDoIt/main.rb:2:in `<top (required)>'
       10: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
        9: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
        8: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems.rb:217:in `try_activate'
        7: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems.rb:224:in `rescue in try_activate'
        6: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/specification.rb:1439:in `activate'
        5: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/specification.rb:1457:in `activate_dependencies'
        4: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/specification.rb:1457:in `each'
        3: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/specification.rb:1471:in `block in activate_dependencies'
        2: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/specification.rb:1437:in `activate'
        1: from /home/lori/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/specification.rb:2324:in `raise_if_conflicts'
Gem::ConflictError (Unable to activate dm-serializer-1.2.2, because json-2.1.0 conflicts with json (~> 1.6))

@lshep I see

If you create Gemfile with the following content:

# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem "sinatra"
gem "data_mapper"

and issue the commands

gem install bundler
bundle install

you will be able to run irb like this:

$ bundle exec irb
irb(main):001:0> require './main'
=> true

and main.rb like this:

bundle exec ruby main.rb

I get the same error but the following is the Gemfile.lock that was produced:

JustDoIt$ cat Gemfile.lock 
GEM
  remote: https://rubygems.org/
  specs:
    addressable (2.5.2)
      public_suffix (>= 2.0.2, < 4.0)
    bcrypt (3.1.12)
    bcrypt-ruby (3.1.5)
      bcrypt (>= 3.1.3)
    data_mapper (1.2.0)
      dm-aggregates (~> 1.2.0)
      dm-constraints (~> 1.2.0)
      dm-core (~> 1.2.0)
      dm-migrations (~> 1.2.0)
      dm-serializer (~> 1.2.0)
      dm-timestamps (~> 1.2.0)
      dm-transactions (~> 1.2.0)
      dm-types (~> 1.2.0)
      dm-validations (~> 1.2.0)
    dm-aggregates (1.2.0)
      dm-core (~> 1.2.0)
    dm-constraints (1.2.0)
      dm-core (~> 1.2.0)
    dm-core (1.2.1)
      addressable (~> 2.3)
    dm-migrations (1.2.0)
      dm-core (~> 1.2.0)
    dm-serializer (1.2.2)
      dm-core (~> 1.2.0)
      fastercsv (~> 1.5)
      json (~> 1.6)
      json_pure (~> 1.6)
      multi_json (~> 1.0)
    dm-timestamps (1.2.0)
      dm-core (~> 1.2.0)
    dm-transactions (1.2.0)
      dm-core (~> 1.2.0)
    dm-types (1.2.2)
      bcrypt-ruby (~> 3.0)
      dm-core (~> 1.2.0)
      fastercsv (~> 1.5)
      json (~> 1.6)
      multi_json (~> 1.0)
      stringex (~> 1.4)
      uuidtools (~> 2.1)
    dm-validations (1.2.0)
      dm-core (~> 1.2.0)
    fastercsv (1.5.5)
    json (1.8.6)
    json_pure (1.8.6)
    multi_json (1.13.1)
    mustermann (1.0.2)
    public_suffix (3.0.2)
    rack (2.0.5)
    rack-protection (2.0.3)
      rack
    sinatra (2.0.3)
      mustermann (~> 1.0)
      rack (~> 2.0)
      rack-protection (= 2.0.3)
      tilt (~> 2.0)
    slim (3.0.9)
      temple (>= 0.7.6, < 0.9)
      tilt (>= 1.3.3, < 2.1)
    stringex (1.5.1)
    temple (0.8.0)
    tilt (2.0.8)
    uuidtools (2.1.5)

PLATFORMS
  ruby

DEPENDENCIES
  data_mapper
  sinatra
  slim

BUNDLED WITH
   1.16.2

I don't get any error with your Gemfile.lock, are you sure it is the same error? Please post all the commands and their output

Nevermind - I had to add the dm-sqlite-adapter to the Gemfile and re install. @dentarg thank you for your assistance!

For anyone who find this via google:

gem uninstall -Vax --force --no-abort-on-dependent json
# specify your desired json gem version in Gemfile
bundle install

On Ubuntu 18.04 running Sinatra 2.0.4 navigate to:
/usr/lib/ruby/gems/2.5.0/specifications/default

Run:
sudo rm json-2.1.0.gemspec

This completely cleared the error:
Unable to activate dm-types-1.2.2, because json-2.1.0 conflicts with json (~> 1.6) (Gem::ConflictError)

Apparently it is necessary to write this gem versions explicitly in the Gemfile and to use a config.ru to configure Rack. Smanezitec's solution with using Ruby 2.3.3 works fine for me:

My Gemfile:

source 'https://rubygems.org'

gem 'sinatra',            '1.4.8'
gem 'data_mapper',        '1.2.0'
gem 'dm-sqlite-adapter',  '1.2.0'
gem 'json',               '~>1.6'
gem 'shotgun',            '0.9.2'
gem 'slim',               '3.0.8'
gem 'thin',               '1.7.0'

my config.ru:

require 'rubygems'
require 'bundler'

Bundler.require

require './app'
run MiApp

my main.rb:

require 'sinatra'
require 'data_mapper'

# setup the database connection
DataMapper.setup(
  :default,
  ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/development.db"
)

# model definitions etc. placed here ...

# check the integrity of the models
DataMapper.finalize

class MiApp < Sinatra::Base
  get '/' do
    "Hello World!"
  end
end

How did you know which version numbers to use?

I had this problem w/ ruby 2.6.3 and I just reverted to ruby 2.3.7

Add require 'bundler/setup' to main.rb.

I solved this issue by:
gem 'json', '~> 1.6', '>= 1.6.7'

None of the solutions above worked for me. If i reverted to an earlier ruby version I had errors with openssl.

Are contributors still looking at this? Tried multiple things in this thread to limited/no avail. Gonna work on getting a Lockfile or something.

After trying to make myself useful, I've noticed data_mapper is archived, so presumably unmaintained. We're working on dropping DataMapper from our project at my company.

I recently found this out as well. Sequel is alive and well. A Google group with the author in there. It's quite good. It needs a Dash library though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aren55555 picture aren55555  路  7Comments

GCorbel picture GCorbel  路  7Comments

mediafinger picture mediafinger  路  7Comments

za3k picture za3k  路  5Comments

paulmenzel picture paulmenzel  路  4Comments