Ruby Gem本地覆盖不起作用
问题描述:
我是Ruby新手,试图修改一个gem。阅读完一些资料后,我明白最好的方法是使用'Fork and Source'。 我有我需要的宝石来源的叉子,并已做出所有需要的修改,并将其推到我的本地回购。Ruby Gem本地覆盖不起作用
在我的红宝石应用程序的宝石文件,
gem 'earnshark_sdk','0.2.0', :git => 'https://github.com/kniveditha/earnshark-sdk-ruby.git', :branch => 'master'
我的创业板安装后
gem install earnshark_sdk
和包安装说明我,它获取我的本地宝石,
E:\Work\CoverYa\TEST>bundle install
Fetching https://github.com/kniveditha/earnshark-sdk-ruby.git
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using public_suffix 3.0.0
Using bundler 1.15.4
Using unf_ext 0.0.7.4 (x86-mingw32)
Using earnshark_sdk 0.2.0 from https://github.com/kniveditha/earnshark-sdk-ruby.git (at [email protected])
Using http-form_data 1.0.3
Using http_parser.rb 0.6.0
Using addressable 2.5.2
Using unf 0.1.4
Using domain_name 0.5.20170404
Using http-cookie 1.0.3
Using http 2.2.2
Bundle complete! 2 Gemfile dependencies, 11 gems now installed.
捆绑列表命令显示我使用当地的宝石,
E:\Work\CoverYa\TEST>bundle list
Gems included by the bundle:
* addressable (2.5.2)
* bundler (1.15.4)
* domain_name (0.5.20170404)
* earnshark_sdk (0.2.0 976ec5c)
* http (2.2.2)
* http-cookie (1.0.3)
* http-form_data (1.0.3)
* http_parser.rb (0.6.0)
* public_suffix (3.0.0)
* unf (0.1.4)
* unf_ext (0.0.7.4)
除了在我的Gemfile中指定路径,我也迫使捆扎机使用本地宝石为我的环境中只能通过使用下面的配置选项
bundle config local.earnshark_sdk https://github.com/kniveditha/earnshark-sdk-ruby.git
但我的问题是,当我运行我的应用程序仍然给我的老宝石输出
我甚至查gem env
我gem paths
并在lib
文件夹“earnshark”宝石的代码,甚至显示了人我的本地代码库我的变化。
我哪里出错了?
UPDATE:做
bundle config local.earnshark_sdk https://github.com/kniveditha/earnshark-sdk-ruby.git
当我尝试bundle install
它给我这个错误后,
E:\Work\CoverYa\TEST>bundle install
Cannot use local override for earnshark-sdk-ruby because
https://github.com/kniveditha/earnshark-sdk-ruby.git does not exist. Check
`bundle config --delete` to remove the local override
答
的最佳方式与您要修改的瑰宝工作与本地副本一起工作,以便您不必将代码推送到github,并在每次要测试修改时都可以获取它。
首先克隆计算机中某处的github存储库。
然后用它在你的Gemfile
这样的:
gem 'earnshark-sdk-ruby', path: 'path/to/earnshark-sdk-ruby'