-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RAILS_ENV environment variable causes __FILE__ to be (incorrectly) set to the absolute path of the file in Rails 5.2 #36550
Comments
Update: We discovered that we can work around the issue by removing |
Yes, bootsnap expand all paths to use absolute paths, so |
But why does it only do that when using |
Bootsnap, in the same way as Rails, follows some conventions. The conventions you are expecting are different of the bootsnap conventions. When the conventions don't work to you, you can configure, which is what I recommended above. |
Also, this line answer you why |
Although I would prefer this to be fixed to not change the behavior of how |
Isn't it already in the changelog as "Added bootsnap by default"? What bootsnap does and behaves is well documented in its README too. |
Just to make it clear, neither Rails or bootsnap change For the "why -e We could expand the CHANGELOG entry for bootsnap to include what it does so people understand its behavior without having to look to its README. I'm happy to merge a PR. |
__FILE__
is being set to the absolute path of the file when executed byrails runner
in Rails 5.2, but only when the environment is manipulated with theRAILS_ENV
environment variable. This will cause any script using theif $0 == __FILE__
idiom to not execute. Using a different method to set the rails environment (e.g.rails runner -e
produces the expected behavior).Steps to reproduce
rails new
DISABLE_SPRING=1 RAILS_ENV=production bin/rails runner_test.rb
Expected behavior
The output should look like the output to
DISABLE_SPRING=1 bin/rails runner -e production runner_test.rb
, which is:Actual behavior
But instead,
__FILE__
is set to the absolute path.System configuration
Rails version:
5.2.3
Ruby version:
Reproduced on:
The text was updated successfully, but these errors were encountered: