Bug #14144
closed__FILE__ displays wrong value for executables when run from project root w/Ruby 2.4.1
Description
This problem can be illustrated by using the attached tar file, or the Github repo at https://github.com/keithrbennett/underscore_file_test.
When Ruby version == 2.4.1
and
current directory is the project root of this project
and
the gem is built and installed
and
the executable is run from the gem without preceding it with 'ruby'
and
the executable is run without specifying a directory
(i.e. as 'underscore_file_test', not 'bin/underscore_file_test')
Then (FILE below should be FILE surrounded by double underscores)
__FILE__ => $PROJECT_ROOT/exe/underscore_file_test
instead of pointing to a directory in the GEM_PATH, something like:
__FILE__ => /Users/kbennett/.rvm/gems/ruby-2.4.1/bin/underscore_file_test
This error occurred with Ruby 2.4.1 but not:
- ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-darwin15.6.0]
- ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]
- ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
- jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.77-b03 on 1.8.0_77-b03 +jit [darwin-x86_64]
My development machine was a MacBookPro running MacOs Sierra. uname -a
output is:
- Darwin MacBook-Pro-KB-13.local 16.7.0 Darwin Kernel Version 16.7.0: Wed Oct 4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64 x86_64
Steps to Reproduce:¶
- Download or git clone the Github project tree, or the attached tarball.
- Change directory to the project root.
- Run:
clear; gem build *gemspec && gem install *gem && underscore_file_test
- Note the directory component of the output.
If you cd somewhere else, the output will be correct,
i.e. will be located in a GEM_PATH directory.
If you run the command from the project root using a different Ruby,
it may work. I have not tested this on versions later than 2.4.1.
Files