codidact / qpixel

Q&A-based community knowledge-sharing software
https://codidact.com
GNU Affero General Public License v3.0
378 stars 69 forks source link

Rails error "wrong number of arguments" #1308

Closed trichoplax closed 4 months ago

trichoplax commented 5 months ago

Describe the bug Trying to run Rails with either rails s or rails c gives an error wrong number of arguments (given 3, expected 1..2).

This may be due to the change in how positional arguments are handled in Ruby 3.

To Reproduce Steps to reproduce the behavior:

  1. Install QPixel following the installation instructions, with Ruby 3.3.0 (I used RVM on Fedora Linux).
  2. Try to use rails c and see the following error message:
    /home/trichoplax/.rvm/gems/ruby-3.3.0/gems/css_parser-1.11.0/lib/css_parser/regexps.rb:11:in `initialize': wrong number of arguments (given 3, expected 1..2) (ArgumentError)

This appears to be fixable by upgrading the css_parser gem. I'm not sure why my previous installations of QPixel with Ruby 3 have worked without this error though.

hmltn-0 commented 5 months ago

Does rails c depend on the Qpixel installation? Or just the gemfile? Im new to Ruby but was under the impression rails c would just launch a console but wouldn't necessarily run a lot of app-specific things before launching. https://guides.rubyonrails.org/command_line.html

trichoplax commented 5 months ago

I'm not sure why opening the console from the terminal would depend on css_parser, but it may not be QPixel related. If I enter which rails I get the same location regardless of whether I am in the QPixel directory, and that location is where the gems appear to be stored. So it appears that rails c depends only on the gem file.

trichoplax commented 5 months ago

I suppose the link to QPixel is that Gemfile.lock in the QPixel repository specifies the version of the css_parser gem that is then shared by anything that uses the gem. I don't understand how gems work but the pull request updating css_parser fixes the problem on my machine.

ArtOfCode- commented 5 months ago

I can't remember if we support 3.3 or not - last I recall we upgraded to 3.1, can't remember if we've gone beyond that. Are you able to check with 3.1 without upgrading css_parser and see if that works (and vice-versa, if you can - if you upgrade the css_parser gem and use 3.1, does that work)?

trichoplax commented 5 months ago

Thanks for pointing this out. I've now checked with Ruby 3.1.0 and css_parser 1.11.0 (the version from the current Gemfile.lock on the develop branch) and it works fine. So the upgrade of css_parser won't be needed until we upgrade Ruby.

trichoplax commented 5 months ago

I've converted the associated pull request to a draft now that I understand that it is not needed until we upgrade Ruby.

Out of interest, I've just tested that the newer version of css_parser (1.16.0) works fine with Ruby 3.1.0 so there doesn't seem any reason not to upgrade earlier if desired (it's just not necessary).

ArtOfCode- commented 4 months ago

In that case let's upgrade the gem if it works with both. Wider support in this case is not a bad thing.