prettier / plugin-ruby

Prettier Ruby Plugin
MIT License
1.47k stars 98 forks source link

Couldn't resolve parser "ruby" #1392

Closed raxod502 closed 1 year ago

raxod502 commented 1 year ago

Hi, I maintain an editor package that configures and runs code formatters. My CI installs supported code formatters and runs them to ensure they work with the provided configuration. Recently the Ruby plugin for Prettier has stopped working in my CI and I've been unable to figure out why. Here's a Dockerfile that reproduces the issue:

FROM ubuntu:20.04

RUN apt-get update

RUN apt-get install -y ca-certificates curl gnupg lsb-release
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
RUN echo "deb [arch=amd64] https://deb.nodesource.com/node_20.x focal main" | tee /etc/apt/sources.list.d/nodejs.list
RUN apt-get update

RUN apt-get install -y nodejs
RUN apt-get install -y ruby ruby-dev
RUN apt-get install -y gcc make

RUN gem install rbs -v 3.1.3
RUN gem install prettier_print
RUN gem install syntax_tree
RUN gem install syntax_tree-haml
RUN gem install syntax_tree-rbs

RUN npm install -g prettier @prettier/plugin-ruby

RUN echo "puts 'hello world'" | prettier --stdin-filepath=main.rb --parser=ruby

(Un)expected output:

 => ERROR [16/16] RUN echo "puts 'hello world'" | prettier --stdin-filepath=main.rb --parser=ruby                                                                                        0.7s 
------                                                                                                                                                                                        
 > [16/16] RUN echo "puts 'hello world'" | prettier --stdin-filepath=main.rb --parser=ruby:                                                                                                   
0.644 [error] Couldn't resolve parser "ruby".                                                                                                                                                 

What am I missing about the dependencies here? It seems like @prettier/plugin-ruby is not detected by prettier despite being installed. Changing --parser=ruby to --parser=@prettier/plugin-ruby produces the same result (Couldn't resolve parser "@prettier/plugin-ruby").

Let me know if this is an issue further upstream (e.g., with Prettier or NPM), or if it's a configuration problem on my end.

kddnewton commented 1 year ago

You have to specify --plugin not --parser. See the docs here: https://prettier.io/docs/en/plugins