TL;DR
If the gemfile has not been updated, you will go to see the commit hash of revision
in gemfile.lock.
console
bundle update gem-name
let's do it
When I went to fork-> PR-> merge
to the library used in the company and tried to check it, it was said that the method that should have been added was undefined.
First check what you can use
rails_console
# respond_to?Is the one that checks if a method exists
GemName respond_to? :configure #-> true
GemName respond_to? :new_added_method #-> false
#I noticed that there is no method that I should have entered in PR and check if the gem itself is included without problems
GemName.added_a_lomng_time_ago_method #->Passed
Here, I noticed that the contents of the PR were not completely included and considered that the HEAD might be off.
console
git clone [email protected]:my-org/gem-name #Clone the original repository instead of fork
git rev-parse HEAD #-> 00ff0012345
git rev-parse master #-> 00ff0012345(Confirm that it is the same as HEAD)
Specify gem with commit hash as a trial because it is not misaligned
gemfile
gem 'gem-name', git: '[email protected]:my-org/gem-name', ref: '00ff0012345'
#bundle install
rails_console
GemName.new_added_method #->I passed!
So, when I checked gemfile.lock
, revision
changed. This is the cause …………
After this
gemfile
gem 'gem-name', git: '[email protected]:my-org/gem-name', branch: 'master'
But there was no problem. Well, it is expected because revision
became HEAD when commit hash was specified.
Well, install is done based on gemfile.lock
, so it is natural to say, but I had to use bundle update
. I was completely distracted by the fact that I specified the repository directly and completely forgot.
If you want to update at the same time as bundle install, you need to create an executable file to do it all at once.
Reference: https://stackoverflow.com/questions/8324334/bundler-always-use-latest-revision-of-git-branch-in-gemfile
Recommended Posts