nebulab / erb-formatter

Format ERB files with speed and precision
MIT License
151 stars 25 forks source link

File.exists? error on first run #20

Closed wassimk closed 1 year ago

wassimk commented 1 year ago

I have a relatively new and tiny Rails 7.0.4.2 project running Ruby 3.2.1. I just added the erb-formatter to the Gemfile and ran the format command from the README, and I immediately got this. Any ideas?

❯ erb-format app/views/**/*.html.erb --write
/Users/wassim/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/erb-formatter-0.3.0/lib/erb/formatter/ignore_list.rb:4:in `initialize': undefined method `exists?' for File:Class (NoMethodError)

    @contents = contents || (File.exists?(ignore_list_path) ? File.read(ignore_list_path) : '')
                                 ^^^^^^^^
Did you mean?  exist?
        from /Users/wassim/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/erb-formatter-0.3.0/lib/erb/formatter/command_line.rb:48:in `new'
        from /Users/wassim/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/erb-formatter-0.3.0/lib/erb/formatter/command_line.rb:48:in `ignore_list'
        from /Users/wassim/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/erb-formatter-0.3.0/lib/erb/formatter/command_line.rb:68:in `block in run'
        from /Users/wassim/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/erb-formatter-0.3.0/lib/erb/formatter/command_line.rb:67:in `each'
        from /Users/wassim/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/erb-formatter-0.3.0/lib/erb/formatter/command_line.rb:67:in `run'
        from /Users/wassim/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/erb-formatter-0.3.0/exe/erb-format:5:in `<top (required)>'
        from /Users/wassim/.rbenv/versions/3.2.1/bin/erb-format:25:in `load'
        from /Users/wassim/.rbenv/versions/3.2.1/bin/erb-format:25:in `<main>'
nbelzer commented 1 year ago

Hey @wassimk, this has been fixed in erb-formatter 4.0+ (see related PR), could you try to upgrade?

wassimk commented 1 year ago

Thanks for pointing me in the right direction. I had another gem version constraining syntax tree, so it installed an older version. I should have caught that! It's resolved, and wow, the formatting is so beautiful.

I am looking forward to proposing this tool to my team.