In Linux, you can find the value of the
$PATH
echo $PATH
RAILS_ENV
RACK_ENV
echo RAILS_ENV
RAILS_ENV
echo $RAILS_ENV
env RAILS_ENV
env
RAILS_ENV
Rails.env
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
No 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