Friedrich Ewald My Personal Website

Conflicting dependencies in Ruby

I installed two different Ruby projects on my local system which both depended on different versions of bigdecimal. One project required bigdecimal version 4.0.1, while the other needed version 3.3.1. When I tried to run the second project after installing the first, I encountered a conflict because both projects were trying to use different versions of the same gem. Finding the different versions of bigdecimal can be done via

 gem list bigdecimal

*** LOCAL GEMS ***

bigdecimal (4.0.1, 3.3.1, 3.1.9, 3.1.8)
Then remove the conflicting version using
gem uninstall bigdecimal -v 4.0.1
The cleanest fix is to set bundler to use a specific folder for dependencies for each project. This way, each project can have its own set of gems without conflicts. You can do this by running:
bundle config set path 'vendor/bundle'
This command tells Bundler to install gems in the vendor/bundle directory within each project, allowing each project to maintain its own dependencies without interfering with each other. After running this command, you can run bundle install in each project, and it will install the required gems in their respective directories. This approach ensures that each project can use the specific version of bigdecimal it requires without any conflicts, and you can switch between projects without worrying about dependency issues.

About the author

is a Staff Software Engineer with a Master's degree in Computer Science. He started this website in late 2015, mostly as a digital business card. He is interested in Go, Python, Ruby, SQL- and NoSQL-databases, machine learning and AI and is experienced in building scalable, distributed systems and micro-services at multiple larger and smaller companies.