Update just one gem with bundler

后端 未结 8 1073
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 07:05

I use bundler to manage dependencies in my rails app, and I have a gem hosted in a git repository included as followed:

gem \'gem-name\', :git => \'path/t         


        
相关标签:
8条回答
  • 2020-12-07 07:41

    Here you can find a good explanation on the difference between

    Update both gem and dependencies:

    bundle update gem-name 
    

    or

    Update exclusively the gem:

    bundle update --source gem-name
    

    along with some nice examples of possible side-effects.

    Update

    As @Tim's answer says, as of Bundler 1.14 the officially-supported way to this is with bundle update --conservative gem-name.

    0 讨论(0)
  • 2020-12-07 07:41

    bundler update --source gem-name will update the revision hash in Gemfile.lock which you can compare with the last commit hash of that git branch (master by default).

    GIT remote: git@github.com:organization/repo-name.git revision: c810f4a29547b60ca8106b7a6b9a9532c392c954

    can be found at github.com/organization/repo-name/commits/c810f4a2 (I used shorthand 8 character commit hash for the url)

    0 讨论(0)
  • 2020-12-07 07:42

    If you want to update a single gem to a specific version:

    1. change the version of the gem in the Gemfile
    2. bundle update
    > ruby -v
    ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
    > gem -v
    3.0.3
    > bundle -v
    Bundler version 2.1.4
    
    0 讨论(0)
  • 2020-12-07 07:43

    bundle update gem-name [--major|--patch|--minor]

    This also works for dependencies.

    0 讨论(0)
  • 2020-12-07 07:48

    You simply need to specify the gem name on the command line:

    bundle update gem-name
    
    0 讨论(0)
  • 2020-12-07 07:50

    It appears that with newer versions of bundler (>= 1.14) it's:

    bundle update --conservative gem-name
    
    0 讨论(0)
提交回复
热议问题