davetron5000 / gli

Make awesome command-line applications the easy way
http://davetron5000.github.io/gli
Apache License 2.0
1.26k stars 102 forks source link

Can't build/run tests - due to old ruby version / minitest changes? #323

Closed rsanheim closed 1 month ago

rsanheim commented 1 month ago

I was poking around in gli and wanted to take a shot at adding some features to the init command, but wasn't able to get it run tests locally. Part of the issue is that it looks like things are locked to ruby 2.7.1 as well as an old version of Minitest before the MiniTest -> Minitest rename.

I first tried using Ruby 3.3.4 locally locking to Minitest v4, before the rename, but think I hit other minitest issues:

~/src/oss/gli (main)⚡] [1] (26.5s) > be rake
/Users/rsanheim/.asdf/installs/ruby/3.3.4/lib/ruby/3.3.0/bundled_gems.rb:74:in `require': cannot load such file -- minitest (LoadError)
Did you mean?  minitest/unit
    from /Users/rsanheim/.asdf/installs/ruby/3.3.4/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
    from /Users/rsanheim/src/oss/gli/test/unit/test_helper.rb:1:in `<top (required)>'
    from /Users/rsanheim/src/oss/gli/test/unit/command_finder_test.rb:1:in `require_relative'
    from /Users/rsanheim/src/oss/gli/test/unit/command_finder_test.rb:1:in `<top (required)>'
    from /Users/rsanheim/.asdf/installs/ruby/3.3.4/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'
    from /Users/rsanheim/.asdf/installs/ruby/3.3.4/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
    from /Users/rsanheim/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb:21:in `block in <main>'
    from /Users/rsanheim/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb:6:in `select'
    from /Users/rsanheim/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb:6:in `<main>'
rake aborted!
Command failed with status (1)
/Users/rsanheim/.asdf/installs/ruby/3.3.4/bin/bundle:25:in `load'
/Users/rsanheim/.asdf/installs/ruby/3.3.4/bin/bundle:25:in `<main>'
Tasks: TOP => default => test:unit

Then I tried ruby 2.7.6, which I think is one of the older Rubies still installable on ARM macs, and still hit some test issues:

~/src/oss/gli (main)⚡] [1] (436ms) > bundle exec rake
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/text_wrapper.rb:48: warning: character class has duplicated range: /[\n\s]*\Z/
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/global_help_format.rb:14: warning: assigned but unused variable - program_desc
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/global_help_format.rb:28: warning: assigned but unused variable - commands
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/global_help_format.rb:30: warning: assigned but unused variable - global_option_descriptions
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/command_help_format.rb:16: warning: assigned but unused variable - command_wrapper
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/command_help_format.rb:17: warning: assigned but unused variable - wrapper
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/command_help_format.rb:19: warning: assigned but unused variable - options_description
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/command_help_format.rb:20: warning: assigned but unused variable - commands_description
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/command_help_format.rb:21: warning: assigned but unused variable - command_examples
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/command_help_format.rb:23: warning: assigned but unused variable - synopses
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/full_synopsis_formatter.rb:29: warning: assigned but unused variable - sub_options_doc
/Users/rsanheim/src/oss/gli/lib/gli/commands/help_modules/full_synopsis_formatter.rb:92: warning: assigned but unused variable - synopses
/Users/rsanheim/src/oss/gli/lib/gli/commands/initconfig.rb:1: warning: /Users/rsanheim/src/oss/gli/lib/gli/commands/initconfig.rb:1: warning: loading in progress, circular require considered harmful - /Users/rsanheim/src/oss/gli/lib/gli.rb
    from /Users/rsanheim/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb:6:in  `<main>'
    from /Users/rsanheim/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb:6:in  `select'
    from /Users/rsanheim/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb:21:in  `block in <main>'
    from /Users/rsanheim/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb:21:in  `require'
    from /Users/rsanheim/src/oss/gli/test/unit/command_finder_test.rb:1:in  `<top (required)>'
    from /Users/rsanheim/src/oss/gli/test/unit/command_finder_test.rb:1:in  `require_relative'
    from /Users/rsanheim/src/oss/gli/test/unit/test_helper.rb:2:in  `<top (required)>'
    from /Users/rsanheim/src/oss/gli/test/unit/test_helper.rb:2:in  `require'
    from /Users/rsanheim/src/oss/gli/lib/gli.rb:21:in  `<top (required)>'
    from /Users/rsanheim/src/oss/gli/lib/gli.rb:21:in  `require'
    from /Users/rsanheim/src/oss/gli/lib/gli/commands/initconfig.rb:1:in  `<top (required)>'
    from /Users/rsanheim/src/oss/gli/lib/gli/commands/initconfig.rb:1:in  `require'

/Users/rsanheim/src/oss/gli/lib/gli/commands/doc.rb:145: warning: assigned but unused variable - ex
Traceback (most recent call last):
    5: from /Users/rsanheim/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb:6:in `<main>'
    4: from /Users/rsanheim/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb:6:in `select'
    3: from /Users/rsanheim/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb:21:in `block in <main>'
    2: from /Users/rsanheim/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb:21:in `require'
    1: from /Users/rsanheim/src/oss/gli/test/unit/command_finder_test.rb:3:in `<top (required)>'
/Users/rsanheim/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/minitest-4.7.5/lib/minitest/unit.rb:19:in `const_missing': uninitialized constant MiniTest::Test (NameError)
rake aborted!
Command failed with status (1)
/Users/rsanheim/.asdf/installs/ruby/2.7.6/bin/bundle:23:in `load'
/Users/rsanheim/.asdf/installs/ruby/2.7.6/bin/bundle:23:in `<main>'
Tasks: TOP => default => test:unit
(See full trace by running task with --trace)

Not sure where to go from here, as i'm not sure what version of minitest should actually be in use here?

rsanheim commented 1 month ago

Figuring some things out via https://github.com/freerange/mocha/issues/614 and https://github.com/minitest/minitest/issues/960 ...

rsanheim commented 1 month ago

Fixed in #324

davetron5000 commented 1 month ago

I'm not seeing this, but I also haven't updated the infrastructure for the latest Rubies. I'm using Ruby 3.2.4 (which happens to be what I have) and bin/rake succeeds without any issues. By default, it picked up Minitest 5.18.1 which is somewhat recent.

See https://github.com/davetron5000/gli/tree/docker-devcontainer for what I have been using locally. Also, the code doesn't reference the old constant, so not sure how that could be a problem.

Can you try with the oldest supported Ruby, which is 3.1?

Here is the workflow:

your-computer> dx/setup
your-computer> dx/buid
your-computer> dx/start
your-computer> dx/exec bash
inside-dev-container> bin/setup
inside-dev-container> bin/rake

That, for me, works without any issues.

That said, I am definitely unclear about if I need minitest, where it is in the Ruby stdlib or what happened there, so this setup may happen to work, but was created a long time ago and not changed much since.

davetron5000 commented 1 month ago

OK, I have recreated this - not sure what I was doing before. Will examine your PR and be back in touch

davetron5000 commented 1 month ago

See #325 for the fix. Thanks again for finding this!

rsanheim commented 1 month ago

Thanks for the fix!

I wasn't aware of the docker dev setup (as you discovered and documented 😁 ), and normally just prefer to develop gems & libraries locally if the dependency list is small. I'm sure w/ #325 either way will work easily now 👍 .