Skip to content

Ruby 4.0 - cannot load such file -- cgi/cookie #478

@schinery

Description

@schinery

Describe the bug

After upgrading my project to Ruby 4.0 I'm getting the following error when trying to boot the application.

❯ bundle exec rails c
/Users/stu/.rbenv/versions/4.0.0/lib/ruby/4.0.0/bundler/runtime.rb:71:in 'block (2 levels) in Bundler::Runtime#require': There was an error while trying to load the gem 'jira-ruby'. (Bundler::GemRequireError)
Gem Load Error is: cannot load such file -- cgi/cookie
Backtrace for gem load error is:
/Users/stu/.rbenv/versions/4.0.0/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require'
/Users/stu/.rbenv/versions/4.0.0/lib/ruby/4.0.0/bundled_gems.rb:60:in 'block (2 levels) in Kernel#replace_require'
/Users/stu/.rbenv/versions/4.0.0/lib/ruby/gems/4.0.0/gems/bootsnap-1.20.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in 'Kernel#require'
/Users/stu/.rbenv/versions/4.0.0/lib/ruby/gems/4.0.0/gems/zeitwerk-2.7.4/lib/zeitwerk/core_ext/kernel.rb:34:in 'Kernel#require'
/Users/stu/.rbenv/versions/4.0.0/lib/ruby/gems/4.0.0/gems/jira-ruby-3.0.0/lib/jira/http_client.rb:5:in '<main>'
/Users/stu/.rbenv/versions/4.0.0/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require'
# ...

This is because the cgi gem has been removed from the default Ruby gems in 4.0.

Dropping gem "cgi" into the project's Gemfile resolves the issue, so should the cgi gem now be a dependency of the jira-ruby gem?

To Reproduce

  • Try using this gem in a Ruby 4.0 project

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugBroken functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions