Project

General

Profile

Actions

Bug #2669

closed

mkmf find_executable doesn't find .bat files

Added by rogerdpack (Roger Pack) about 14 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.2dev (2010-01-25 trunk 26409) [i386-mingw32]
Backport:
[ruby-core:27912]

Description

=begin
Dunno if this was discussed already...

require 'mkmf'
=> true
find_executable('rdebug')
checking for rdebug... no
=> nil
find_executable('rdebug.bat')
checking for rdebug.bat... yes
=> "E:\installs\ruby_trunk_installed\bin/rdebug.bat"

(to me that's a bug, since it can find .exe's but not .bat's)
=end

Actions #1

Updated by usa (Usaku NAKAMURA) about 14 years ago

  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

=begin
memo:
problem of File.executable?

I do not have the opinion now.

=end

Actions #2

Updated by hgs (Hugh Sasse) about 14 years ago

=begin
Under cygwin, I have lots of .bat files which are not executable (according to ls -l). Indeed, under Ruby 1.8, my rdoc.bat is not:

hgs@Q2P14HGS /bin
12:58:47$ ls -ld rdoc.bat
-rw-r--r-- 1 hgs None 141 Apr 27 2009 rdoc.bat

hgs@Q2P14HGS /bin
12:58:59$ wc !$
wc rdoc.bat
6 26 141 rdoc.bat

hgs@Q2P14HGS /bin
12:59:17$ more rdoc.bat
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "/usr/bin/rdoc" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*

hgs@Q2P14HGS /bin
12:59:23$ file rdoc.bat
rdoc.bat: MS-DOS batch file text

hgs@Q2P14HGS /bin
13:01:54$

In fact, most in /cygwin/bin are not executable
according to ls. And...

hgs@Q2P14HGS /bin
13:05:07$ irb
irb(main):001:0> File.executable?('/bin/rdoc.bat')
=> false
irb(main):002:0>

So we have one part of Ruby installing batch files to be executed, and another part saying they are not executable. True, they are not marked as executable according to the bits.
Does this mean we need another method of File, to distinguish these cases? If so, then we probably need to think about the Windows Scripting Host.
=end

Actions #3

Updated by luislavena (Luis Lavena) about 14 years ago

=begin
Neither cygwin or MSYS (which is based in cygwin) likes batch files, that is one of the reasons is not marked as executable.

A few patch levels ago for 1.8.6 and 1.9.1, Ruby didn't consider batch levels priority over extension-less executables. That was one of the issues when calling "rake" versus "rake.bat"

I've commented about this back in 2008 here:

http://blog.mmediasys.com/2008/04/24/contributions-speedup-and-less-quirks-for-us/

I believe mkmf needs to implement the same changes to match the behavior expressed and corrected in that ticket.

=end

Actions #4

Updated by luislavena (Luis Lavena) about 14 years ago

=begin
On Thu, Jan 28, 2010 at 5:33 PM, Roger Pack wrote:

Which ticket is it?

I don't remember, let me search my sent items and will comment again.

Luis Lavena
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

=end

Actions #5

Updated by luislavena (Luis Lavena) about 14 years ago

=begin
On Thu, Jan 28, 2010 at 5:33 PM, Roger Pack wrote:

Which ticket is it?

Found it:

http://rubyforge.org/tracker/?func=detail&aid=19733&group_id=426&atid=1698

--
Luis Lavena
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

=end

Actions #6

Updated by hgs (Hugh Sasse) about 14 years ago

=begin
On Fri, 29 Jan 2010, Luis Lavena wrote:

Issue #2669 has been updated by Luis Lavena.

Neither cygwin or MSYS (which is based in cygwin) likes batch files, that is one of the reasons is not marked as executable.

A few patch levels ago for 1.8.6 and 1.9.1, Ruby didn't consider batch levels priority over extension-less executables. That was one of the issues when calling "rake" versus "rake.bat"

I've commented about this back in 2008 here:

http://blog.mmediasys.com/2008/04/24/contributions-speedup-and-less-quirks-for-us/

I believe mkmf needs to implement the same changes to match the behavior expressed and corrected in that ticket.

I only see:

system('gem') vs system('gem.bat')

Was annoying needed to patch every Rakefile or Ruby script that
called gem or rake or any other tool installed via RubyGems. Turns
out that wasn.t a Windows fault, but some faulty logic in the
Windows version of Ruby when dealing with system() calls.

Thanks to Nobuyoshi Nakada, 1.8 branch includes this fix, which
solves a few things we discussed on rubyinstaller-devel mailing
list to ease the need of tweaking the environment for MinGW.

without any links to a ticket, but there is code in the thread
linked to under "discussed"
http://rubyforge.org/pipermail/rubyinstaller-devel/2008-April/000288.html
and the last fully formed code seems to be here:
http://rubyforge.org/pipermail/rubyinstaller-devel/2008-April/000298.html
in which a batch file wraps an invocation of ruby, in a rather clever
way.

I'm probably being slow, but I don't see how that helps ruby find the
wanted batch file, when it is looking for "things it can execute,
notwithstanding that the permissions bit(s) for execution is(are) off".

I'm not certain about the mechanisms in this next paragraph, but:

I think the above fixes the problem that windows looks for files with
certain extensions as executables, and not finding them if they don't
have an extension. I think this #2669 wants ruby to find the .bat
files as if they were executable, because that's what windows does.
(Or seems to, in my experience. File associations.)

So if we say "make" to windows, provided the paths are right,
windows would find a make.bat, but if we say make to ruby, ruby
would miss it because it has no execute bit.

Or have I now confused myself as well as everyone else?

     Hugh

=end

Actions #7

Updated by luislavena (Luis Lavena) about 14 years ago

=begin
On Thu, Jan 28, 2010 at 6:02 PM, Hugh Sasse wrote:

On Fri, 29 Jan 2010, Luis Lavena wrote:

Issue #2669 has been updated by Luis Lavena.

Neither cygwin or MSYS (which is based in cygwin) likes batch files, that is one of the reasons is not marked as executable.

A few patch levels ago for 1.8.6 and 1.9.1, Ruby didn't consider batch levels priority over extension-less executables. That was one of the issues when calling "rake" versus "rake.bat"

I've commented about this back in 2008 here:

http://blog.mmediasys.com/2008/04/24/contributions-speedup-and-less-quirks-for-us/

I believe mkmf needs to implement the same changes to match the behavior expressed and corrected in that ticket.

I only see:

 system('gem') vs system('gem.bat')

 Was annoying needed to patch every Rakefile or Ruby script that
 called gem or rake or any other tool installed via RubyGems. Turns
 out that wasn.t a Windows fault, but some faulty logic in the
 Windows version of Ruby when dealing with system() calls.

 Thanks to Nobuyoshi Nakada, 1.8 branch includes this fix, which
 solves a few things we discussed on rubyinstaller-devel mailing
 list to ease the need of tweaking the environment for MinGW.

without any links to a ticket, but there is code in the thread
linked to under "discussed"
http://rubyforge.org/pipermail/rubyinstaller-devel/2008-April/000288.html
and the last fully formed code seems to be here:
http://rubyforge.org/pipermail/rubyinstaller-devel/2008-April/000298.html
in which a batch file wraps an invocation of ruby, in a rather clever
way.

I'm probably being slow, but I don't see how that helps ruby find the
wanted batch file, when it is looking for "things it can execute,
notwithstanding that the permissions bit(s) for execution is(are) off".

I'm not certain about the mechanisms in this next paragraph, but:

I think the above fixes the problem that windows looks for files with
certain extensions as executables, and not finding them if they don't
have an extension.    I think this #2669 wants ruby to find the .bat
files as if they were executable, because that's what windows does.
(Or seems to, in my experience. File associations.)

So if we say "make" to windows, provided the paths are right,
windows would find a make.bat, but if we say make to ruby, ruby
would miss it because it has no execute bit.

Or have I now confused myself as well as everyone else?

       Hugh

See the ticket at RubyForge I mentioned earlier.

--
Luis Lavena
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

=end

Actions #8

Updated by hgs (Hugh Sasse) about 14 years ago

=begin
Composing my email crossed with yours. Yes, I think
that rubyforge ticket you link to would cover it.
A quick prod of dln.c suggests it is dln_find_1
we are talking about.

Is there a way to expose this mechanism to mkmf without duplicating it? It doesn't seem to be wrapped in a ruby method yet.
=end

Actions #9

Updated by nobu (Nobuyoshi Nakada) about 14 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r26468.
Roger, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0