开发者

Buildr ruby error, can't convert Rake::FileTask into String

开发者 https://www.devze.com 2023-02-06 01:07 出处:网络
I have the following buildr buildfile segment: require \"buildr/protobuf\" .... define \"protobuf-stuff\" do

I have the following buildr buildfile segment:

require "buildr/protobuf"

....

define "protobuf-stuff" do
  pbs = protoc(
        Dir[_("pbsrc/some/pkg/*.proto")], { 
        :include => [_("pbsrc")],
        })

  comp = compile.from(pbs).with(PROTOBUF_LIB) # MARK
  package :jar
end

Buildr is 1.4.4, installed with the Linux install script on two machnies.

  • Machine 1: Debian 32bit, ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
  • Machine 2: Ubuntu 64bit, ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]

Machine 1 compiles everything file. Machine 2 fails on the MARK-ed place, with

Buildr aborted!
TypeError : can't convert Rake::FileTask into String
/usr/lib/ruby/gems/1.8/gems/buildr-1.4.4/lib/buildr/core/application.rb:414:in `raw_load_buildfile'
/usr/lib/ruby/gems/1.8/gems/buildr-1.4.4/lib/buildr/core/application.rb:218:in `load_buildfile'
/usr/lib/ruby/gems/1.8/gems/buildr-1.4.4/lib/buildr/core/application.rb:213:in `load_buildfile'

Now I can see that pbs is a 开发者_开发技巧FileTask and not a string.. but how come one machine accepts it, the other not? Is there a forced conversion to String?

Some buildr traces are attached at http://pastebin.com/nf4HiYx9 .

Thank you.


The stacktrace on pastebin is very different from the stacktrace pasted here, from what I can see.

Where is the protoc method defined ? Is it part of Buildr core ?

The reason why it fails on one machine and not the other might be the version of Ruby you have, given that the line that fails is "if File.exist? path". path there is supposed to be a String, but is probably converted to a String in one case but not the other.

The overall fix is to add a call after calling protoc(...), protoc(...).map(&:to_s).

I hope this helped.


I figured that adding .to_s helps and everything is fine. But I could appreciate an answer telling where exactly the implicit conversion was lost, and why is it good (if so).

/from my earlier comment/

0

精彩评论

暂无评论...
验证码 换一张
取 消