Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis gem 4+ incompatibility "Specified 'redis' for Action Cable pubsub adapter, but the gem is not loaded" #30527

Closed
cpg opened this issue Sep 5, 2017 · 17 comments

Comments

@cpg
Copy link
Contributor

cpg commented Sep 5, 2017

Steps to reproduce

Using ActionCable 5.1.3 with the redis gem upgraded from 3.3.3 to 4.0.0 and attempting to broadcast on a channel seems to yield this exception:

Specified 'redis' for Action Cable pubsub adapter, but the gem is not loaded. Add `gem 'redis'` to your Gemfile (and ensure its version is at the minimum required by Action Cable).

Going back to ~> 3.3 makes AC work again as expected.

Expected behavior

AC should work

Actual behavior

An exception is raised indicating the gem is not loaded, but it seems to be.

Going back to ~> 3.3 makes AC work again as expected.

System configuration

Rails version: 5.1.3

Ruby version: 2.4.1

@KeithP
Copy link
Contributor

KeithP commented Sep 11, 2017

We got this error too after bundle update. Might not be obvious to all how to diagnose from the error message - we did have gem 'redis' in our gemfile, just not the right version.

@InteNs
Copy link

InteNs commented Sep 21, 2017

same problem here, seems that AC doesn't have it's dependencies straight.

@rikkipitt
Copy link
Contributor

rikkipitt commented Sep 21, 2017

I'm getting this today too, shall investigate further.

@aldefouw
Copy link

Can confirm that this happened to me as well.

Rails Version 5.0.0.1.
Ruby Version 2.2.3

I tried running Redis 4.0 and received the error.

When I moved back to ~> 3.3 then everything was fine and web sockets worked.

@apai4
Copy link

apai4 commented Sep 28, 2017

I can also confirm that this issue persists in 5.1.4. As @rikkipitt discovered, the version constraint for the redis gem that actioncable is requesting is too strict:

Which causes this exception to be raised when using a 4.x version of the redis gem (4.0.0 was released August 25):

raise Gem::LoadError, "Specified '#{adapter}' for Action Cable pubsub adapter, but the gem is not loaded. Add `gem '#{e.name}'` to your Gemfile (and ensure its version is at the minimum required by Action Cable)."

It would also be helpful for debugging if the exception being raised mentioned the specific constraint that wasn't satisfied (which should be present in the exception being caught) instead of saying the minimum required version wasn't met.

I can start a PR, but some more testing may be required before the version constraint can be relaxed since this is a major version bump @maclover7 @matthewd

@matthewd
Copy link
Member

@jeremy is taking care of the bump in #30748, but I agree the current exception is hiding too much information. It'd be good to improve that, if anyone's up for it.

We should address the AR instance it was copied from at the same time:

raise Gem::LoadError, "Specified '#{spec[:adapter]}' for database adapter, but the gem is not loaded. Add `gem '#{e.name}'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord)."

@Senegal
Copy link

Senegal commented Oct 1, 2017

any updates?
I faced same issue on heroku.

versions:
ruby-2.4.0
rails: '~> 5.1.3'

but when I try to downgrade redis to 3.3.3, heroku reject my commit.

remote: Bundler Output: Warning: the running version of Bundler (1.15.2) is older than the
version that created the lockfile (1.16.0.pre.2). We suggest you upgrade to the latest version of Bundler by running gem install bundler --pre.
remote: You are trying to install in deployment mode after changing
remote: your Gemfile. Run bundle install elsewhere and add the
remote: updated Gemfile.lock to version control.
remote:
remote: The dependencies in your gemfile changed
remote:
remote: You have added to the Gemfile:
remote: * redis (= 3.3.3)
remote:
remote: You have deleted from the Gemfile:
remote: * redis (~> 3.0)
remote: !
remote: ! Failed to install gems via Bundler.
remote: !
remote: ! Push rejected, failed to compile Ruby app.

how can i fix it?

@aldefouw
Copy link

aldefouw commented Oct 2, 2017

@Senegal - You probably need to run bundle install on your LOCAL development machine and then commit those updates to your repository before you try deploying again.

When you run a bundle install locally what will happen is that your Gemfile.lock file will be updated to reflect the appropriate Redis version that you are referencing in your Gemfile.

I think Heroku is rejecting because your Gemfile and Gemfile.lock have versions that do not mesh.

If you fix that and then re-deploy, you should be good to go.

jonallured added a commit to jonallured/bearden that referenced this issue Oct 26, 2017
I was getting the exception documented here:

rails/rails#30527

Looks fixed but not yet deployed so I'm retreating to the older version
of the redis gem.

While I was at it, I also fixed an exception about not having the Popper
lib for Bootstrap.
jonallured added a commit to jonallured/bearden that referenced this issue Oct 26, 2017
I was getting the exception documented here:

rails/rails#30527

Looks fixed but not yet deployed so I'm retreating to the older version
of the redis gem.

While I was at it, I also fixed an exception about not having the Popper
lib for Bootstrap.
n-rodriguez pushed a commit to jbox-web/deploy-it that referenced this issue Nov 5, 2017
@Xosmond
Copy link

Xosmond commented Jan 16, 2018

Im experiencing the same problem! with Redis 4.0.1, I had to downgrade to 3.3.5

@novotarq
Copy link

I had the same problem - @Xosmond temporary(?) solution worked for me as well.

zdavis added a commit to ManifoldScholar/manifold that referenced this issue Jan 26, 2018
Action cable is not compatibile with v4 of the redis gem.

See rails/rails#30527
@wh1le
Copy link

wh1le commented Feb 9, 2018

Have the same problem, ruby - 2.4.0, rails - 5.0.4, had to set redis to ~> 3.2

@AnkIF
Copy link

AnkIF commented Feb 16, 2018

I had the same issue.
I solved it by updating my gems (bundle update). Not sure which gem exactly solved it.
Now I have: ruby 2.5.0, rails 5.1.5, redis 4.0.1, actioncable 5.1.5.
Perhaps this method is not suitable for everyone, but it worked for me.

@Xosmond
Copy link

Xosmond commented Feb 16, 2018

@AnkIF Looks like v5.1.5 was released 2 days ago.

@kimyu92
Copy link
Contributor

kimyu92 commented Apr 13, 2018

seems like it doesn't backport to rails 5.0.7 (ruby 2.4.4) still having the same problem with redis 4
cc @eileencodes

@eileencodes
Copy link
Member

I didn't backport 3789531 to 5-0-stable because the build wasn't failing with the error that 5-1-stable was failing with.

5.0 is only supported for security fixes now so we're likely not going to backport this to 5.0. Our recommendation is to upgrade to 5.1.

@techieroshan
Copy link

Same issue with Rails 5.0.5, Ruby 2.4

@nathan-eko
Copy link

If you can't upgrade to 5.1 because you don't have time to rewrite a ton of old Paperclip code then locking your Redis gem to 3.3.1 makes ActionCable's myopic dependency declaration happy. If you're running something else that truly demands a 4.x.x then the only practical solution seems to be vendorizing ActionCable and fixing it yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests