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:

  • Building pry plugin(gem) with bundler
  • 'Could not find gem' error when specifying a forked version of a gem from Github in my gemfile
  • Should Gemfile.lock be included in .gitignore?
  • What is the best way to keep javascript libraries up-to-date in rails?
  • Gem::LoadError when using a git repo in Gemfile
  • Gemfile.lock not checked in - Heroku
  • 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?

  • How to select repository for staging view in Eclipse Luna 4.4?
  • Pull single file on server
  • Git always merge without a fast-forward, except for when pulling?
  • Github-like hosting, with private source, public ticketing system
  • Why Mylyn is not getting issues from GitHub?
  • git trying to push non-existent file … after clearing cache
  • 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://', :tag => '1.0.1'
    gem 'A', '~> 1.0.0'
    Git Baby is a git and github fan, let's start git clone.