Skip to content

Conversation

tnir
Copy link
Contributor

@tnir tnir commented Oct 6, 2025

Motivation / Background

ActiveSupport depends on json gem, which has been This pull request makes a small update to the activesupport.gemspec file, adding a new dependency to the gem specification.

Fixes #55853

Detail

This pull request adds json as a dependency in the Gem::Specification for activesupport, ensuring that the gem explicitly requires the json library.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • [n/a] Tests are added or updated if you fix a bug or add a feature.
  • [n/a] CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@zzak
Copy link
Member

zzak commented Oct 6, 2025

Why does it need to be explicit?
I thought for default gems it was unnecessary because they are installed with ruby.

@byroot
Copy link
Member

byroot commented Oct 6, 2025

Yes, json comes with Ruby and there no plans for it to change, so no need to declare the dependency.

@byroot byroot closed this Oct 6, 2025
@tnir
Copy link
Contributor Author

tnir commented Oct 6, 2025

@zzak @byroot Sorry for missing the context. One case where this change is required is filed in #55853. What do you think?

@byroot
Copy link
Member

byroot commented Oct 6, 2025

Hum, I see.

I need to think a bit about this.

@byroot byroot reopened this Oct 6, 2025
@rafaelfranca rafaelfranca requested a review from byroot October 6, 2025 23:43
@Earlopain
Copy link
Contributor

json is hardly the only gem where this would apply. These are also used by rails in some place and have a gem available: cgi, date, digest, erb, fileutils, ipaddr, net-http, open-uri, pp, psych, shellwords, tempfile, time, tmpdir, weakref, zlib.

The gem is explicitly marked as group: :development so the text is not that unexpected to me. I guess a more realistic case would be some development dependency that itself depends on json. Probably it happens there as well. Still, I would rather not have the whole of stdgems listed by rails.

@matthewd
Copy link
Member

matthewd commented Oct 7, 2025

I would rather not have the whole of stdgems listed by rails

Me too, but it's my understanding that encouraging, if not forcing, that is an intended goal of stdgems work

@Earlopain
Copy link
Contributor

Well, if at one point json moves to be bundled like many other gems already have then there is really no way around doing something like that. But up to the point where that actually happens, I am heavily -1 on this. Feels like JavaScript.

I already heavily dislike the move to make many of the commonly used gems bundled and I know I am not the only one with that sentiment. Fine, move webrick to bundled, I see the point of that, but who thought it was a good idea to do the same with base64 that basically just wraps a single method call?? /rant over/

@byroot
Copy link
Member

byroot commented Oct 7, 2025

Yeah, that's a lot of dependencies. On one end, they already are so it just makes them explicit, but that "looks" weird.

But I also like the idea that by listing these dependencies we make it more likely that users will upgrade them.

So I'm warming up to the idea of listing json at least.

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
@byroot byroot force-pushed the tn-activesupport-json branch from 48276e5 to 4646cc4 Compare October 7, 2025 08:23
@byroot
Copy link
Member

byroot commented Oct 7, 2025

I force pushed the PR to update the Gemfile.lock.

@byroot byroot merged commit 2fd2695 into rails:main Oct 7, 2025
1 of 3 checks passed
@tnir
Copy link
Contributor Author

tnir commented Oct 7, 2025

I am not on listing every stdgem at all.

json gem has been unique in terms of the gems installed via rails new (see Gemfile.tt).

Per @Earlopain's list, we will have four gems as follows:

# grep -E '^    (cgi|date|digest|erb|fileutils|ipaddr|net-http|open-uri|pp|psych|shellwords|tempfile|time|tmpdir|weakref|zlib) ' < Gemfile.lock 
    date (3.4.1)
    erb (5.0.3)
    pp (0.6.3)
    psych (5.2.6)

json gem is the only gem on that gems in group: :development depend:

## date
rails -> actiontext -> action_text-trix -> railties -> irb -> rdoc -> psych -> date
importmap-rails -> railties -> irb -> rdoc -> psych -> date
rails -> railties -> irb -> rdoc -> psych -> date
solid_cable -> railties -> irb -> rdoc -> psych -> date
solid_cache -> railties -> irb -> rdoc -> psych -> date
solid_queue -> railties -> irb -> rdoc -> psych -> date
stimulus-rails -> railties -> irb -> rdoc -> psych -> date
turbo-rails -> railties -> irb -> rdoc -> psych -> date
web-console -> railties -> irb -> rdoc -> psych -> date
debug -> irb -> rdoc -> psych -> date
rails -> actionmailbox -> mail -> net-imap -> date
rails -> actionmailer -> mail -> net-imap -> date
## erb
rails -> actiontext -> action_text-trix -> railties -> irb -> rdoc -> erb
importmap-rails -> railties -> irb -> rdoc -> erb
rails -> railties -> irb -> rdoc -> erb
solid_cable -> railties -> irb -> rdoc -> erb
solid_cache -> railties -> irb -> rdoc -> erb
solid_queue -> railties -> irb -> rdoc -> erb
stimulus-rails -> railties -> irb -> rdoc -> erb
turbo-rails -> railties -> irb -> rdoc -> erb
web-console -> railties -> irb -> rdoc -> erb
debug -> irb -> rdoc -> erb
## pp
rails -> actiontext -> action_text-trix -> railties -> irb -> pp
importmap-rails -> railties -> irb -> pp
rails -> railties -> irb -> pp
solid_cable -> railties -> irb -> pp
solid_cache -> railties -> irb -> pp
solid_queue -> railties -> irb -> pp
stimulus-rails -> railties -> irb -> pp
turbo-rails -> railties -> irb -> pp
web-console -> railties -> irb -> pp
debug -> irb -> pp
## psych
rails -> actiontext -> action_text-trix -> railties -> irb -> rdoc -> psych
importmap-rails -> railties -> irb -> rdoc -> psych
rails -> railties -> irb -> rdoc -> psych
solid_cable -> railties -> irb -> rdoc -> psych
solid_cache -> railties -> irb -> rdoc -> psych
solid_queue -> railties -> irb -> rdoc -> psych
stimulus-rails -> railties -> irb -> rdoc -> psych
turbo-rails -> railties -> irb -> rdoc -> psych
web-console -> railties -> irb -> rdoc -> psych
debug -> irb -> rdoc -> psych
## json
rubocop-rails-omakase -> rubocop-performance -> rubocop -> json
rubocop-rails-omakase -> rubocop-rails -> rubocop -> json
rubocop-rails-omakase -> rubocop -> json
selenium-webdriver -> json

This is why I think we should only add the json gem as a dependency to activesupport.gemspec.

The used commands: echo -n date erb pp psych json | xargs -d ' ' -I {} sh -c "echo '## {}'; bundle why {}"

