Rails throwing error incompatible library version gem nio4r-2.5.8

I am trying to run an existing project which is using ruby 3.1.0 and rails 7. So I installed ruby v3.1.0 using chruby and it was working fine yesterday when I ran rails s but it's failing today with errors

/Users/james/.gem/ruby/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require': incompatible library version - /Users/james/.gem/ruby/3.1.0/gems/nio4r-2.5.8/lib/nio4r_ext.bundle (LoadError)
from /Users/james/.gem/ruby/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/james/.gem/ruby/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/james/.gem/ruby/3.1.0/gems/nio4r-2.5.8/lib/nio.rb:42:in `<main>'
from /Users/james/.gem/ruby/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/james/.gem/ruby/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/james/.gem/ruby/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/james/.gem/ruby/3.1.0/gems/puma-5.6.4/lib/puma/reactor.rb:24:in `initialize'
from /Users/james/.gem/ruby/3.1.0/gems/puma-5.6.4/lib/puma/server.rb:242:in `new'
from /Users/james/.gem/ruby/3.1.0/gems/puma-5.6.4/lib/puma/server.rb:242:in `run'
from /Users/james/.gem/ruby/3.1.0/gems/puma-5.6.4/lib/puma/single.rb:53:in `run'
from /Users/james/.gem/ruby/3.1.0/gems/puma-5.6.4/lib/puma/launcher.rb:182:in `run'
from /Users/james/.gem/ruby/3.1.0/gems/puma-5.6.4/lib/rack/handler/puma.rb:72:in `run'
from /Users/james/.gem/ruby/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:327:in `start'
from /Users/james/.gem/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands/server/server_command.rb:38:in `start'
from /Users/james/.gem/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands/server/server_command.rb:143:in `block in perform'
from <internal:kernel>:90:in `tap'
from /Users/james/.gem/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands/server/server_command.rb:134:in `perform'
from /Users/james/.gem/ruby/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /Users/james/.gem/ruby/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/james/.gem/ruby/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /Users/james/.gem/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/command/base.rb:87:in `perform'
from /Users/james/.gem/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/command.rb:48:in `invoke'
from /Users/james/.gem/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands.rb:18:in `<main>'
from /Users/james/.gem/ruby/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/james/.gem/ruby/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from bin/rails:4:in `<main>'

The first row is talking about nio4r but there is no such gem in the Gemfile but it is listed in the Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (7.0.2.3)
      actionpack (= 7.0.2.3)
      activesupport (= 7.0.2.3)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
    ...
    nio4r (2.5.8)
    ...
    puma (5.6.4)
      nio4r (~> 2.0)
    ...

RUBY VERSION
    ruby 3.1.0p0
 
 BUNDLED WITH
    2.3.3

I couldn't find any related issue so I am kind of stuck here but is it related to puma?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum