gjtorikian / html-proofer

Test your rendered HTML files to make sure they're accurate.
MIT License
1.57k stars 196 forks source link

Ruby 3.3.0 parameters bug #814

Closed dmundra closed 5 months ago

dmundra commented 6 months ago

I updated to Ruby 3.3.0 when I run htmlproofer the parameters --enforce_https and --check_external_hash that use true/false are getting added to the 'check_file' function causing an error. Here is an example output:

bundle exec htmlproofer --ignore-status-codes "999,429,403,302,0" --ignore-urls "/fonts.gstatic.com/" --enforce_https "false" --check_external_hash "false" ./_site

bundler: failed to load command: htmlproofer (/Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/bin/htmlproofer)
/Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/html-proofer-5.0.8/lib/html_proofer.rb:29:in `check_file': false,false,./_site does not exist (ArgumentError)

      raise ArgumentError, "#{file} does not exist" unless File.exist?(file)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/html-proofer-5.0.8/lib/html_proofer/cli.rb:24:in `run'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/html-proofer-5.0.8/exe/htmlproofer:14:in `block in <top (required)>'
    from /usr/local/Cellar/ruby/3.3.0/lib/ruby/3.3.0/benchmark.rb:313:in `realtime'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/html-proofer-5.0.8/exe/htmlproofer:14:in `<top (required)>'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/bin/htmlproofer:25:in `load'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/bin/htmlproofer:25:in `<top (required)>'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:58:in `load'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:58:in `kernel_load'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:23:in `run'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/lib/bundler/cli.rb:451:in `exec'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/lib/bundler/cli.rb:34:in `dispatch'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/lib/bundler/cli.rb:28:in `start'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/exe/bundle:28:in `block in <top (required)>'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
    from /Users/dmundra/workspace/accessibility/accessibility/vendor/ruby/ruby/3.3.0/gems/bundler-2.5.6/exe/bundle:20:in `<top (required)>'
    from /usr/local/lib/ruby/gems/3.3.0/bin/bundle:25:in `load'
    from /usr/local/lib/ruby/gems/3.3.0/bin/bundle:25:in `<main>'
dmundra commented 6 months ago

Removing --enforce_https and --check_external_hash does work. So not sure why those args are being picked up.

riccardoporreca commented 5 months ago

@dmundra, you have been upgrading not only the version of Ruby, but also and most importantly html-proofer from v4 to v5, which has refactored the CLI arguments, see #758.

The error you get clearly points to the fact that "false" is interpreted as an input to be checked, because since v5 boolean CLI arguments are simply stated as e.g. --[no-]check-external-hash. Run htmlproofer --help for help on the CLI usage.

dmundra commented 4 months ago

Ah got it. Thank you for the clarification.