Rails runner without spring

If you want to keep spring in general, you can temporarily disable spring for a single command by prefixing it with the DISABLE_SPRING environment variable:

DISABLE_SPRING=1 bin/rails runner -e production 'MyJob.perform_later'

This happens because you are using the spring gem and your bin folder has been "springified".

If you take a look in the bin/rails file you will see that spring is loaded before moving on with running whatever you requested from it.

You could "un-springify" your bin folder by running

bin/spring binstub --remove --all

This would mean of course that you opt out from all performance benefits that spring provides you. This should be OK for production environments. In fact, it is recommended that you do not install spring in your production environments [1].

So I suggest that you modify your Gemfile and place spring under the development group. In production you usually do something like:

bundle install --without development test

That way spring will never make it to your production servers. See also this related issue on Github.

--

1 . Spring project readme file