Skip to content

Instantly share code, notes, and snippets.

@Fitzsimmons
Last active June 24, 2019 19:33
Show Gist options
  • Save Fitzsimmons/3aaab7e5718827f95dc4dfc6a00ef53a to your computer and use it in GitHub Desktop.
Save Fitzsimmons/3aaab7e5718827f95dc4dfc6a00ef53a to your computer and use it in GitHub Desktop.
__FILE__ is set to the absolute path in Rails 5.2 when RAILS_ENV is set to production
justinf@jakiro:/tmp/runner_problem
> DISABLE_SPRING=1 RAILS_ENV=production bin/rails runner runner_test.rb
Rails version: 5.2.3
Rails env: production
$0: runner_test.rb
__FILE__: /tmp/runner_problem/runner_test.rb
==================================
> DISABLE_SPRING=1 bin/rails runner -e production runner_test.rb
Rails version: 5.2.3
Rails env: production
$0: runner_test.rb
__FILE__: runner_test.rb
puts "Rails version: #{Rails.version}"
puts "Rails env: #{Rails.env}"
puts "$0: #{$0}"
puts "__FILE__: #{__FILE__}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment