Project

General

Profile

Bug #15664

File.executable returns incorrect results in Windows 10

Added by BoldRabbit (Bold Rabbit) 5 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:91822]

Description

Calling File.executable? in Windows 10 return false for a file with execute permissions set.


Files

RailsTest.PNG (108 KB) RailsTest.PNG ss of the error BoldRabbit (Bold Rabbit), 03/14/2019 12:30 AM
FilePerm.PNG (3.99 KB) FilePerm.PNG actual permissions reported by Windows BoldRabbit (Bold Rabbit), 03/14/2019 12:31 AM
file-executable-doc.patch (1.22 KB) file-executable-doc.patch jeremyevans0 (Jeremy Evans), 06/11/2019 07:06 PM

Associated revisions

Revision c8edf70c
Added by jeremyevans (Jeremy Evans) 2 months ago

Update documentation for File.executable{,_real}? to mention Windows issues

Fixes [Bug #15664]

History

Updated by jeremyevans0 (Jeremy Evans) 2 months ago

Unlike Unix, Windows doesn't support execute permissions separately. If the path is a regular file, Ruby currently uses file extensions to determine if a file is executable, and only considers the following extensions as executable: .bat, .cmd, .com, .exe. See https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L5598-L5602

I don't think this is fixable unless we want to make File.executable? an alias to File.readable? on Windows, and that would just result in the opposite issue, with File.executable? returning true for files that are just readable and not actually executable.

The documentation for File.executable and File.executable_real? does not currently reflect the issues on Windows. Attached is a documentation patch to explain the behavior. I plan to commit this in about a week unless I hear objections.

Updated by nobu (Nobuyoshi Nakada) 2 months ago

I agree on the documentation fix, but I guess that Gem.bin_path should return the proper stub file path in this case.

#3

Updated by jeremyevans (Jeremy Evans) 2 months ago

  • Status changed from Open to Closed

Applied in changeset git|c8edf70cd20b9ff72ebd1e9402a556089f6ff204.


Update documentation for File.executable{,_real}? to mention Windows issues

Fixes [Bug #15664]

Also available in: Atom PDF