如何制作Ruby gem可执行文件

时间:2023-01-04 00:18:17

I can use gems like RSpec or Rails or Pry by calling their respective gem names, e.g. rspec, rails, pry on the commandline. How can I achieve this with gems I create? I'm using bundler for the basic gem creation.

我可以通过调用各自的宝石名称来使用像RSpec或Rails或Pry这样的宝石,例如: rspec,rails,pry在命令行上。我如何用我创造的宝石实现这一目标?我正在使用bundler来创建基本的gem。

2 个解决方案

#1


9  

I actually had my executable in the /bin folder.

我实际上在/ bin文件夹中有我的可执行文件。

Turns out my issue was that bundler's gem template is too smart for it's own good, and only includes files that have been committed to git. I hadn't actually committed the executable yet, so it wasn't picking it up:

事实证明,我的问题是Bundler的gem模板太聪明了,它本身就是好的,只包含已经提交给git的文件。我还没有真正提交可执行文件,所以它没有提起它:

# gemname.gemspec
gem.files         = `git ls-files`.split($\)

#2


4  

According to documentation of Gemspec file you must put your executable in bin/ folder.

根据Gemspec文件的文档,您必须将您的可执行文件放在bin /文件夹中。

#1


9  

I actually had my executable in the /bin folder.

我实际上在/ bin文件夹中有我的可执行文件。

Turns out my issue was that bundler's gem template is too smart for it's own good, and only includes files that have been committed to git. I hadn't actually committed the executable yet, so it wasn't picking it up:

事实证明,我的问题是Bundler的gem模板太聪明了,它本身就是好的,只包含已经提交给git的文件。我还没有真正提交可执行文件,所以它没有提起它:

# gemname.gemspec
gem.files         = `git ls-files`.split($\)

#2


4  

According to documentation of Gemspec file you must put your executable in bin/ folder.

根据Gemspec文件的文档,您必须将您的可执行文件放在bin /文件夹中。