Skip to content

uninitialized constant JSON::Fragment from require 'json' #752

@ntkme

Description

@ntkme

The root cause is again the famous ruby/rubygems#6490.

$ gem --version
3.3.27

$ gem info json

*** LOCAL GEMS ***

json (2.10.1, 2.6.1)
    Author: Florian Frank
    Homepage: https://github.com/ruby/json
    License: Ruby
    Installed at (2.10.1): /usr/local/bundle
                 (2.6.1, default): /usr/local/lib/ruby/gems/3.1.0

    JSON Implementation for Ruby

$ /usr/local/bin/ruby -I/usr/local/lib/ruby/3.1.0 -r json -e ''
<internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require': uninitialized constant JSON::Fragment (NameError)
	from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/3.1.0/json/ext.rb:8:in `<module:Ext>'
	from /usr/local/lib/ruby/3.1.0/json/ext.rb:6:in `<module:JSON>'
	from /usr/local/lib/ruby/3.1.0/json/ext.rb:3:in `<top (required)>'
	from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/3.1.0/json.rb:579:in `<module:JSON>'
	from /usr/local/lib/ruby/3.1.0/json.rb:575:in `<top (required)>'
	from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'

This happened in my CI job where my gem has a Rakefile based extension, and the Rakefile has require 'json':

https://github.com/sass-contrib/sass-embedded-host-ruby/actions/runs/13320451344/job/37204292341

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions