Running into problems when setting RAILS_ENV=production

We have a rails app that uses temporal which we are moving to production and whenever we set RAILS_ENV=production we are getting the following error:

RuntimeError: grpc cannot be used before and after forking unless the GRPC_ENABLE_FORK_SUPPORT env var is set to "1" and the platform supports it (linux only)
grpc-1.60.0-x86_64 (linux) src/ruby/lib/grpc/generic/client_stub.rb:49:in `new'
grpc-1.60.0-x86_64 (linux) src/ruby/lib/grpc/generic/client_stub.rb:49:in `setup_channel'
grpc-1.60.0-x86_64 (linux) src/ruby/lib/grpc/generic/client_stub.rb:104:in `initialize'
grpc-1.60.0-x86_64 (linux) src/ruby/lib/grpc/generic/service.rb:158:in `initialize'
temporal-ruby (3e0dae708ec0) lib/temporal/connection/grpc.rb:798:in `new'

And after setting GRPC_ENABLE_FORK_SUPPORT=1 we then get this:

RuntimeError: grpc is in a broken state: GRPC.prefork must be called before calling fork from a process using grpc
grpc-1.60.0-x86_64 (linux) src/ruby/lib/grpc/generic/client_stub.rb:49:in `new'
grpc-1.60.0-x86_64 (linux) src/ruby/lib/grpc/generic/client_stub.rb:49:in `setup_channel'
grpc-1.60.0-x86_64 (linux) src/ruby/lib/grpc/generic/client_stub.rb:104:in `initialize'
grpc-1.60.0-x86_64 (linux) src/ruby/lib/grpc/generic/service.rb:158:in `initialize'

Wondering if someone around could shed some light based on this errors.

RAILS_ENV

what does this change entail, as in does it load different config files, or preloads different env vars or similar? would maybe start looking into this if everything else is same.

Hey @pabss, did you ever figure this out? Running into the same issue and wondering if you can save me some time :slight_smile:

UPDATE: For anyone else looking, there’s an open issue here, and an open PR here.

Another update: The workaround in the issue and PR aren’t working for me. Wondering if anyone else is running into this and finding a solution.

@tihomir To answer your question: Setting RAILS_ENV does imply some config changes. In my case, we’re running one process in development, but multiple processes in production, which is why we’re not seeing the forking issue until we’re in production mode. (That’s a common setup, so I’m guessing that’s what’s going on with @pabss as well.)

Stumble to this while working on similar things. My understanding is gRPC only recently provide support for forking [ruby] experimental client side fork support by apolcyn · Pull Request #33430 · grpc/grpc · GitHub

My guess this is not yet supported by temporal client?