Project

General

Profile

Actions

Bug #14779

closed

Windows - Casing issues - __FILE__, __dir__

Bug #14779: Windows - Casing issues - __FILE__, __dir__

Added by MSP-Greg (Greg L) over 7 years ago. Updated over 7 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-05-21 trunk 63473) [x64-mingw32]
[ruby-core:87202]

Description

For an unknown time, an informational Appveyor repo I have (here) has shown default gems inconsistently. While doing some work in RubyGems, I came across the issue again. The issue went back to RbConfig, and the TOPDIR constant.

I added the following lines to RbConfig.rb

puts "__dir__                 #{__dir__}"
puts "File.dirname(__FILE__)  #{File.dirname(__FILE__)}"
puts "Dir.pwd                 #{Dir.pwd}"

Testing with 2.4.4, 2.5.1, and trunk (ruby 2.6.0dev (2018-05-21 trunk 63473) [x64-mingw32]), in all instances, Dir.pwd returned the correct casing, but __dir__ and File.dirname(__FILE__) did not.

Below is console from the three versions:

C:\Greg\ruby24-x64>ruby -e "puts RUBY_DESCRIPTION"
__dir__                 C:/Greg/ruby26-x64/lib/ruby/2.6.0/x64-mingw32
File.dirname(__FILE__)  C:/Greg/ruby26-x64/lib/ruby/2.6.0/x64-mingw32
Dir.pwd                 C:/Greg/ruby24-x64
ruby 2.6.0dev (2018-05-18 trunk 63464) [x64-mingw32]

C:\Greg\ruby25-x64>ruby -e "puts RUBY_DESCRIPTION"
__dir__                 C:/Greg/Ruby25-x64/lib/ruby/2.5.0/x64-mingw32
File.dirname(__FILE__)  C:/Greg/Ruby25-x64/lib/ruby/2.5.0/x64-mingw32
Dir.pwd                 C:/Greg/ruby25-x64
ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32]

C:\Greg\ruby26-x64>ruby -e "puts RUBY_DESCRIPTION"
__dir__                 C:/Greg/ruby26-x64/lib/ruby/2.6.0/x64-mingw32
File.dirname(__FILE__)  C:/Greg/ruby26-x64/lib/ruby/2.6.0/x64-mingw32
Dir.pwd                 C:/Greg/ruby26-x64
ruby 2.6.0dev (2018-05-21 trunk 63473) [x64-mingw32]

From the above, I thought the issue was just with 2.5.1, but I then renamed the trunk folder, and had the following:

C:\Greg\ruby26-x64>cd ..

C:\Greg>ren ruby26-x64 Ruby26-x64

C:\Greg>cd Ruby26-x64

C:\Greg\Ruby26-x64>ruby -e "puts RUBY_DESCRIPTION"
__dir__                 C:/Greg/ruby26-x64/lib/ruby/2.6.0/x64-mingw32
File.dirname(__FILE__)  C:/Greg/ruby26-x64/lib/ruby/2.6.0/x64-mingw32
Dir.pwd                 C:/Greg/Ruby26-x64
ruby 2.6.0dev (2018-05-21 trunk 63473) [x64-mingw32]

So, the issue seems to also affect trunk.

Thanks, Greg

Updated by MSP-Greg (Greg L) over 7 years ago Actions #1

  • Subject changed from Windows - Casing issues - __FILE to Windows - Casing issues - __FILE__, __dir__

Updated by MSP-Greg (Greg L) over 7 years ago Actions #2

  • ruby -v changed from trunk, 2.5.1, maybe 2.4.4 to ruby 2.6.0dev (2018-05-21 trunk 63473) [x64-mingw32]

Updated by MSP-Greg (Greg L) over 7 years ago Actions #3 [ruby-core:87203]

Sorry, just to be clear, the casing in question is the first letter of Ruby in the path.

Updated by usa (Usaku NAKAMURA) over 7 years ago Actions #4 [ruby-core:87204]

  • Status changed from Open to Rejected

__FILE__ (and __dir__) is derived from argv[0], or if it's not contain path information, derived from PATH environment variable.
Check your setting of PATH.

Updated by MSP-Greg (Greg L) over 7 years ago Actions #5 [ruby-core:87205]

usa (Usaku NAKAMURA) wrote:

__FILE__ (and __dir__) is derived from argv[0], or if it's not contain path information, derived from PATH environment variable.
Check your setting of PATH.

Please review my message. This has nothing to do with PATH. I noticed it when in RubyGems, Gem::BasicSpecification#default_gem? wasn't correct.

Please reopen.

Thank you, Greg

Updated by shyouhei (Shyouhei Urabe) over 7 years ago Actions #6 [ruby-core:87206]

MSP-Greg (Greg L) wrote:

Please review my message. This has nothing to do with PATH. I noticed it when in RubyGems, Gem::BasicSpecification#default_gem? wasn't correct.

?? I don't get it. You claim __FILE__ and Dir.getwd are inconsistent, no? The reason for the inconsistency was described by @usa (Usaku NAKAMURA).

Updated by MSP-Greg (Greg L) over 7 years ago Actions #7 [ruby-core:87207]

So RubyGems is comparing (via ==) a known path (based on RbConfig info) and the location of a gemspec file. One character is a different case, which (as mentioned above) is the R in Ruby.

I guess I'm missing something. The code generating the output shown above is contained in RbConfig.rb.

Not being a c type, am I to assume that this is a Windows issue due to its case-insensitive file system?

Updated by shyouhei (Shyouhei Urabe) over 7 years ago Actions #8 [ruby-core:87208]

MSP-Greg (Greg L) wrote:

I guess I'm missing something. The code generating the output shown above is contained in RbConfig.rb.

When your code (in this case rubygems) requires rbconfig, require 'rbconfig' infers the location of rbconfig.rb using the location of ruby.exe, which is (if not set from argv[0]) from PATH environment variable. And that bit is reflected to the value of __FILE__. rbconfig's TOPDIR is a cooked version of this information.

Got it? the capital 'R' is from your PATH, according to @usa's explanation.

Actions

Also available in: PDF Atom