undefined method `connect' for Redis:Class (NoMethodError)

Hi everyone !

I’m currently trying to get things working with the redis server and default docker image. I have redis server up and running on default port :
Redis server v=2.8.17 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=5b70b85861dcf95e

When I run the container with

 docker run --name foodsoft_prod -p 3000 -e SECRET_KEY_BASE='mYunBreAkaBleKEY15476147654145' -e DATABASE_URL='mysql2://root:foodsoft@172.17.0.2/foodsoftdb?encoding=utf8' -e REDIS_URL='redis://my.host:6379' -e RAILS_FORCE_SSL=false   -v /var/www/app_config.yml:/usr/src/app/config/app_config.yml:ro   foodcoops/foodsoft

I have this error message

/usr/src/app/vendor/bundle/ruby/2.3.0/gems/resque-1.27.4/lib/resque.rb:116:in `redis=': undefined method `connect' for Redis:Class (NoMethodError)

I understood it comes from updates in redis 4.0 that replaced an older method of connecting to redis-server and I’m aware people are working on it on github
https://github.com/foodcoops/foodsoft/issues/585

I just would like to know how to use the older verson of the gem : I tried ‘gem install redis --version 3.3.5’ without success.

Hi,

I’m trying to set the workarounds described in the github topic above : locking redis to version 3.3 or installing resque 2, but I can’t manage to find how, even googling for hours (truly).
I tried to put "gem ‘redis’, ‘~> 3.3’ # " in /usr/local/rvm/gems/ruby-2.4.2/gems/redis-3.3.5/Gemfile and then run the docker container, but it didn’t work.

I can’t find how to update resque to version 2. I can’t even find where that version exists. The latest version I found on the official site is from 2017.

Ok I’m sorry as I’m a beginner in docker, but I really need help here.

I managed to guess one must change the Gemfile of foodsoft itself to fix the issue concerning latest version of redis. Nevertheless the non-running foodsoft container is not accessible with docker exec or any other method I found. I guess one must use -v argument while running the container to change the Gemfile “on the fly”, but I ended up with this while trying :

Bundler::ProductionError: You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

If this is a development machine, remove the /usr/src/app/Gemfile freeze 
by running `bundle install --no-deployment`.

The list of sources changed
The dependencies in your gemfile changed

You have added to the Gemfile:
* source: https://github.com/carchrae/localize_input.git (at master)
* redis (~> 3.3)
* mime-types
* apivore
* hashie (~> 3.4.6)

You have deleted from the Gemfile:
* source: https://github.com/bennibu/localize_input.git (at master@5eb188d)

  /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/definition.rb:467:in `ensure_equivalent_gemfile_and_lockfile'
  /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/runtime.rb:13:in `setup'
  /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler.rb:107:in `setup'
  /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/setup.rb:20:in `<top (required)>'
  /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:59:in `require'
  /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:59:in `require'

I have two problems here :

  1. I don’t know how I can run bundle install inside a non-running container. I doubt it is possible.
  2. I didn’t delete anything from the Gemfile, only added ‘redis (~> 3.3)’. I double checked this. So why does the output say I deleted all that lines ?

Hi,

I wish I had the time to dive a bit more into this, but perhaps I can give some pointers.

If you want to change the source, you’d better use the docker development setup as explained in this doc. To use production setup to develop is not very handy, because it’s tuned for production use. The development setup (with docker-compose as explained) will also use a compatible version of redis as a docker container.

Docker containers are kind of readonly (you can modify it while it’s running, but all changes are lost when you start it again - this is intentional, for reproducability). So if you want to make changes, you’d generally create a new docker project with a Dockerfile, starting from the image you want to base yours on (foodcoops/foodsoft), then each command in the Dockerfile will be stored as a ‘layer’ of changes on top of the previous. That’s how you make changes persistent (like foodcoops.net’s foodsoft setup, or that of vokomokum).

If you just want to get foodsoft up and running with docker, I’d advise to run stock redis:3.2-alpine in a docker container. That avoids you having to change the Foodsoft image.

Hope this helps a bit.

Best,

  • Willem

Thank you, the working version number of redis is exactly what I wanted to know.

I made

docker pull redis:3.2-alpine
docker run redis:3.2-alpine
docker container ls -a
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                     PORTS               NAMES
b799a1d9be1b        foodcoops/foodsoft   "./docker-entrypoint…"   2 minutes ago       Exited (1) 2 minutes ago                       foodsoft_prod
9a965b299445        redis:3.2-alpine     "docker-entrypoint.s…"   8 minutes ago       Up 8 minutes               6379/tcp            unruffled_shannon
569f0715687c        mysql:5.5            "docker-entrypoint.s…"   2 months ago        Up 2 months                3306/tcp            foodsoft-mysql
1c3c62a1cbfc        foodcoops/foodsoft   "./docker-entrypoint…"   6 months ago        Exited (1) 6 months ago                        mystifying_heisenberg

But ended up with exact same error when trying to run foodsoft container…

I truly don’t know how I can have it running…

Up.