lassik / emacs-format-all-the-code

Auto-format source code in many languages with one command
https://melpa.org/#/format-all
MIT License
604 stars 105 forks source link

Unable to format with `ruff` #250

Closed chookity-pokk closed 8 months ago

chookity-pokk commented 8 months ago

I am trying to use ruff on a python file and I get the below error.

error: unexpected argument '--stdin-filename' found

  tip: to pass '--stdin-filename' as a value, use '-- --stdin-filename'

Usage: ruff format <--verbose|--quiet|--silent> [FILES]...

For more information, try '--help'.

I don't really know enough elisp to help here, sorry!

doolio commented 8 months ago

I can't reproduce this error. If I open an unformatted python file and M-x format-all-buffer I first see a list of formatters to choose from which I select ruff and then see the following messages. I'm not using any LSP client in this test.

Setting formatter to ruff
Reformatted!

Can you maybe detail the steps you follow that produces this error?

chookity-pokk commented 8 months ago

My steps are the same as yours. I also just uninstall ruff, closed emacs, reinstalled ruff (0.1.11), launched emacs again and got the same error. I have a different computer I can try this on and I'll see if it might be something going on with my laptop.

doolio commented 8 months ago

Yes, another data point could help. We are using the same version of ruff and I presume you are on the latest version of formall-all? I'm still using Emacs 27.1 though. You never said but I assume you see this error in the *Messages* buffer?

chookity-pokk commented 8 months ago

I got it working on my other computer. Same steps but this time ruff worked. So I am thinking it has to be an issue with MacOS or something. My work laptop is an M2 and the other laptop I tested with was running Arch. Both of which are running emacs 29.1.

You see this error in Messages buffer?

No, it's in a format-all-errors buffer and Messages just shows "Formatting error"

I am going to close this since this is likely either a MacOS problem, their Emacs problem or a problem that's hidden in my config.

Thank you for the help though!

doolio commented 8 months ago

No problem, glad you go it working on one machine at least.

chookity-pokk commented 8 months ago

I got it working on my Mac by using https://github.com/purcell/exec-path-from-shell with the setup

(package-install 'exec-path-from-shell)
(exec-path-from-shell-initialize)
doolio commented 8 months ago

Glad to hear it. Yes, exec-path-from-shell is by all accounts an essential package when working on a mac.