-
Notifications
You must be signed in to change notification settings - Fork 193
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
Debug bundler #5159
Debug bundler #5159
Conversation
# require 'logger' | ||
# $logger = Logger.new(STDOUT) | ||
# $logger.level = Logger::DEBUG #WARN | ||
# Mimic ruby Logger, but forward to OpenStudio, so we don't have to worry about setting the LogLevel | ||
class ConvenienceLogger | ||
|
||
attr_accessor :level | ||
|
||
def initialize(log_level) | ||
@level = log_level | ||
end | ||
|
||
def trace? | ||
@level <= OpenStudio::Trace | ||
end | ||
|
||
def debug(msg) | ||
OpenStudio::logFree(OpenStudio::Debug, "ruby", msg) | ||
end | ||
|
||
def info(msg) | ||
OpenStudio::logFree(OpenStudio::Info, "ruby", msg) | ||
end | ||
|
||
def warn(msg) | ||
OpenStudio::logFree(OpenStudio::Warn, "ruby", msg) | ||
end | ||
|
||
def error(msg) | ||
OpenStudio::logFree(OpenStudio::Error, "ruby", msg) | ||
end | ||
|
||
def fatal(msg) | ||
OpenStudio::logFree(OpenStudio::Fatal, "ruby", msg) | ||
end | ||
|
||
end | ||
$logger = ConvenienceLogger.new(OpenStudio::Logger.instance.standardOutLogger.logLevel.get) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A clever way to keep the "$logger" code below working, while respecting the user's choice in terms of log level. PReviosuly the C++ CLI was lacking the ability to debug this stuff because the loglevel was set in stone to WARN.
if $logger.trace? | ||
ENV['DEBUG_RESOLVER'] = "1" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better than the ruby cli
rescue Gem::LoadError => e | ||
# There may be conflicts between the bundle and the embedded gems, | ||
# those will be logged here | ||
exception_msg = "Error activating gem #{spec.spec_file}: #{e.class}: #{e.message}\nTraceback:\n" | ||
exception_msg += e.backtrace.join("\n") | ||
STDERR.puts exception_msg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No matter what I do, I can't get the failure like I do in the ruby cli.
cd OpenStudio/src/cli/test/bundle
ruby --version
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
bundle install --path ./test_gems
C++
$ $os_build_rel/Products/openstudio --bundle Gemfile.lock --bundle_path './test_gems' --loglevel Debug test.rb
[...]
[ruby] <-2> Adding dependency on tbd '~> 3.4.1'
[ruby] <-2> Adding dependency on topolys '~> 0.6.2'
[ruby] <-2> Adding dependency on unicode-display_width '~> 2.5.0'
[ruby] <-2> Adding dependency on uuid '~> 2.3.9'
[ruby] <-2> Adding dependency on yamler '~> 0.1.0'
[ruby] <-2> Adding dependency on zliby '~> 0.0.5'
[ruby] <-2> Processing 136 activation requests
[ruby] <-2> Activating Bundler gem :/ruby/3.2.0/specifications/bundler-2.5.5.gemspec
Failed to execute '/home/julien/Software/Others/OpenStudio/src/cli/test/bundle/test.rb'
Classic
$ $os_build_rel/Products/openstudio classic --bundle Gemfile.lock --bundle_path './test_gems' --verbose test.rb
[...]
D, [2024-04-19T14:52:29.102995 #1611746] DEBUG -- : Processing 136 activation requests
D, [2024-04-19T14:52:29.119140 #1611746] DEBUG -- : Activating gem :/ruby/3.2.0/specifications/bundler-2.5.5.gemspec
Error executing argv: ["--bundle", "Gemfile.lock", "--bundle_path", "./test_gems", "--verbose", "test.rb"]
Error:
[!] There was an error parsing `Gemfile.lock`: syntax error, unexpected ':', expecting end-of-input - remote: http://rubygems.org/
^
. Bundler cannot continue.
# from /home/julien/Software/Others/OpenStudio/src/cli/test/bundle/Gemfile.lock:2
# -------------------------------------------
# GEM
> remote: http://rubygems.org/
# specs:
# -------------------------------------------
in :/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/dsl.rb:49:in `instance_eval'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/dsl.rb:49:in `eval_gemfile'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/dsl.rb:12:in `evaluate'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/definition.rb:38:in `build'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler.rb:326:in `definition'
:/openstudio_cli.rb:645:in `parse_main_args'
:/openstudio_cli.rb:791:in `execute'
:/openstudio_cli.rb:1994:in `<main>'
eval:233:in `eval'
eval:233:in `require_embedded_absolute'
eval:218:in `block in require_embedded'
eval:212:in `each'
eval:212:in `require_embedded'
eval:171:in `require'
eval:3:in `<main>'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kbenne that error makes zero sense to me.
…g messages This was missing compared to the CLI. @kbenne
… but not for trying to use --bundle
…it::TestCase/Minitest::Test/g' @`
I've modified dsl.rb locally in build/openstudio-gems which corresponds to https://github.com/rubygems/rubygems/blob/63bec47bb84105aec729bc12be02770d3f5b48e6/bundler/lib/bundler/dsl.rb#L44-L54
When I pass the "Gemfile" to the CLI (not the Gemfile.lock) I still have an error
|
Wait, so in that bit where we try to activate the bundler spec, we call bundler itself? Isn't that strange or something? |
So the error happens here: OpenStudio/ruby/bindings/InitRubyBindings.cpp Line 765 in 8b0f3a9
D, [2024-04-19T15:58:11.967007 #1633316] DEBUG -- : Activating gem :/ruby/3.2.0/specifications/bundler-2.5.5.gemspec
contents=
gemfile=/home/julien/Software/Others/OpenStudio/src/cli/test/bundle/Gemfile
@gemfile=/home/julien/Software/Others/OpenStudio/src/cli/test/bundle/Gemfile
expanded_gemfile_path=/home/julien/Software/Others/OpenStudio/src/cli/test/bundle/Gemfile
contents=source "https://rubygems.org"
# gem 'openstudio-workflow', '2.4.0' # This is compatible with bundler 2.5 / Ruby 3.2 (OS 3.8+), but **NOT** already older than currently used at this time
gem 'tilt', '2.0.8'
Error executing argv: ["--bundle", "Gemfile", "--bundle_path", "./test_gems", "--verbose", "test.rb"]
Error:
[!] There was an error parsing `Gemfile`: nil is not a class/module. Bundler cannot continue.
# from /home/julien/Software/Others/OpenStudio/src/cli/test/bundle/Gemfile:1
# -------------------------------------------
> source "https://rubygems.org"
#
# -------------------------------------------
in :/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/source/rubygems.rb:24:in `initialize'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/source_list.rb:12:in `new'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/source_list.rb:12:in `global_rubygems_source'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/source_list.rb:72:in `add_global_rubygems_remote'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/dsl.rb:180:in `source'
+/home/julien/Software/Others/OpenStudio/src/cli/test/bundle/Gemfile:1:in `eval_gemfile'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/dsl.rb:54:in `instance_eval'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/dsl.rb:54:in `eval_gemfile'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/dsl.rb:12:in `evaluate'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/definition.rb:38:in `build'
:/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler.rb:326:in `definition'
:/openstudio_cli.rb:645:in `parse_main_args'
:/openstudio_cli.rb:791:in `execute'
:/openstudio_cli.rb:1994:in `<main>'
eval:233:in `eval'
eval:233:in `require_embedded_absolute'
eval:218:in `block in require_embedded'
eval:212:in `each'
eval:212:in `require_embedded'
eval:171:in `require'
eval:3:in `<main>'
|
…'t one we can use
CI Results for cd134b6:
|
Pull request overview
Pull Request Author
src/model/test
)src/energyplus/Test
)src/osversion/VersionTranslator.cpp
)Labels:
IDDChange
APIChange
Pull Request - Ready for CI
so that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.