Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two gems share same require?

When I call:

require 'retryable' 

These two gems clash:

  • https://github.com/robertsosinski/retryable
  • https://github.com/carlo/retryable

as they both have a 'retryable' file they ask the user to require. I'm interested in using the first gem, however this doesn't always happen.

This code is executed as a part of my own gem, and it has to be reliable across all users.

Is there a way to require specifically from a gem (as the gem names are different of course)?

How do I resolve this naming conflict?

EDIT: To clarify, this is the official repo and the gem names are actually different ("retryable-rb" and "carlo-retryable"), however they both ask their users to require the lib/retryable.rb file with require 'retryable'

like image 529
ZirconCode Avatar asked Nov 18 '13 17:11

ZirconCode


1 Answers

You can explicitly activate a specific gem with the gem method.

In this case you want the retryable-rb gem, and not any others that may have a retryable.rb file:

gem 'retryable-rb'   # activates the gem in question
                     # and adds its lib dir to load path

require 'retryable'  # loads retryable.rb from the retryable-rb gem, as it
                     # is now on the load path
like image 183
matt Avatar answered Oct 08 '22 13:10

matt