1

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?

user3309314
  • 2,453
  • 2
  • 17
  • 30
  • Does this answer your question? [How to install gem from GitHub source?](https://stackoverflow.com/questions/2577346/how-to-install-gem-from-github-source) or [this](https://stackoverflow.com/questions/6119946/how-to-get-a-specific-commit-of-a-gem-from-github) – Alexander Santos Dec 22 '19 at 14:34
  • why do you need that particular commit if it was merged into master branch as seen in (the pull request)(https://github.com/rebelidealist/stripe-ruby-mock/pull/623) ? – lacostenycoder Dec 22 '19 at 14:36
  • @AlexanderSantos I'm not really sure. I have a project with tests. Using exactly this commit of the gem tests pass. When I use another revision - tests fail. That's why ‍♂️ I just can't get what I miss using this revision. I have this revision cached on my computer and all works fine but when I run `bundle` on another computer Bundler can't fetch the gem according Gemfile – user3309314 Dec 22 '19 at 14:38
  • Tag it, and get it by tag instead of commit – DannyB Dec 22 '19 at 14:44
  • but that commit has been merged in to the main repo so did you try with just using `https://github.com/rebelidealist/stripe-ruby-mock` without branch or commit? In fact try to comment out everything and just use the core gem? It's bad practice to use forks of a gem if you can get the main repo to work. I – lacostenycoder Dec 22 '19 at 14:44

2 Answers2

1

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:

enter image description here

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

enter image description here

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.

fphilipe
  • 9,739
  • 1
  • 40
  • 52
-1

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.

lacostenycoder
  • 10,623
  • 4
  • 31
  • 48