I'm trying to get an old version from a repository using bundler
.
For instance, in my Gemfile I have:
...
gem "custom-metrics", "~> 0.14.0", git: "https://gitlab.custom.co/gems/custom-metrics.git"
...
This is properly installing the version 0.14.0
. Then I pushed a 0.14.1
version in the dependency repository, and it's still the same, as expected.
In the dependency, I'm setting the version in my .gemspec
file as:
Gem::Specification.new do |spec|
spec.name = "custom-metrics"
spec.version = 0.14.0
...
end
If I now push a 0.15.0
version, it would stop working. In this case, I have to specify the ref:
to the previous commit. So it seems it's not that bundler can't install the version, but that it only looks for versions in the last MINOR version (in this case, it would be in 0.15.*
)
I couldn't find any doc that confirms my hypothesis.
> Am I missing something?
> Would it be possible to specify a version and be sure that bundler will always find it?
CodePudding user response:
When loading a gem directly from a git repository, then Bundler loads exactly the version that it find in the defined branch, at the ref or tag.
When you define that a specific version of the gem should be used, then Bundler will check if the version of gem found in the repository matches that condition.
Therefore, you likely do not want to simply install the latest available version of a gem directly from a main branch from GitHub. But instead defining to install from a specific branch, tag, or ref might be easier to manage.
How to install gems from git repositories from the Bundler docs.