# Use RAILS\_ENV=production in development mode to catch Rails syntax errors

DevFeed: [Use RAILS\_ENV=production in development mode to catch Rails syntax errors](<https://devfeed.tech/articles/a-drop-dead-stupid-rails-testing-trick-28267.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/rails/2020/03/19/a-drop-dead-stupid-rails-testing-trick.html>)

Author: Fuzzygroup

Published: 2020-03-19T00:00:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Rails](<https://devfeed.tech/topics/rails.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [ci](<https://devfeed.tech/topics/ci.md>), [Development](<https://devfeed.tech/topics/development.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>)

Tags: [ci](<https://devfeed.tech/tags/ci.md>), [development](<https://devfeed.tech/tags/development.md>), [production](<https://devfeed.tech/tags/production.md>), [rails](<https://devfeed.tech/tags/rails.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [run](<https://devfeed.tech/tags/run.md>), [rvm](<https://devfeed.tech/tags/rvm.md>), [server](<https://devfeed.tech/tags/server.md>), [syntax](<https://devfeed.tech/tags/syntax.md>), [testing](<https://devfeed.tech/tags/testing.md>), [trace](<https://devfeed.tech/tags/trace.md>)

## AI overview

This article presents a Rails debugging and testing workaround for projects without a robust test suite or CI environment. It recommends running the Rails server in development mode with RAILS_ENV=production so syntax errors are caught during startup.

## Source excerpt

This is an old school trick that you use when you don't have a robust test suite and / or a CI environment. When you run Rails in development mode it is VERY, VERY forgiving of little details like syntax errors - the type of thing that grind your web server to a hard stop. The trick is to use RAILS_ENV=production in development mode and that causes syntax errors to get caught: RAILS_ENV=production bundle exec rails s -p3169 Here's an example stack trace: 20: from /Users/sjohnson/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each' 19: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:61:in `block in run_initializers' 18: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in `run' 17: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in `instance_exec' 16: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/railties-6.0.2.1/lib/rails/application/finisher.rb:122:in `block in <module:Finisher>' 15: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:449:in `eager_load_all' 14: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:449:in `each' 13: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:338:in `eager_load' 12: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:338:in `synchronize' 11: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:346:in `block in eager_load' 10: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:682:in `ls' 9: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:682:in `foreach' 8: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:685:in `block in ls' 7: from /Users/sjohnson/.rvm/gems/ruby-2.7.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loa