In Linux, you can find the value of the
rails r "puts Rails.env"
You were right with
echo $RAILS_ENV. It is likely not set, so it is defaulting to development. This is done within the Rails codebase.
$ export RAILS_ENV=development $ echo $RAILS_ENV #=> development
In another console
# In a new window $ echo $RAILS_ENV $ rails runner "puts Rails.env" #=> development $ RAILS_ENV=test rails runner "puts Rails.env" #=> test
RAILS_ENV variable is set, to rails defaults to development
Here is the equivilent in Bash.
if [ -z "$RAILS_ENV" ]; then export RAILS_ENV="development"; fi echo $RAILS_ENV