Agile Web Development with Rails 7: Iteration F4 crashes (solved)

I’m working with Version B2.0 of the epub. After making the changes in Iteration F4, the app crashes and the console shows errors related to Redis. I dug through the provided sample code and determined the fix was as simple as updating the development section of the config/cable.yml file:

development:
  adapter: async

Nowhere in the book did I see anything that mentioned making that change.

Erik

That’s peculiar. If you generate a new project, it should look exactly that way. Try the following two commands to see what that file should look like when you first generate your application, and what it should look like at the end of iteration F4:

curl https://media.pragprog.com/titles/rails7/code/rails7/depot_a/config/cable.yml
curl https://media.pragprog.com/titles/rails7/code/rails7/depot_n/config/cable.yml

So the question isn’t why you needed to change this file at this point, but what caused this file to change for you before you got to this point.

Thanks for the quick reply, Sam.

I figured it out: Because I had redis installed locally with Homebrew, running the rails new generator included this output:

Switch development cable to use redis
        gsub  config/cable.yml

and the top of config/cable.yml reads as follows:

development:
  adapter: redis
  url: redis://localhost:6379/1

After removing my local version of redis, running rails new results in a config/cable.yml like the one in your sample code.

So while I doubt I won’t be the only person who runs into this issue, it’s likely not worth mentioning in the book.

Thanks again,
Erik

OK, I’ve verified that brew install redis on MacOS will cause config/cable.yml to use that adapter. And then I verified that all of the code in the book will work with that configuration, whether or not the redis service is started.

Very curious.

Weird… For me, when I have cable.yml set to use the redis adapter, it definitely crashes if I do not have redis running. But if I simply run redis-server alongside the Depot app, everything works. And then as soon as I kill theredis-server process, the Depot app crashes.

Anyhow, thanks again for getting me unstuck here.

Erik

This has been valuable. I’m now inclined to recommend installing redis and ensuring that the server is started.

I’ve updated the installation section to recommend installing redis and (for MacOS users) running the following command:

brew services start redis

At the end of section F4, I’ve added a recommendation to try redid-cli ping if redis is installed, and noted that redis can be avoided entirely during development by using the async adapter in config/cable.yml.

1 Like

:tada: Great to see the beta book process working