捆绑本地 gem(我正在开发)似乎不包含 lib 目录(使用 rvm)

发布于 2024-12-09 02:57:49 字数 613 浏览 0 评论 0原文

我正在尝试在本地开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

输什么也不输骨气 2024-12-16 02:57:49

摆脱 bundler: command not find: {your binexecutable} 的最简单方法:

git add bin/*  # git-ls-files will now list your bin executables.
bundle install 
# No git-commit necessary.
bundle exec <MY_BIN_EXECUTABLE>

Easiest way to get rid of bundler: command not found: {your bin executable}:

git add bin/*  # git-ls-files will now list your bin executables.
bundle install 
# No git-commit necessary.
bundle exec <MY_BIN_EXECUTABLE>
清风夜微凉 2024-12-16 02:57:49

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 with bundle exec so that Bundler can set up the environment for you. So, if you have a binary called, for example, mygem, you should use bundle 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 your lib 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!

爱格式化 2024-12-16 02:57:49

我也有这个问题。

确保可执行文件和default_executable 行不包含“bin/”。然后:

git add add . # You can be more precice if you want.
git commit -m "My lousy commit message."
bundle install
bundle exec <binaryname>

I had this problem too.

Make sure the executables and default_executable lines don't contain 'bin/'. Then:

git add add . # You can be more precice if you want.
git commit -m "My lousy commit message."
bundle install
bundle exec <binaryname>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文