【发布时间】:2015-02-26 00:39:58
【问题描述】:
我正在使用 ruby 制作自己的日志监控脚本,并使用 Warbler 将其与 JRuby 编译成 JAR。我正在运行 JRuby 1.7.17 64 位。当我运行以下脚本时,我正在尝试使用与 MRI 和 JRuby 一起使用的 gem optparse:
monitor_log>] jruby lib\monitor_log\log_watch.rb --help
Usage: log_watch [options]
-f, --file FILE Input file to monitor
-p, --pattern PATTERN Pattern to match in the file
-h, --help Show this screen
所以我尝试使用 JBundler 运行它,看看 JRuby 是否会运行我的 gem,
monitor_log>] jbundle exec jruby bin/log_watch.rb --help
Usage: log_watch [options]
-f, --file FILE Input file to monitor
-p, --pattern PATTERN Pattern to match in the file
-h, --help Show this screen
所以,然后我尝试使用 Warbler 运行它以将其编译成 JAR。我得到:
monitor_log>] warble executable jar
warble aborted!
Bundler::GemNotFound: Could not find gem 'optparse (>= 0) java' in the gems available on this machine.
c:\Ruby\jruby-1.7.17\bin\warble:23:in `(root)'
(See full trace by running task with --trace)
我以为JRuby可能默认没有这个,所以我尝试了so搜索gem,
monitor_log>] jruby -S gem search optparse
*** REMOTE GEMS ***
micro-optparse (1.2.0)
optparse-command (0.1.8)
optparse-defaults (0.1.0)
optparse-lite (0.0.0)
optparse-off (0.0.1)
optparse-pathname (0.0.1)
optparse-range (0.0.3)
optparse-simple (0.4.2)
optparse_ex (0.0.4)
pickled_optparse (0.1.1)
remi-optparse-simple (0.1.0)
rubysl-optparse (2.0.1)
subcommand-optparse (0.0.3)
但对我来说没有什么真正明显的。有什么我做的不对吗?我将 gem optparse 添加到 .gemspec 作为开发依赖项和运行时依赖项。我不应该这样做还是我还缺少其他东西?
【问题讨论】: