Skip to content

Commit a8588f8

Browse files
committed
debug for #5335
$os_build3/Products/openstudio --loglevel Debug --bundle Gemfile --bundle_path ./gems -e "puts ''; puts ''; puts 'REQUIRE AGAIN'; STDOUT.flush; require 'bundler/errors'" &> log.txt
1 parent 73e12b9 commit a8588f8

File tree

2 files changed

+70
-40
lines changed

2 files changed

+70
-40
lines changed

ruby/bindings/InitRubyBindings.cpp

+55-39
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ module IRB # :nodoc:
630630
631631
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
632632
# puts @CONF[:PROMPT_MODE]
633-
os_version = "3.8.0" # OpenStudio::openStudioVersion
633+
os_version = "3.9.0" # OpenStudio::openStudioVersion
634634
@CONF[:PROMPT][:OPENSTUDIO] = {
635635
:PROMPT_I=>"(os #{os_version}) :%03n > ",
636636
:PROMPT_S=>"(os #{os_version}) :%03n%l> ",
@@ -758,6 +758,15 @@ ENV.reject! { |k, _| ['GEM', 'BUNDLE'].any? { |x| k.start_with?(x) } }
758758
if md = /specifications\/.*\.gemspec$/.match(f) ||
759759
md = /bundler\/.*\.gemspec$/.match(f)
760760
begin
761+
puts "* #{f}"
762+
if /bundler.*gemspec/.match(f)
763+
if f.include?('specifications')
764+
puts "Skipping bundler from specifications/: #{f}"
765+
next
766+
else
767+
puts "Catching #{f}"
768+
end
769+
end
761770
spec = EmbeddedScripting::getFileAsString(f)
762771
s = eval(spec)
763772
@@ -851,6 +860,7 @@ ENV.reject! { |k, _| ['GEM', 'BUNDLE'].any? { |x| k.start_with?(x) } }
851860

852861
if (use_bundler) {
853862
initCmd += R"ruby(
863+
puts "embedded_gems_to_activate=#{embedded_gems_to_activate}"
854864
# Load the bundle before activating any embedded gems
855865
embedded_gems_to_activate.each do |spec|
856866
if spec.name == "bundler"
@@ -861,7 +871,12 @@ ENV.reject! { |k, _| ['GEM', 'BUNDLE'].any? { |x| k.start_with?(x) } }
861871
862872
begin
863873
# Activate will manipulate the $LOAD_PATH to include the gem
874+
puts "=" * 80
875+
puts "LOAD_PATH=#{$LOAD_PATH}"
876+
puts "Activating spec"
864877
spec.activate
878+
puts "LOAD_PATH=#{$LOAD_PATH}"
879+
puts "=" * 80
865880
rescue Gem::LoadError => e
866881
# There may be conflicts between the bundle and the embedded gems,
867882
# those will be logged here
@@ -884,53 +899,54 @@ ENV.reject! { |k, _| ['GEM', 'BUNDLE'].any? { |x| k.start_with?(x) } }
884899
RbConfig::CONFIG['arch'] = 'x64-mingw32'
885900
end
886901
887-
# require bundler
888-
# have to do some forward declaration and pre-require to get around autoload cycles
889-
require 'bundler/errors'
890-
#require 'bundler/environment_preserver'
891-
require 'bundler/plugin'
892-
#require 'bundler/rubygems_ext'
893-
require 'bundler/rubygems_integration'
894-
895-
# Global list, to be populated below
896-
$ignore_native_gem_names = []
902+
puts "Requiring bundler"
903+
# require bundler
904+
# have to do some forward declaration and pre-require to get around autoload cycles
905+
require 'bundler/errors'
906+
#require 'bundler/environment_preserver'
907+
require 'bundler/plugin'
908+
#require 'bundler/rubygems_ext'
909+
require 'bundler/rubygems_integration'
897910
898-
module Bundler
899-
class RubygemsIntegration
911+
# Global list, to be populated below
912+
$ignore_native_gem_names = []
900913
901-
alias :ori_spec_missing_extensions? :spec_missing_extensions?
914+
module Bundler
915+
class RubygemsIntegration
902916
903-
def spec_missing_extensions?(spec, default = true)
917+
alias :ori_spec_missing_extensions? :spec_missing_extensions?
904918
905-
# This avoids getting an annoying message for no reason
906-
if $ignore_native_gem_names.any? {|name| name == spec.name }
907-
return false
908-
end
919+
def spec_missing_extensions?(spec, default = true)
909920
910-
return ori_spec_missing_extensions?(spec, default)
921+
# This avoids getting an annoying message for no reason
922+
if $ignore_native_gem_names.any? {|name| name == spec.name }
923+
return false
911924
end
925+
926+
return ori_spec_missing_extensions?(spec, default)
912927
end
913928
end
929+
end
914930
915-
require 'bundler/version'
916-
require 'bundler/ruby_version'
917-
#require 'bundler/constants'
918-
#require 'bundler/current_ruby'
919-
require 'bundler/gem_helpers'
920-
#require 'bundler/plugin'
921-
require 'bundler/source'
922-
require 'bundler/definition'
923-
require 'bundler/dsl'
924-
require 'bundler/uri_credentials_filter'
925-
require 'bundler/uri_normalizer'
926-
require 'bundler/index'
927-
require 'bundler/digest'
928-
require 'bundler/source/git'
929-
require 'bundler/source/git/git_proxy'
930-
require 'bundler/match_remote_metadata'
931-
require 'bundler/remote_specification'
932-
require 'bundler/stub_specification'
933-
require 'bundler'
931+
require 'bundler/version'
932+
require 'bundler/ruby_version'
933+
#require 'bundler/constants'
934+
#require 'bundler/current_ruby'
935+
require 'bundler/gem_helpers'
936+
#require 'bundler/plugin'
937+
require 'bundler/source'
938+
require 'bundler/definition'
939+
require 'bundler/dsl'
940+
require 'bundler/uri_credentials_filter'
941+
require 'bundler/uri_normalizer'
942+
require 'bundler/index'
943+
require 'bundler/digest'
944+
require 'bundler/source/git'
945+
require 'bundler/source/git/git_proxy'
946+
require 'bundler/match_remote_metadata'
947+
require 'bundler/remote_specification'
948+
require 'bundler/stub_specification'
949+
require 'bundler'
934950
935951
begin
936952
# activate bundled gems

ruby/engine/embedded_help.rb

+15-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def require_embedded_extension path
146146
end
147147

148148
def require path
149+
puts "\nrequire, path=#{path}"
149150
result = false
150151
original_directory = Dir.pwd
151152
path_with_extension = path
@@ -158,20 +159,25 @@ def require path
158159
if extname.empty? or ! RUBY_FILE_EXTS.include? extname
159160
path_with_extension = path + '.rb'
160161
end
162+
puts "path_with_extension=#{path_with_extension}"
161163

162164
if path.include? 'openstudio/energyplus/find_energyplus'
165+
puts "ladder1"
163166
return false
164167
elsif path_with_extension.to_s.chars.first == ':'
168+
puts "ladder2"
165169
# Give absolute embedded paths first priority
166170
if $LOADED.include?(path_with_extension)
167-
return true
171+
puts "ladder2 - already loaded"
172+
return true
168173
else
169174
return require_embedded_absolute(path_with_extension)
170175
end
171176
elsif path_with_extension == 'openstudio.rb'
172177
# OpenStudio is loaded by default and does not need to be required
173178
return true
174179
elsif require_embedded(path_with_extension, $LOAD_PATH)
180+
puts "ladder3"
175181
# Load embedded files that are no required using full paths now
176182
# This does not included the openstudio-gems set of default, baked in gems
177183
# because we want to give anything provided by --bundle the first chance
@@ -182,6 +188,7 @@ def require path
182188
result = original_require path
183189
end
184190
rescue Exception => e
191+
puts "exception - embedded gems"
185192
# This picks up the embedded gems
186193
# Important to do this now, so that --bundle has first chance
187194
# using rescue in normal program flow, might have poor performance
@@ -211,6 +218,7 @@ def require path
211218
end
212219

213220
def require_embedded(path, search_paths)
221+
puts "require_embedded, path=#{path}, search_paths=#{search_paths}"
214222
search_paths = [] if not search_paths
215223
search_paths.each do |p|
216224
if p.to_s.chars.first == ':'
@@ -227,12 +235,16 @@ def require_embedded(path, search_paths)
227235
end
228236

229237
def require_embedded_absolute path
238+
puts "require_embedded_absolute path=#{path}"
230239
original_directory = Dir.pwd
231240

232241
$LOADED << path
233242
s = EmbeddedScripting::getFileAsString(path)
234243
s = OpenStudio::preprocess_ruby_script(s)
235244

245+
puts $LOADED
246+
STDOUT.flush
247+
236248
result = Kernel::eval(s,BINDING,path)
237249

238250

@@ -247,8 +259,10 @@ def require_embedded_absolute path
247259

248260
def require_relative path
249261
absolute_path = File.dirname(caller_locations(1,1)[0].path) + '/' + path
262+
puts "\n\nrequire_relative, path=#{path}, absolute_path=#{absolute_path}"
250263
if absolute_path.to_s.chars.first == ':'
251264
absolute_path = OpenStudio.get_absolute_path(absolute_path)
265+
puts "get_absolute_path=#{absolute_path}"
252266
end
253267
return require absolute_path
254268
end

0 commit comments

Comments
 (0)