Buildr ruby 错误,无法将 Rake::FileTask 转换为 String
我有以下 buildr 构建文件段:
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 是 1.4.4,使用 Linux 安装脚本安装在两台机器上。
- 机器 1:Debian 32 位,ruby 1.8.7(2008-08-11 补丁级别 72)[i486-linux]
- 机器 2:Ubuntu 64 位,ruby 1.8.7(2010-01-10 补丁级别 249)[x86_64-linux]
机器 1编译所有文件。机器 2 在 MARK
-ed 位置失败,
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'
现在我可以看到 pbs
是一个 FileTask 而不是字符串..但是为什么一台机器接受它,另一台机器接受它不是?是否有强制转换为字符串?
一些构建器跟踪附加在 http://pastebin.com/nf4HiYx9 。
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,pastebin 上的堆栈跟踪与此处粘贴的堆栈跟踪非常不同。
protoc 方法在哪里定义?它是 Builder 核心的一部分吗?
考虑到失败的行是“if File.exist?path”,它在一台机器上失败而在另一台机器上失败的原因可能是您所拥有的 Ruby 版本。路径应该是一个字符串,但在一种情况下可能会转换为字符串,但在另一种情况下则不会。
总体修复是在调用 protoc(...)、protoc(...).map(&:to_s) 之后添加一个调用。
我希望这有帮助。
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.
我认为添加 .to_s 有帮助,一切都很好。但我可以理解一个答案,告诉我们隐式转换到底在哪里丢失了,以及为什么它是好的(如果是这样)。
/来自我之前的评论/
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/