# Fix "uninitialized constant Fixnum (NameError)" on Ruby 3.2 and later

Yes. An agent finds the Fixnum and Bignum lines, shows why the version check around them lets the error through, removes them, and runs the suite on a current Ruby.

[Run this on Rush](https://cloud.getrush.ai/run/fix-uninitialized-constant-fixnum/ruby/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the failing line and what surrounds it. In a caching gem like seamusabshere/lock_and_cache, `lib/lock_and_cache/key.rb` builds `ALLOWED_IN_KEYS`, the set of classes that may appear in a cache key as themselves (lines 44 to 52: `String`, `Symbol`, `Numeric`, `TrueClass`, `FalseClass`, `NilClass`, `Integer`, `Float`), and then at lines 54 to 58 reads `parts = ::RUBY_VERSION.split('.').map(&:to_i)` and `unless parts[0] >= 2 and parts[1] >= 4` appends `::Fixnum` and `::Bignum`. `extract_obj_id` at line 25 consults the set for every key part. The file is required by `lib/lock_and_cache.rb` at load, so the constant is evaluated the moment anyone requires the gem.

The check is the bug, and the agent says so with three runs. The condition compares the minor version on its own, so it is true for 2.4 and for 3.4 but false for 3.0 through 3.3. On Ruby 3.1, `require 'lock_and_cache'` prints `key.rb:56: warning: constant ::Fixnum is deprecated` and the same for `::Bignum` on line 57, and loads. On Ruby 3.3 it raises `uninitialized constant Fixnum (NameError)` at line 56 and nothing that requires the gem can start. On Ruby 3.4 it loads clean, because the minor number is 4 again. A maintainer who tests on 3.4 would never see it.

The fix is to delete the five lines. `Integer` is already in the set on line 50, and on every Ruby where the branch would run, an integer is an `Integer`, so the branch adds nothing a current interpreter needs. The agent then proves it against the gem's own suite, which needs a real Redis: `spec/spec_helper.rb` opens `Redis.new db: 3` for locks and `db: 4` for cache, so the agent starts `redis-server` in the sandbox, installs `redis`, `activesupport`, `rspec` and `thread` (the gemspec's development dependency `bundler ~> 1.6` makes a current `bundle install` stop and ask for Bundler 1.17.3 instead), and runs `rspec` on Ruby 3.3, where every example passes. The two `somebody already clicking` lines in that output come from the spec's own threads at `spec/lock_and_cache_spec.rb` line 97 and are expected.

It reports the rest without changing it: `.travis.yml` still lists Ruby 2.3.0 and 2.4.1, the gemspec has no `required_ruby_version`, and the `bundler ~> 1.6` development dependency is what stops `bundle install` on a current Ruby. Each is one line in the pull request for the maintainer to take or leave.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Our Ruby gem fails to load with \"uninitialized constant Fixnum (NameError)\" on Ruby 3.2 and later. Find every reference to Fixnum and Bignum, explain why any version check around them does not stop the error, and remove or replace them so the code loads on every Ruby from 2.4 up. Show the load on at least one Ruby that warns and one that raises. Run the full spec suite on a current Ruby, starting any service the specs need, and open a pull request with the output and anything else that blocks the gem on current Rubies.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that removes five lines from `lib/lock_and_cache/key.rb` and changes nothing else. The description shows the `require` on three Rubies (the warning on 3.1, the `NameError` on 3.3, the clean load on 3.4) with the version check explained, then the `rspec` run on Ruby 3.3 passing against a Redis the agent started, and lists the CI file, the missing `required_ruby_version` and the `bundler ~> 1.6` dependency as follow-ups.

A reviewer checks that `Integer` already covers what the removed lines added, that the suite really ran against Redis rather than being skipped, and decides whether to update the CI Ruby list in the same change.

## Run it on every Ruby version bump in a service's Dockerfile or .ruby-version

The error appears the first time an app boots on Ruby 3.2 or 3.3, so the trigger is the change that moves the Ruby version. An automation with a `github` trigger on `pull_request.opened` and `pull_request.synchronize` runs this prompt on each pull request that touches `.ruby-version`, `Gemfile` or the Dockerfile, with the event appended after the prompt, and pushes the fix when `bundle exec` fails to load.

For a fleet of services sharing an in-house gem, your server sends this request once per repository, each with its own UUID as `request_id` so a retry returns the run already started, and reads each `run.completed` webhook; a key starts at most `max_concurrent` runs at once and queues the rest.

## Why run it on Rush?

A version check that compares the minor number alone is exactly the kind of bug a laptop on the newest Ruby cannot see: it passes on 3.4 and fails on 3.3. In a Rush sandbox the agent runs the load on three interpreters and keeps each output, so the pull request explains the shape of the bug instead of just deleting a line.

The gem's specs need Redis, and a review that skips them proves nothing about cache keys. The agent starts the service, runs the whole suite on a Ruby where the gem could not even load before, and records the count.

## Frequently asked questions

### Why does it load on Ruby 3.4 but not on 3.3?

The guard reads `parts[0] >= 2 and parts[1] >= 4`, so it only looks at the minor number. On 3.4 the minor is 4 and the Fixnum lines are skipped; on 3.0 through 3.3 the minor is below 4, the branch runs, and from 3.2 the constant no longer exists. The fix removes the branch rather than repairing the comparison.

### Should the lines be replaced with Integer instead of deleted?

No. `Integer` is already in `ALLOWED_IN_KEYS` on line 50, so the branch was only ever adding aliases of a class the set already allowed. Deleting it leaves the behaviour on every supported Ruby exactly as it is on 3.4 today.

### Why did the agent install gems by hand instead of bundle install?

The gemspec declares a development dependency on `bundler ~> 1.6`, so a current `bundle install` stops and asks for Bundler 1.17.3. The agent installs the runtime and test gems directly, runs the specs, and lists the pin as a follow-up so the maintainer can decide how to modernise the gemspec.

### Do the specs really need Redis?

Yes. `spec/spec_helper.rb` connects to two Redis databases at load, so without a server every example errors before it runs. The agent starts `redis-server` in the sandbox and the pull request shows the full run against it.

## More Ruby jobs

- [Fix "cannot load such file -- net/smtp (LoadError)" on Ruby 3.1 and Later](https://getrush.ai/run/fix-cannot-load-such-file-net-smtp/ruby/)
- [Fix NoMethodError: Undefined Method exists? for File:Class on Ruby 3.2 and Later](https://getrush.ai/run/fix-file-exists-nomethoderror/ruby/)
- [Fix "Psych::DisallowedClass: Tried to load unspecified class" on Ruby 3.1 and later](https://getrush.ai/run/fix-psych-disallowedclass-tried-to-load-unspecified-class/ruby/)

## More jobs like this: Fix a bug from an alert

- [Fix "AttributeError: 'TestCase' object has no attribute 'assertEquals'" on Python 3.12](https://getrush.ai/run/fix-unittest-assertequals-attribute-error/unittest/)
- [Fix "AttributeError: module 'unittest' has no attribute 'makeSuite'" on Python 3.13](https://getrush.ai/run/fix-unittest-makesuite-attribute-error/unittest/)
- [Fix "TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"" in ts-node](https://getrush.ai/run/fix-unknown-file-extension-ts/ts-node/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
