-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot require 'bundler'
when we are using --bundle flag and --bundle_path flag
#5335
Comments
I was going to say that to workaround it you could just do |
module Bundler
class BundlerError < StandardError
def self.status_code(code)
define_method(:status_code) { code }
if match = BundlerError.all_errors.find {|_k, v| v == code }
error, _ = match
raise ArgumentError,
"Trying to register #{self} for status code #{code} but #{error} is already registered"
end
BundlerError.all_errors[self] = code
end
def self.all_errors
@all_errors ||= {}
end
end
class GemfileError < BundlerError; status_code(4); end |
OpenStudio/ruby/bindings/InitRubyBindings.cpp Line 889 in 73e12b9
|
This only happens because of the embedded filesystem. We use Kernel::eval when it's embedded, so it still tries to load it, whether normally require "bundler/errors" a second time would just say false since it's already loaded. The chain is:
|
I hate the embedded filesystem. Anyways, seems like we may be able to trick it... prev_features = $LOADED_FEATURES.dup
puts prev_features.select{|x| x.include?('bundler') }
puts "require bundler"
require 'bundler'
new_features = $LOADED_FEATURES.dup
puts new_features - prev_features
puts "bundler features"
puts new_features.select{|x| x.include?('bundler') } see the difference when you call
|
Oh. we actually don't try to load the same file twice from embedded either. It's just that it still returns "true"... But the issue is that initially when InitRubyBindings does it, this is the file that's loaded
But then, when you call
We shouldn't have two bundlers (built in ruby + bundler gem)... I think we've said that before... |
Meh, I think it's going to be hard, and given what we discussed about possibly eliminating the embedded file system, I suppose it's not wise to go down the rabbit hole. @DavidGoldwasser @kbenne . @wenyikuang I think your workaround in openstudio-extension-gem is probably fine for now |
Similar to #5161 , the issue about
The way I reproduce the issue:
//generate an empty Gemfile and install it
In NREL/openstudio:3.9.0
//run openstudio with --bundle --bundle_path flags with require bundler
It will raise exception:
Issue overview
Current Behavior
Expected Behavior
I think in the old release it will not block the execution of rb file from
The root cause is tracing back through:
"lib/measures/urban_geometry_creation/tests/urban_geometry_creation_test.rb" -> "urbanopt/geojson" -> "urbanopt/core" -> "openstudio/extension" -> "bundler"
Steps to Reproduce
Has mentioned above.
Possible Solution
I offered a bypass in openstudio/extension to avoid requiring bundler when there is
Bundler
constants.in this commit:
NREL/openstudio-extension-gem@9c1e2da
and it do fix the issue, but I am not sure how it should be handle gracefully.
Details
Environment
Some additional details about your environment for this issue (if relevant):
Context
The text was updated successfully, but these errors were encountered: