2017-09-19 64 views
-1

我是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 envgem 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 

回答

0

的最佳方式與您要修改的瑰寶工作與本地副本一起工作,以便您不必將代碼推送到github,並在每次要測試修改時都可以獲取它。

首先克隆計算機中某處的github存儲庫。

然後用它在你的Gemfile這樣的:

gem 'earnshark-sdk-ruby', path: 'path/to/earnshark-sdk-ruby'