how to require different gems with the same name?

前端 未结 2 1842
自闭症患者
自闭症患者 2021-01-13 08:23

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

相关标签:
2条回答
  • 2021-01-13 08:49

    You could add the following to your Gemfile:

    gem 'gmail', :git => "git://github.com/dcparker/ruby-gmail", :branch => "master"
    gem 'gmail', :git => "git://github.com/nu7hatch/gmail", :branch => "master"
    
    0 讨论(0)
  • 2021-01-13 08:51

    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.

    0 讨论(0)
提交回复
热议问题