Huliax
Huliax

Reputation: 1527

Can I get rubygems to ignore gem version conflicts?

I have done a bit of digging through the rubygems code and it doesn't look like there is a built-in way to get it to not throw a Gem::ConflictError even if there is one. During development I might be wanting to test something that I know is not going to touch the code from which the conflict is coming or I know that the whatever version of the erstwhile conflicting gem isn't going to cause a problem. I just want to get on with testing what I want to test and I'll worry about version conflicts later.

I know I can hack rubygems to do this. I can think or multiple ways to get it done. I'm just kind of curious if anyone has already done this, how they did it, and maybe if that code has been shared somewhere. I'm also a bit curious as to why this isn't built in to rubygems as a development tool.

Upvotes: 1

Views: 565

Answers (2)

Jonny
Jonny

Reputation: 320

If you really know what you are doing, try this:

export NOEXEC_DISABLE=1
ruby you-program.rb

This environment variable will disable search and check for Gemfiles and gem versions.

Upvotes: 1

tadman
tadman

Reputation: 211540

You need to worry about version conflicts now before you can get anything done. As Ruby has a singular root namespace and every dependency gets loaded there it's generally not possible to load multiple versions of the same gem. Other systems like NPM for Node.js are significantly more flexible, it's possible to load any number of versions at the same time, so if you're used to that you'll need to adjust your expectations.

If you're trying to do testing and you want to avoid resolving a conflict, just remove that gem requirement from the Gemfile temporarily.

Ultimately you'll have to fix things, there's no way around it, but you can always be selective about what you require.

Upvotes: 2

Related Questions