是否可以直接从 git 存储库安装 gem?
使用捆绑器,您可以在 Gemfile
中执行类似的操作:
gem 'my_gem', :git => 'git@github:me/my_gem.git'
在该存储库中构建 gem 并安装它。效果很好。是否可以仅使用命令行 gem 工具执行类似的操作?像这样的东西吗?
gem install my_gem --git="git@github:me/my_gem.git"
显然这个命令不起作用,但是有类似的命令吗?我知道我可以克隆该存储库,运行gem build my_gem.gemspec
,然后运行gem install my_gem-1.2.3.gem
。但我想知道是否有一个直接的台词可以将这些中间步骤隐藏在幕后。
Using bundler, you can do something like this in the Gemfile
:
gem 'my_gem', :git => 'git@github:me/my_gem.git'
That builds the gem in that repo and installs it. Works great. Is it possible to do something similar just using the command-line gem tool? Something like this?
gem install my_gem --git="git@github:me/my_gem.git"
Obviously that command doesn't work, but is there something like it that does? I know I can clone the repo, run a gem build my_gem.gemspec
and then a gem install my_gem-1.2.3.gem
. But I'm wondering if there is a direct one-liner that hides these intermediate steps behind the scenes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为与典型的 Git 存储库不同,GitHub 构建 gem,如果项目托管在 GitHub 上并且可以在 源中找到 gem list 然后你可以将 GitHub 添加到你的源列表中,如下所示:
然后稍后根据需要一步安装 gem,如下所示:
否则,没有一步解决方案,你将不得不执行类似的操作这:
gem build.gemspec
sudo gem install-xxxgem
Because unlike typical Git repositories, GitHub builds gems, if the project is hosted on GitHub and the gem is found in the source list then you can add GitHub to your sources list like this:
and then later install gems as desired in a single step, like this:
Otherwise, there's no one-step solution, and you'll have to do something like this:
gem build <gemname>.gemspec
sudo gem install <gemname>-x.x.x.gem