捆绑本地 gem(我正在开发)似乎不包含 lib 目录(使用 rvm)
我正在尝试在本地开发一个 gem,并使用 Bundler 安装它。
我的 Gemfile 看起来像这样:
source "http://rubygems.org"
gemspec
我的 gemspec 是一个标准的 gemspec 文件。
我可以在目录中使用“捆绑安装”来安装 gem,并且我会看到本地 gem 及其所有依赖项安装:
bundle install
Using rack (1.3.4)
Using tilt (1.3.3)
Using sinatra (1.3.1)
Using {my gem} (0.0.2) from source at .
Using bundler (1.0.21)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
但是,当我执行“gem 列表”时,我的 gem 不包含在 gem 列表中 - 这是我猜测为什么我的 bin 目录没有出现在路径中。有没有办法测试本地 gem 并使用捆绑器将其包含在已安装的 gem 列表中,以便 bin 目录正常工作?
I'm trying to develop a gem locally, and have installed it with Bundler.
My Gemfile looks like this:
source "http://rubygems.org"
gemspec
And my gemspec is a standard gemspec file.
I can install the gem with 'bundle install' in the directory, and i see the local gem and all it's dependencies install:
bundle install
Using rack (1.3.4)
Using tilt (1.3.3)
Using sinatra (1.3.1)
Using {my gem} (0.0.2) from source at .
Using bundler (1.0.21)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
However, when I do a 'gem list', my gem is not included in the list of gems - which is my guess as to why my bin directory does not appear in the path. Is there a way to test a local gem and include it in the list of installed gems using bundler, so that the bin directory properly works?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
摆脱
bundler: command not find: {your binexecutable}
的最简单方法:Easiest way to get rid of
bundler: command not found: {your bin executable}
:gem list
显示您的系统安装的 gem,而不是 Bundle 中的 gem(这通常是相同的,但并非总是如此 - 正如本例所示)。当您使用 Bundler 时,您应该始终使用bundle exec
执行 gem 可执行文件,以便 Bundler 可以为您设置环境。因此,如果您有一个名为mygem
的二进制文件,则应使用bundle exec mygem
。请访问 Bundler 网站 或 手册页。
[编辑]
另外请确保您的 gemspec 包含 bin 目录!常见的约定是在与
lib
目录相同的级别创建一个名为bin
的目录,将二进制文件放入其中,然后将其添加为 gemspec 中的目录。如果您不这样做,Bundler 将不会公开您的二进制文件!gem list
shows your system installed gems, not the gems in your Bundle (this are often the same but not always--as in this case). When you're using Bundler, you should always execute gem executables withbundle exec
so that Bundler can set up the environment for you. So, if you have a binary called, for example,mygem
, you should usebundle exec mygem
.See more info at Bundler's site or in the manpage.
[Edit]
Also be sure that your gemspec includes a bin directory! Common convention is to create a directory called
bin
at the same level as yourlib
directory, put your binaries in there, and then add this as the directory in your gemspec. If you don't do this, Bundler won't expose your binaries!我也有这个问题。
确保可执行文件和default_executable 行不包含“bin/”。然后:
I had this problem too.
Make sure the executables and default_executable lines don't contain 'bin/'. Then: