NREL / OpenStudio

OpenStudio is a cross-platform collection of software tools to support whole building energy modeling using EnergyPlus and advanced daylight analysis using Radiance.
https://www.openstudio.net/
Other
496 stars 190 forks source link

CLI issue when using bundle and it has a native gem listed as a dependency #5181

Closed jmarrec closed 5 months ago

jmarrec commented 5 months ago

Issue overview

This is exactly the same issue as https://github.com/NREL/OpenStudio/issues/5091 which was specifically for racc.

This popped up again yesterday when @wenyikuang and @DavidGoldwasser tried to upgrade rubocop to > 1.31.

Rubocop 1.31 added json, ~> 2.3 as a dependency, and that is a native extension. We do have a json 2.6.3 in the CLI, but it would still fails because

Source locally installed gems is ignoring #<Bundler::StubSpecification name=json version=2.7.2 platform=ruby> because it is missing extensions
terminate called after throwing an instance of 'RubyException'
  what():  Bundler::GemNotFound: Could not find json-2.7.2 in locally installed gems

Current Behavior

Expected Behavior

Steps to Reproduce

checkout https://github.com/NREL/openstudio-ee-gem/pull/52/commits/e0f9fdc4877cd8868164a710fdffb61ab2f045a4

using system ruby 3.2.2 with bundler 2.4.10

bundle _2.4.10_ install --path=$(pwd)/.bundle

Example command would be bundle exec rake openstudio:test_with_openstudio.

Or directly and more succinctly

$os_build_rel2/Products/openstudio --loglevel Trace --bundle '/home/julien/Software/Others/openstudio_gems/openstudio-ee-gem/Gemfile' --bundle_path '/home/julien/Software/Others/openstudio_gems/openstudio-ee-gem/.bundle' -e 'puts "hello"'

Possible Solution

We should just use the embedded native gems when they are both:

eg rubocop requires json ~> 2.3

bundle _2.4.10_ install --path=$(pwd)/.bundle would resolve it as json-2.7.2.

But our CLI embeds json 2.6.3, which is compatible.

So we should just use the CLI one.

@kbenne FYI.

Details

Environment

Some additional details about your environment for this issue (if relevant):

Context