Problems with first gem using Rake/Hoe

Hi,

I’m trying to package my first gem using Hoe (1.4.0) and am having
difficulties with Rake (0.8.1) on a Windows XP system. What I notice is
that when I execute the task through Rake, it will fail yet I can
execute the task outside of Rake. For instance:

C:\rubylogparser>rake install_gem
(in C:/rubylogparser)
zip -r rubylogparser-0.1.0.zip rubylogparser-0.1.0
Successfully built RubyGem
Name: rubylogparser
Version: 0.1.0
File: rubylogparser-0.1.0.gem
gem install pkg/.gem
rake aborted!
Command failed with status (0): [gem install pkg/
.gem…]

(See full trace by running task with --trace)

C:\rubylogparser>rake install_gem --trace
(in C:/rubylogparser)
** Invoke install_gem (first_time)
** Invoke clean (first_time)
** Invoke clobber_docs (first_time)
** Execute clobber_docs
** Invoke clobber_package (first_time)
** Execute clobber_package
** Execute clean
** Invoke package (first_time)
** Invoke pkg/rubylogparser-0.1.0.zip (first_time)
** Invoke pkg/rubylogparser-0.1.0 (first_time)
** Invoke EXAMPLES.txt (first_time, not_needed)
** Invoke GUIDE.txt (first_time, not_needed)
** Invoke History.txt (first_time, not_needed)
** Invoke Manifest.txt (first_time, not_needed)
** Invoke README.txt (first_time, not_needed)
** Invoke Rakefile (first_time, not_needed)
** Invoke examples/event_log.rb (first_time, not_needed)
** Invoke examples/files.rb (first_time, not_needed)
** Invoke examples/queryinfo.rb (first_time, not_needed)
** Invoke examples/registry.rb (first_time, not_needed)
** Invoke lib/rubylogparser.rb (first_time, not_needed)
** Invoke test/test_rubylogparser.rb (first_time, not_needed)
** Execute pkg/rubylogparser-0.1.0
** Invoke EXAMPLES.txt (not_needed)
** Invoke GUIDE.txt (not_needed)
** Invoke History.txt (not_needed)
** Invoke Manifest.txt (not_needed)
** Invoke README.txt (not_needed)
** Invoke Rakefile (not_needed)
** Invoke examples/event_log.rb (not_needed)
** Invoke examples/files.rb (not_needed)
** Invoke examples/queryinfo.rb (not_needed)
** Invoke examples/registry.rb (not_needed)
** Invoke lib/rubylogparser.rb (not_needed)
** Invoke test/test_rubylogparser.rb (not_needed)
** Execute pkg/rubylogparser-0.1.0.zip
zip -r rubylogparser-0.1.0.zip rubylogparser-0.1.0
** Invoke gem (first_time)
** Invoke pkg/rubylogparser-0.1.0.gem (first_time)
** Invoke pkg (first_time, not_needed)
** Invoke EXAMPLES.txt (not_needed)
** Invoke GUIDE.txt (not_needed)
** Invoke History.txt (not_needed)
** Invoke Manifest.txt (not_needed)
** Invoke README.txt (not_needed)
** Invoke Rakefile (not_needed)
** Invoke examples/event_log.rb (not_needed)
** Invoke examples/files.rb (not_needed)
** Invoke examples/queryinfo.rb (not_needed)
** Invoke examples/registry.rb (not_needed)
** Invoke lib/rubylogparser.rb (not_needed)
** Invoke test/test_rubylogparser.rb (not_needed)
** Execute pkg/rubylogparser-0.1.0.gem
Successfully built RubyGem
Name: rubylogparser
Version: 0.1.0
File: rubylogparser-0.1.0.gem
** Execute gem
** Execute package
** Execute install_gem
gem install pkg/.gem
rake aborted!
Command failed with status (0): [gem install pkg/
.gem…]
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:899:in sh' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:906:incall’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:906:in sh' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:985:insh’
c:/ruby/lib/ruby/gems/1.8/gems/hoe-1.4.0/lib/hoe.rb:486:in
define_tasks' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:incall’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in execute' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:ineach’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in execute' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:ininvoke_with_call_c
hain’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in
synchronize' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:ininvoke_with_call_c
hain’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in invoke' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:ininvoke_task’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in
top_level' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:ineach’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in
top_level' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:instandard_exceptio
n_handling’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in
top_level' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:inrun’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in
standard_exceptio n_handling' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:inrun’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31
c:/ruby/bin/rake:16:in `load’
c:/ruby/bin/rake:16

C:\rubylogparser>gem install pkg/*.gem
Successfully installed rubylogparser, version 0.1.0
Installing ri documentation for rubylogparser-0.1.0…
Installing RDoc documentation for rubylogparser-0.1.0…

C:\rubylogparser>rake ridocs
(in C:/rubylogparser)
rdoc --ri -o ri .
rake aborted!
undefined method `exitstatus’ for nil:NilClass

(See full trace by running task with --trace)

