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

Problem with redis gem > 4.2 #58

Closed
mrship opened this issue Jun 12, 2020 · 2 comments
Closed

Problem with redis gem > 4.2 #58

mrship opened this issue Jun 12, 2020 · 2 comments

Comments

@mrship
Copy link

mrship commented Jun 12, 2020

Using the Redis gem > 4.2, we can't write anything to the session using redis-rack and a redis session.

Below is a repo-script. Using with 4.1.4 works fine; with 4.2 it throws an exception:

/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/redis-4.2.1/lib/redis.rb:836: warning: The called method `set' is defined here
ArgumentError: unknown keywords: :path, :domain, :expire_after, :secure, :httponly, :defer, :renew, :sidbits, :secure_random, :redis_server
	/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/redis-4.2.1/lib/redis.rb:836:in `set'
	/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/redis-store-1.8.2/lib/redis/store/interface.rb:9:in `set'
	/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/redis-store-1.8.2/lib/redis/store/ttl.rb:8:in `set'

As far as I can tell, this is because of the change under this commit to the redis gem that removed the options in favour of explicit keyword arguments.

We can fix our version of redis to 4.1.4 to get around this for now, but this does appear to be something that redis-store will need fixing for too.


#!/usr/bin/env ruby

require 'bundler/inline'

REDIS_VERSION = "4.1.4"
# REDIS_VERSION = "4.2.1" # boom

gemfile do
  source 'https://rubygems.org'
  ruby '2.7.1'

  gem "rack"
  gem "redis", REDIS_VERSION
  gem "redis-rack"
end

class Sesh
  def call(env)
    env['rack.session']['id'] = 1
    [200, {}, ["Using #{REDIS_VERSION}"]]
  end
end

handler = Rack::Builder.new do
  use Rack::Session::Redis
  run Sesh.new
end

run handler
@tubbo
Copy link
Contributor

tubbo commented Jun 12, 2020

I just merged redis-store/redis-store#333 which should have fixed a lot of these problems. Once the ruby-head fixes are merged in I'll do a release. To use this gem with redis-rack, add this to Gemfile:

gem 'redis-store', github: 'redis-store/redis-store'

@mrship
Copy link
Author

mrship commented Jun 12, 2020

Aha! Thanks for the review/fix.

@tubbo tubbo closed this as completed Jun 12, 2020
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

2 participants