简体   繁体   English

在Gemfile中从github指定一个插件作为gem

[英]Specify a plugin as gem from github in Gemfile

I am including 'acts_as_rateable' gem in my Gemfile like this 我在我的Gemfile中包含'acts_as_rateable'gem就像这样

gem 'acts_as_rateable', :git => 'git://github.com/azabaj/acts_as_rateable.git'

and then when I do bundle install it gives me this error message! 然后当我做bundle install它给了我这个错误信息!

Could not find gem 'acts_as_rateable (>= 0, runtime)' in git://github.com/azabaj/acts_as_rateable.git (at master). 无法在git://github.com/azabaj/acts_as_rateable.git(在master中)找到gem'meject_as_rateable(> = 0,runtime)'。 Source does not contain any versions of 'acts_as_rateable (>= 0, runtime)' Source不包含任何版本的'acts_as_rateable(> = 0,runtime)'

I am developing a plugin of my own, when I include that, even that gives the same error like this.. 我正在开发一个自己的插件,当我包含它时,即使这样也会产生同样的错误。

I assume this has something to do with the gemspec? 我认为这与gemspec有关?

Please help 请帮忙

Rails version : 3.0.1 Rubygems version : 1.3.7 Bundler version : 1.0.3 Rails版本:3.0.1 Rubygems版本:1.3.7 Bundler版本:1.0.3

let me know if you need any other details.. 如果您需要任何其他细节,请告诉我..

If you want to pull a gem directly from GitHub, you can put this into your GemFile : 如果你想直接从GitHub中提取一个gem,你可以把它放到你的GemFile中

gem 'twitter', github: 'sferik/twitter'

Which will use the default branch. 哪个将使用默认分支。 To specify the branch to use: 指定要使用的分支:

gem 'twitter', github: 'sferik/twitter', branch: 'branch_name'

The problem is that the repository you link to is not a RubyGem. 问题是您链接的存储库不是RubyGem。 You can get with 你可以得到

$ rails plugin install git://github.com/azabaj/acts_as_rateable.git 

Edit: This answer was accurate on the date it was published. 编辑:这个答案在发布之日是准确的。 Rails 4 doesn't support plugins anymore, so you will have to make this into a local gem yourself. Rails 4不再支持插件,因此您必须自己将其变为本地gem。 Bundler has some commands that will help you with it, or alternatively you can use a different library, eg https://github.com/anton-zaytsev/acts_as_rateable . Bundler有一些命令可以帮助你,或者你可以使用不同的库,例如https://github.com/anton-zaytsev/acts_as_rateable

Jakub Hampl is right, but it seems strange to depend on git repos like that. Jakub Hampl是对的,但依赖git repos似乎很奇怪。 I guess you're you making it yourself? 我猜你是自己做的吗? If so, make it a real gem. 如果是这样,那就把它变成真正的宝石。 It should have a acts_as_rateable.gemspec and you'll be able to depend on it like you wrote. 它应该有一个acts_as_rateable.gemspec,你就可以像你写的一样依赖它。 Bundler makes your life easy, create the gemspec with Bundler让您的生活更轻松,创造出gemspec

$ bundle gem acts_as_rateable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM