threedaymonk / htmlbeautifier

A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.
MIT License
325 stars 59 forks source link

`uninitialized constant Pathname` when running with `--lint-only` #64

Closed andyw8 closed 2 years ago

andyw8 commented 2 years ago

I think this is just missing a require "pathname":

$ htmlbeautifier **/*.html.erb --lint-only
Traceback (most recent call last):
        4: from /Users/andyw8/.gem/ruby/2.7.5/bin/htmlbeautifier:23:in `<main>'
        3: from /Users/andyw8/.gem/ruby/2.7.5/bin/htmlbeautifier:23:in `load'
        2: from /Users/andyw8/.gem/ruby/2.7.5/gems/htmlbeautifier-1.4.1/bin/htmlbeautifier:104:in `<top (required)>'
        1: from /Users/andyw8/.gem/ruby/2.7.5/gems/htmlbeautifier-1.4.1/bin/htmlbeautifier:104:in `map'
/Users/andyw8/.gem/ruby/2.7.5/gems/htmlbeautifier-1.4.1/bin/htmlbeautifier:105:in `block in <top (required)>': uninitialized constant Pathname (NameError)
$ ruby -v
ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [arm64-darwin21]
andyw8 commented 2 years ago

(when I run with bundle exec this doesn't happen, presumably because some other gem is already requiring Pathname).

mweitzel commented 2 years ago

If you need to run htmlbeautifer without bundle exec, I believe running it from generated binstubs resolves this issue.

andyw8 commented 2 years ago

@mweitzel It does, since the binstub includes a call to require "pathname", but I still think this is something the gem should handle.

andyw8 commented 2 years ago

I've opened https://github.com/threedaymonk/htmlbeautifier/pull/70 to fix this.

threedaymonk commented 2 years ago

Should be fixed by #69.