Problem with Rake's RDoc task on Windows

If you have ever wondered, why none of the rdoc tasks in any rakefile ever work with your One Click Installer Ruby, here is the explanation.

c:\ruby\bin contains both 'rdoc' and 'rdoc.bat'. c:\ruby\bin is on the system path.

From Windows point of view, rdoc is not an executable. rdoc.bat is an executable, but in its eternal struggle to protect the user from himself, Windows doesn't notice that. Hence:

irb(main):001:0> `rdoc`
Errno::ENOEXEC: Exec format error - rdoc
...
irb(main):002:0> `rdoc.bat`
... works...

Unfortunately system 'rdoc ...' is exactly what Rake does. Not sure where and how it can be dealt with. Can One Click Installer somehow cope with it? Or can Rake invoke rdoc.rb directly, rather than via an executable?

An ugly but effective workaround is to hack your local copy of lib/rake/rdoctask.rb, replacing sh %{rdoc -o with sh %{rdoc.bat -o

P.S. I am fully aware of the common opinion that the _proper_ workaround is to ditch Windows. But circumstances force me :slight_smile:

···

--
Best regards,

Alexey Verkhovsky

Ruby Forum: http://ruby-forum.org (moderator)
RForum: http://rforum.andreas-s.net (co-author)
Instiki: http://instiki.org (maintainer)

If you have ever wondered, why none of the rdoc tasks in any rakefile
ever work with your One Click Installer Ruby, here is the explanation.

c:\ruby\bin contains both 'rdoc' and 'rdoc.bat'. c:\ruby\bin is on the
system path.

From Windows point of view, rdoc is not an executable. rdoc.bat is an
executable, but in its eternal struggle to protect the user from
himself, Windows doesn't notice that. Hence:

irb(main):001:0> `rdoc`
Errno::ENOEXEC: Exec format error - rdoc
...
irb(main):002:0> `rdoc.bat`
... works...

Unfortunately system 'rdoc ...' is exactly what Rake does. Not sure
where and how it can be dealt with. Can One Click Installer somehow cope
with it? Or can Rake invoke rdoc.rb directly, rather than via an
executable?

An ugly but effective workaround is to hack your local copy of
lib/rake/rdoctask.rb, replacing sh %{rdoc -o with sh %{rdoc.bat -o

An easy and clean way to solve this problem is to invoke rdoc
programmatically. This is what I do for Rant:

    require 'rdoc/rdoc'
    # args is an array of strings which you would otherwise give
    # on the commandline to rdoc
    RDoc::RDoc.new.document(args)

This should really work everywhere ruby runs.

P.S. I am fully aware of the common opinion that the _proper_ workaround
is to ditch Windows. But circumstances force me :slight_smile:

Surely the best solution!

Stefan

···

On Monday 02 May 2005 06:32, Alexey Verkhovsky wrote:

Alexey Verkhovsky wrote:

If you have ever wondered, why none of the rdoc tasks in any rakefile ever work with your One Click Installer Ruby, here is the explanation.

c:\ruby\bin contains both 'rdoc' and 'rdoc.bat'. c:\ruby\bin is on the system path.

From Windows point of view, rdoc is not an executable. rdoc.bat is an executable, but in its eternal struggle to protect the user from himself, Windows doesn't notice that.

Yet I can run

c:\> rdoc

and it works just fine, so Windows *does* know that rdoc.bat is an executable.

No struggle.

Hence:

irb(main):001:0> `rdoc`
Errno::ENOEXEC: Exec format error - rdoc
...
irb(main):002:0> `rdoc.bat`
... works...

Unfortunately system 'rdoc ...' is exactly what Rake does. Not sure where and how it can be dealt with. Can One Click Installer somehow cope with it? Or can Rake invoke rdoc.rb directly, rather than via an executable?

I believe this has been discussed here before, and the suggestion was made to have Rake just call into RDoc code directly, and avoid system calls entirely.

P.S. I am fully aware of the common opinion that the _proper_ workaround is to ditch Windows. But circumstances force me :slight_smile:

Well, think different. Use Windows.

James