Full content of Gemfile.lock, generated with rails 8.1.0.beta1
# cat Gemfile.lock 
GEM
  remote: https://rubygems.org/
  specs:
    action_text-trix (2.1.15)
      railties
    actioncable (8.1.0.beta1)
      actionpack (= 8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
      zeitwerk (~> 2.6)
    actionmailbox (8.1.0.beta1)
      actionpack (= 8.1.0.beta1)
      activejob (= 8.1.0.beta1)
      activerecord (= 8.1.0.beta1)
      activestorage (= 8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
      mail (>= 2.8.0)
    actionmailer (8.1.0.beta1)
      actionpack (= 8.1.0.beta1)
      actionview (= 8.1.0.beta1)
      activejob (= 8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
      mail (>= 2.8.0)
      rails-dom-testing (~> 2.2)
    actionpack (8.1.0.beta1)
      actionview (= 8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
      nokogiri (>= 1.8.5)
      rack (>= 2.2.4)
      rack-session (>= 1.0.1)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.2)
      rails-html-sanitizer (~> 1.6)
      useragent (~> 0.16)
    actiontext (8.1.0.beta1)
      action_text-trix (~> 2.1.15)
      actionpack (= 8.1.0.beta1)
      activerecord (= 8.1.0.beta1)
      activestorage (= 8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
      globalid (>= 0.6.0)
      nokogiri (>= 1.8.5)
    actionview (8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
      builder (~> 3.1)
      erubi (~> 1.11)
      rails-dom-testing (~> 2.2)
      rails-html-sanitizer (~> 1.6)
    activejob (8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
      globalid (>= 0.3.6)
    activemodel (8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
    activerecord (8.1.0.beta1)
      activemodel (= 8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
      timeout (>= 0.4.0)
    activestorage (8.1.0.beta1)
      actionpack (= 8.1.0.beta1)
      activejob (= 8.1.0.beta1)
      activerecord (= 8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
      marcel (~> 1.0)
    activesupport (8.1.0.beta1)
      base64
      benchmark (>= 0.3)
      bigdecimal
      concurrent-ruby (~> 1.0, >= 1.3.1)
      connection_pool (>= 2.2.5)
      drb
      i18n (>= 1.6, < 2)
      logger (>= 1.4.2)
      minitest (>= 5.1)
      securerandom (>= 0.3)
      tzinfo (~> 2.0, >= 2.0.5)
      uri (>= 0.13.1)
    addressable (2.8.7)
      public_suffix (>= 2.0.2, < 7.0)
    ast (2.4.3)
    base64 (0.3.0)
    bcrypt_pbkdf (1.1.1)
    bcrypt_pbkdf (1.1.1-arm64-darwin)
    bcrypt_pbkdf (1.1.1-x86_64-darwin)
    benchmark (0.4.1)
    bigdecimal (3.3.0)
    bindex (0.8.1)
    bootsnap (1.18.6)
      msgpack (~> 1.2)
    brakeman (7.1.0)
      racc
    builder (3.3.0)
    bundler-audit (0.9.2)
      bundler (>= 1.2.0, < 3)
      thor (~> 1.0)
    capybara (3.40.0)
      addressable
      matrix
      mini_mime (>= 0.1.3)
      nokogiri (~> 1.11)
      rack (>= 1.6.0)
      rack-test (>= 0.6.3)
      regexp_parser (>= 1.5, < 3.0)
      xpath (~> 3.2)
    concurrent-ruby (1.3.5)
    connection_pool (2.5.4)
    crass (1.0.6)
    date (3.4.1)
    debug (1.11.0)
      irb (~> 1.10)
      reline (>= 0.3.8)
    dotenv (3.1.8)
    drb (2.2.3)
    ed25519 (1.4.0)
    erb (5.0.3)
    erubi (1.13.1)
    et-orbi (1.4.0)
      tzinfo
    fugit (1.11.2)
      et-orbi (~> 1, >= 1.2.11)
      raabro (~> 1.4)
    globalid (1.3.0)
      activesupport (>= 6.1)
    i18n (1.14.7)
      concurrent-ruby (~> 1.0)
    importmap-rails (2.2.2)
      actionpack (>= 6.0.0)
      activesupport (>= 6.0.0)
      railties (>= 6.0.0)
    io-console (0.8.1)
    irb (1.15.2)
      pp (>= 0.6.0)
      rdoc (>= 4.0.0)
      reline (>= 0.4.2)
    jbuilder (2.14.1)
      actionview (>= 7.0.0)
      activesupport (>= 7.0.0)
    json (2.13.2)
    kamal (2.7.0)
      activesupport (>= 7.0)
      base64 (~> 0.2)
      bcrypt_pbkdf (~> 1.0)
      concurrent-ruby (~> 1.2)
      dotenv (~> 3.1)
      ed25519 (~> 1.4)
      net-ssh (~> 7.3)
      sshkit (>= 1.23.0, < 2.0)
      thor (~> 1.3)
      zeitwerk (>= 2.6.18, < 3.0)
    language_server-protocol (3.17.0.5)
    lint_roller (1.1.0)
    logger (1.7.0)
    loofah (2.24.1)
      crass (~> 1.0.2)
      nokogiri (>= 1.12.0)
    mail (2.8.1)
      mini_mime (>= 0.1.1)
      net-imap
      net-pop
      net-smtp
    marcel (1.1.0)
    matrix (0.4.3)
    mini_mime (1.1.5)
    minitest (5.25.5)
    msgpack (1.8.0)
    net-imap (0.5.12)
      date
      net-protocol
    net-pop (0.1.2)
      net-protocol
    net-protocol (0.2.2)
      timeout
    net-scp (4.1.0)
      net-ssh (>= 2.6.5, < 8.0.0)
    net-sftp (4.0.0)
      net-ssh (>= 5.0.0, < 8.0.0)
    net-smtp (0.5.1)
      net-protocol
    net-ssh (7.3.0)
    nio4r (2.7.4)
    nokogiri (1.18.10-aarch64-linux-gnu)
      racc (~> 1.4)
    nokogiri (1.18.10-aarch64-linux-musl)
      racc (~> 1.4)
    nokogiri (1.18.10-arm-linux-gnu)
      racc (~> 1.4)
    nokogiri (1.18.10-arm-linux-musl)
      racc (~> 1.4)
    nokogiri (1.18.10-arm64-darwin)
      racc (~> 1.4)
    nokogiri (1.18.10-x86_64-darwin)
      racc (~> 1.4)
    nokogiri (1.18.10-x86_64-linux-gnu)
      racc (~> 1.4)
    nokogiri (1.18.10-x86_64-linux-musl)
      racc (~> 1.4)
    ostruct (0.6.3)
    parallel (1.27.0)
    parser (3.3.9.0)
      ast (~> 2.4.1)
      racc
    pp (0.6.3)
      prettyprint
    prettyprint (0.2.0)
    prism (1.4.0)
    propshaft (1.3.1)
      actionpack (>= 7.0.0)
      activesupport (>= 7.0.0)
      rack
    psych (5.2.6)
      date
      stringio
    public_suffix (6.0.2)
    puma (7.0.4)
      nio4r (~> 2.0)
    raabro (1.4.0)
    racc (1.8.1)
    rack (3.2.2)
    rack-session (2.1.1)
      base64 (>= 0.1.0)
      rack (>= 3.0.0)
    rack-test (2.2.0)
      rack (>= 1.3)
    rackup (2.2.1)
      rack (>= 3)
    rails (8.1.0.beta1)
      actioncable (= 8.1.0.beta1)
      actionmailbox (= 8.1.0.beta1)
      actionmailer (= 8.1.0.beta1)
      actionpack (= 8.1.0.beta1)
      actiontext (= 8.1.0.beta1)
      actionview (= 8.1.0.beta1)
      activejob (= 8.1.0.beta1)
      activemodel (= 8.1.0.beta1)
      activerecord (= 8.1.0.beta1)
      activestorage (= 8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
      bundler (>= 1.15.0)
      railties (= 8.1.0.beta1)
    rails-dom-testing (2.3.0)
      activesupport (>= 5.0.0)
      minitest
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.6.2)
      loofah (~> 2.21)
      nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
    railties (8.1.0.beta1)
      actionpack (= 8.1.0.beta1)
      activesupport (= 8.1.0.beta1)
      irb (~> 1.13)
      rackup (>= 1.0.0)
      rake (>= 12.2)
      thor (~> 1.0, >= 1.2.2)
      tsort (>= 0.2)
      zeitwerk (~> 2.6)
    rainbow (3.1.1)
    rake (13.3.0)
    rdoc (6.15.0)
      erb
      psych (>= 4.0.0)
      tsort
    regexp_parser (2.11.3)
    reline (0.6.2)
      io-console (~> 0.5)
    rexml (3.4.4)
    rubocop (1.81.1)
      json (~> 2.3)
      language_server-protocol (~> 3.17.0.2)
      lint_roller (~> 1.1.0)
      parallel (~> 1.10)
      parser (>= 3.3.0.2)
      rainbow (>= 2.2.2, < 4.0)
      regexp_parser (>= 2.9.3, < 3.0)
      rubocop-ast (>= 1.47.1, < 2.0)
      ruby-progressbar (~> 1.7)
      unicode-display_width (>= 2.4.0, < 4.0)
    rubocop-ast (1.47.1)
      parser (>= 3.3.7.2)
      prism (~> 1.4)
    rubocop-performance (1.26.0)
      lint_roller (~> 1.1)
      rubocop (>= 1.75.0, < 2.0)
      rubocop-ast (>= 1.44.0, < 2.0)
    rubocop-rails (2.33.4)
      activesupport (>= 4.2.0)
      lint_roller (~> 1.1)
      rack (>= 1.1)
      rubocop (>= 1.75.0, < 2.0)
      rubocop-ast (>= 1.44.0, < 2.0)
    rubocop-rails-omakase (1.1.0)
      rubocop (>= 1.72)
      rubocop-performance (>= 1.24)
      rubocop-rails (>= 2.30)
    ruby-progressbar (1.13.0)
    rubyzip (3.1.1)
    securerandom (0.4.1)
    selenium-webdriver (4.36.0)
      base64 (~> 0.2)
      json (<= 2.13.2)
      logger (~> 1.4)
      prism (~> 1.0, < 1.5)
      rexml (~> 3.2, >= 3.2.5)
      rubyzip (>= 1.2.2, < 4.0)
      websocket (~> 1.0)
    solid_cable (3.0.12)
      actioncable (>= 7.2)
      activejob (>= 7.2)
      activerecord (>= 7.2)
      railties (>= 7.2)
    solid_cache (1.0.7)
      activejob (>= 7.2)
      activerecord (>= 7.2)
      railties (>= 7.2)
    solid_queue (1.2.1)
      activejob (>= 7.1)
      activerecord (>= 7.1)
      concurrent-ruby (>= 1.3.1)
      fugit (~> 1.11.0)
      railties (>= 7.1)
      thor (>= 1.3.1)
    sqlite3 (2.7.4-aarch64-linux-gnu)
    sqlite3 (2.7.4-aarch64-linux-musl)
    sqlite3 (2.7.4-arm-linux-gnu)
    sqlite3 (2.7.4-arm-linux-musl)
    sqlite3 (2.7.4-arm64-darwin)
    sqlite3 (2.7.4-x86_64-darwin)
    sqlite3 (2.7.4-x86_64-linux-gnu)
    sqlite3 (2.7.4-x86_64-linux-musl)
    sshkit (1.24.0)
      base64
      logger
      net-scp (>= 1.1.2)
      net-sftp (>= 2.1.2)
      net-ssh (>= 2.8.0)
      ostruct
    stimulus-rails (1.3.4)
      railties (>= 6.0.0)
    stringio (3.1.7)
    thor (1.4.0)
    thruster (0.1.15)
    thruster (0.1.15-aarch64-linux)
    thruster (0.1.15-arm64-darwin)
    thruster (0.1.15-x86_64-darwin)
    thruster (0.1.15-x86_64-linux)
    timeout (0.4.3)
    tsort (0.2.0)
    turbo-rails (2.0.17)
      actionpack (>= 7.1.0)
      railties (>= 7.1.0)
    tzinfo (2.0.6)
      concurrent-ruby (~> 1.0)
    unicode-display_width (3.2.0)
      unicode-emoji (~> 4.1)
    unicode-emoji (4.1.0)
    uri (1.0.4)
    useragent (0.16.11)
    web-console (4.2.1)
      actionview (>= 6.0.0)
      activemodel (>= 6.0.0)
      bindex (>= 0.4.0)
      railties (>= 6.0.0)
    websocket (1.2.11)
    websocket-driver (0.8.0)
      base64
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.5)
    xpath (3.2.0)
      nokogiri (~> 1.8)
    zeitwerk (2.7.3)

PLATFORMS
  aarch64-linux-gnu
  aarch64-linux-musl
  arm-linux-gnu
  arm-linux-musl
  arm64-darwin
  x86_64-darwin
  x86_64-linux
  x86_64-linux-gnu
  x86_64-linux-musl

DEPENDENCIES
  bootsnap
  brakeman
  bundler-audit
  capybara
  debug
  importmap-rails
  jbuilder
  kamal
  propshaft
  puma (>= 5.0)
  rails (~> 8.1.0.beta1)
  rubocop-rails-omakase
  selenium-webdriver
  solid_cable
  solid_cache
  solid_queue
  sqlite3 (>= 2.1)
  stimulus-rails
  thruster
  turbo-rails
  tzinfo-data
  web-console

BUNDLED WITH
   2.5.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ActiveSupport: explicit dependency of json gem required

5 participants