私はmygem
と呼ぶ宝石を持っており、実行可能ファイルはCLIツールとして使用されています。Rubyの未解決の仕様Gem :: Specification.resetとインストール済みの宝石と
ファイルmygem/bin/mygem
:
#!/usr/bin/env ruby
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'bundler/setup'
....code goes here....
mygem.gemspec
:
Gem::Specification.new do |gem|
gem.bindir = 'bin'
gem.executables = ['mygem']
end
ビルドしてインストールします。
gem build mygem.gemspec
gem install mygem-0.1.0.gem
<optionally bundle install, but that won't fix the error>
そして、最後に、私は成功し、コマンドラインからmygem
を呼び出すことができますがスクリプトが実行されます。
ではなくにはGemfile
が含まれているフォルダからしか実行できないという問題があります。
WARN: Unresolved specs during Gem::Specification.reset:
json (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Could not find differ-0.1.2 in any of the sources
Run `bundle install` to install missing gems.
このエラーメッセージに表示され、実際の宝石が現在のディレクトリにGemfileによって異なります。それ以外の場合はやった場合、システムはエラーを出力します。
bundle exec mygem
実行すると、エラーメッセージの一部を抑制し、それでもbundle install
が他アプリケーションのGemfile上で実行されていない限り、実行に失敗します。
Could not find differ-0.1.2 in any of the sources
Run `bundle install` to install missing gems.
はどのようにこれを固定することができますか?
問題は、それがすでに – Drew
@Drewだということですが、あなたは似た/同じエラーメッセージの他の記事をチェックアウトしまし?すばやくGoogle検索を行い、多くの質問/回答を見つけました。これはあなたの路地の上にあるかもしれません:http://stackoverflow.com/questions/17936340/unresolved-specs-during-gemspecification-reset – Andrew