C:\rubylogparser>rake ridocs --trace
(in C:/rubylogparser)
** Invoke ridocs (first_time)
** Invoke clean (first_time)
** Invoke clobber_docs (first_time)
** Execute clobber_docs
** Invoke clobber_package (first_time)
** Execute clobber_package
** Execute clean
** Execute ridocs
rdoc --ri -o ri .
rake aborted!
undefined method exitstatus' for nil:NilClass c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:899:insh’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:906:in call' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:906:insh’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:985:in sh' c:/ruby/lib/ruby/gems/1.8/gems/hoe-1.4.0/lib/hoe.rb:546:indefine_tasks’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in call' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:inexecute’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in each' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:inexecute’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in
invoke_with_call_c hain' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:insynchronize’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in
invoke_with_call_c hain' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:ininvoke’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in
invoke_task' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:intop_level’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in each' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:intop_level’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in
standard_exceptio n_handling' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:intop_level’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in run' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:instandard_exceptio
n_handling’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in run' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 c:/ruby/bin/rake:16:inload’
c:/ruby/bin/rake:16

C:\rubylogparser>rdoc --ri -o ri .

                   event_log.rb:
                       files.rb:
                   queryinfo.rb:
                    registry.rb:
               rubylogparser.rb: c...............
          test_rubylogparser.rb: c......

Generating RI…

Files: 6
Classes: 2
Modules: 0
Methods: 21
Elapsed: 1.803s

C:\rubylogparser>

Using Google, I see that I am not the only one who has seen these errors
in various incarnations. Does anyone understand why Rake fails when the
tasks succeed otherwise?

Thanks in advance,
Jim

On 11 ene, 22:02, Jim C. [email protected] wrote:

in various incarnations. Does anyone understand why Rake fails when the
tasks succeed otherwise?

The problem is related to system() and ruby.

It don’t take as valid “executables” the batch files (.bat or .cmd)
that ruby on Windows need to get gem, rake, or other gem installed
tools run.

Try the following in a IRB session:
irb(main):005:0> system “gem”, “-v”
=> false
irb(main):006:0> system “gem.bat”, “-v”
0.9.4
=> true

I you take a closer look, you see that I needed to provide the file
extension to get it working.
Hoe task lack the extension of the command, mostly because it need to
be cross-platform compatible, and is just Windows that needs it.

You can suggest a patch to Hoe project that takes RUBY_PLATFORM in
consideration and set the correct system call.

HTH,

Luis L. wrote:

0.9.4
=> true

OK, I see this in IRB too. I’m still a little confused just because the
tasks that Rake is failing on I am typing in exactly as Rake is issuing
them (well, I haven’t traced it inside a debugger but based on the
–trace output to the screen).

I you take a closer look, you see that I needed to provide the file
extension to get it working.
Hoe task lack the extension of the command, mostly because it need to
be cross-platform compatible, and is just Windows that needs it.

Case in point, Rake fails on the “rake install_gem” command on the “gem
install pkg/*.gem” yet this works verbatim on the command line. I don’t
need “gem.bat install…” on the command line.

You can suggest a patch to Hoe project that takes RUBY_PLATFORM in
consideration and set the correct system call.

Obviously I do need to trace this inside a debugger and understand it
better before I suggest a patch. Being my first gem, I am in that grey
area where when things go wrong, I’m not sure whether it is how I have
things configured or other sometimes Windows specific issues.

Thanks for the help.

Regards,
Jim

On 12 ene, 17:46, Jim C. [email protected] wrote:

irb(main):006:0> system “gem.bat”, “-v”
0.9.4
=> true

OK, I see this in IRB too. I’m still a little confused just because the
tasks that Rake is failing on I am typing in exactly as Rake is issuing
them (well, I haven’t traced it inside a debugger but based on the
–trace output to the screen).

There isn’t too much for you to get confused.

Hoe is creating a series of Rake tasks that do system calls. The way
#system method works in Ruby is that unless it is a executable (.exe)
you need the extension for the file, so you need pass the .bat or .cmd
to it.

The verbatim copy of the commandline works in the Command Prompt
because the execution is done by the cmd.exe and not by ruby.

I you take a closer look, you see that I needed to provide the file
extension to get it working.
Hoe task lack the extension of the command, mostly because it need to
be cross-platform compatible, and is just Windows that needs it.

Case in point, Rake fails on the “rake install_gem” command on the “gem
install pkg/*.gem” yet this works verbatim on the command line. I don’t
need “gem.bat install…” on the command line.

Again, is a known problem of Ruby #system method.

You can suggest a patch to Hoe project that takes RUBY_PLATFORM in
consideration and set the correct system call.

Obviously I do need to trace this inside a debugger and understand it
better before I suggest a patch. Being my first gem, I am in that grey
area where when things go wrong, I’m not sure whether it is how I have
things configured or other sometimes Windows specific issues.

No need for a debugger. If you take a look inside lib/hoe.rb (part of
Hoe gem) you will find the exact code that creates the install_gem
task.

Is nothing related on how you have things configured, is a known
problem of Ruby #system method on Windows.

Thanks for the help.

Regards,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs