简体   繁体   中英

Installing a gem using a commit's hash

I have really simple Gemfile :

source 'https://rubygems.org'                                                                                                                                                                                                                                                                                                                                                                                                   
gem 'stripe-ruby-mock', 
  github: 'mnin/stripe-ruby-mock', 
  require: 'stripe_mock', 
  ref: 'b6446fb5ae2b14b6703554cbea4ebd466e4f3c47'

When I run bundle command to install this gem I get this error:

root@6bcff6bf3997:/app# bundle
The git source `git://github.com/mnin/stripe-ruby-mock.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
Fetching git://github.com/mnin/stripe-ruby-mock.git
fatal: Could not parse object 'b6446fb5ae2b14b6703554cbea4ebd466e4f3c47'.
Revision b6446fb5ae2b14b6703554cbea4ebd466e4f3c47 does not exist in the repository git://github.com/mnin/stripe-ruby-mock.git. Maybe you misspelled it?

But I can visit the commit's page on Github using this link https://github.com/mnin/stripe-ruby-mock/commit/b6446fb5ae2b14b6703554cbea4ebd466e4f3c47 .

So how can I the gem using this commit's hash?

That commit is not reachable from any branch or tag. For that reason, when you clone the repo from GitHub (which Bundler does under the hood), your local copy will not have that commit.

Thus, you can't use it.

On GitHub, you can see that this commit is not reachable as it doesn't list any branch or tag that contains it:

在此处输入图片说明

Compare that to the parent commit, which lists as being reachable from master:

在此处输入图片说明

Note that orphaned commits would get garbage collected by Git eventually. GitHub though doesn't do that as there might be references to particular commits.

Try not to use forked gem if possible. But if you need to lock a forked version, make sure you own the fork. Fork the forked branch, merge it to your own repo's main branch, and then just use that repo in your gemfile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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