Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to require different gems with the same name?

I am interested in making an application that requires me to require a gmail gem for ruby. Right now there are 2 gems:

https://github.com/dcparker/ruby-gmail

https://github.com/nu7hatch/gmail

Both gems have the same require name, ie: gmail The second one is much clear but there is a problem with one of its method. This method works well in the first gem (link). So I was thinking maybe I could require the first one for just that method. Is it possible to do so, how?

like image 743
optimusprime Avatar asked Nov 22 '22 16:11

optimusprime


1 Answers

As others answers and comments have said, you cannot simply require both gems as they are.

However, given that both are hosted on GitHub, you could fork one of them and rename the offending classes. So long as your renaming is consistent within the gem you could use your fork within your Gemfile

Of course, you wouldn't be easily able to rebase changes onto your fork easily but if you really must use both gems this might be a compromise that you are happy with.

like image 133
Graham Savage Avatar answered Jun 25 '23 17:06

Graham Savage