Can I force a gem's dependencies in gemfile?

If there are two gems, A and B. A1.0.0 depends on B1.0.0.

In my Gemfile:

  • Can't run Jenkins Build - bundle: “command not found”
  • Gemfile.lock not checked in - Heroku
  • Gemfile.lock always has changes not staged for commit
  • Gems not found by 'gem list' when using 'bundle install' for git gems with RVM
  • Different gem versions in different branch
  • Ruby “bundle install” error on Openshift
  • gem 'A', '~> 1.0.0'
    

    Then run bundle. It will generate a Gemfile.lock like:

    A (1.0.0)
      B (1.0.0)
    

    But if I want to force A to use B1.0.1, what’s the best practice? Moreover, if the B1.0.1 is not release but a github tag?

  • Is there a way to create a folder-specific readme file in github?
  • Error when using install_github: 'exdir' does not exist
  • what will happen if I add a file to my git repo and later add a pattern in gitignore that suggests that file is to be ignored
  • How can I undo discard changes in GitHub Desktop?
  • How can I set up a github Machine User on Coldfusion (on Windows)?
  • Android Studio and Git - How do I GPG-sign my commits?
  • One Solution collect form web for “Can I force a gem's dependencies in gemfile?”

    You’ll need to explicitly specify the B gem in your Gemfile to use a git repository or another version. As long as A 1.0.0 is compatible with B 1.0.1 you’ll be fine. If it is only compatible with B 1.0.0 then you’ll have to create your own fork of the A gem and upgrade the gemspec to be compatible with B 1.0.1 and then use that repository as your gem for A instead of the rubygems version.

    Here is a sample Gemfile that should give you what you want, provided A 1.0.0 is compatible with B 1.0.1.

    gem 'B', :git => 'git://github.com/B/B.git', :tag => '1.0.1'
    gem 'A', '~> 1.0.0'
    
    Git Baby is a git and github fan, let's start git clone.