is there a way to run two versions of the same gem within the same gem env

92 Views Asked by At

In my Gemfile I need gem lumberg and gem openai_chatgpt which both depend on gem faraday. However, lumberg depends on faraday pre v 2.0 and openai_chatgpt depends on faraday post v 2.0. Faraday 2.0+ was a significant change.

The result is that the bundler cannot resolve the dependencies.

Is there a work around for this conundrum?

2

There are 2 best solutions below

0
Ruby on Rails - React - PHP On BEST ANSWER

There is alternative solution but its bit time taken, process is here.

  1. Just clone the older version of gem.
  2. Make the small changes to make it supportable with you current version on ruby and rails, just like upgrading the dependencies.
  3. push the gem on your github account with slightly different.
  4. Then mention the new gem in Gemfile with repository path.
  5. Bundle install.

Hope fully it will resolve your issue.

0
spickermann On

There is no way to load two different versions of the same gem at the same time in Ruby.

The latest version of the lumberg gem is more than 6 years old, I would consider it unmaintained, and I am surprised that it still works with current versions of Ruby.

I suggest forking that gem and fix the dependency to work with a newer version of faraday gem.