我正在尝试在本地开发一个gem,并使用Bundler安装它。
My Gemfile如下所示:
source "http://rubygems.org"
gemspec
我的gemspec是一个标准的gemspec文件。
我可以在目录中安装带有'bundle install'的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.
然而,当我做一个'宝石列表'时,我的宝石不包含在宝石列表中 - 这就是为什么我的bin目录没有出现在路径中的猜测。有没有办法测试本地gem并使用bundler将其包含在已安装的gem列表中,以便bin目录正常工作?
答案 0 :(得分:1)
摆脱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>
答案 1 :(得分:0)
gem list
显示您的系统安装的宝石,而不是您的Bundle中的宝石(这通常是相同的但不总是 - 如本例所示)。当您使用Bundler时,应始终使用bundle exec
执行gem可执行文件,以便Bundler可以为您设置环境。因此,如果您有一个名为mygem
的二进制文件,则应使用bundle exec mygem
。
在Bundler's site或manpage或。{/ p>中查看更多信息
[编辑]
另外请确保您的gemspec包含bin directory!常见的约定是在与bin
目录相同的级别创建一个名为lib
的目录,将二进制文件放在那里,然后将其添加为gemspec中的目录。如果你不这样做,Bundler将不会暴露你的二进制文件!
答案 2 :(得分:0)
我也有这个问题。
确保可执行文件和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>