安装自定义 jRuby gem 后尝试执行命令时遇到问题。在我创建的 gem 中,Gemfile 如下所示:
source "http://rubygems.org"
gem 'archive-tar-minitar', '~> 0.5.2'
gem 'fastercsv', '~> 1.5.4'
gem 'rake', '~> 0.9.2.2'
gem 'liquid', '>= 2.3.0'
gem 'net-sftp', '>=2.0.5'
gem 'net-ssh', '>=2.3.0'
gem 'jruby-openssl', '>=0.7.5'
gem 'crypt', '~>1.1.4'
gem 'nokogiri', '1.5.2'
和 .gemspec 文件:
$:.push File.expand_path("../lib", __FILE__)
require "example/version"
require "rake"
Gem::Specification.new do |s|
s.name = "example"
s.version = Example::VERSION
s.platform = 'java'
s.date = '2012-03-30'
s.executables = ["load_csv_to_table"]
s.rdoc_options = ["--charset=UTF-8"]
s.add_dependency('bundler', '~> 1.0')
s.add_dependency('archive-tar-minitar', '~> 0.5.2')
s.add_dependency('liquid', '>= 2.3.0')
s.add_dependency('net-sftp', '>=2.0.5')
s.add_dependency('net-ssh', '>=2.3.0')
s.add_dependency('jruby-openssl', '>=0.7.5')
s.add_dependency('crypt', '~>1.1.4')
s.add_dependency('fastercsv', '~> 1.5.4')
s.add_dependency('json', '~>1.6.6')
s.add_dependency('nokogiri', '1.5.2')
s.files = FileList['lib/**/*.rb', 'bin/*', 'vendor/java/**/*', 'resources/**/*'].to_a
s.require_path = ['lib']
s.required_rubygems_version = ">= 1.3.4"
end
在 bin 文件夹中,我创建了一个名为“example”的命令:
#!/usr/bin/env jruby
$:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
require 'example'
require 'pp'
pp "Example!!"
我安装了在本地系统中创建的 gem,没有错误(jruby -S gem install example-0.0.1-java.gem),但是当我尝试启动命令“example”时,似乎找不到该命令