Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make fmt-test FORMATTERS=prettier-astro error #354

Open
panglars opened this issue Mar 9, 2025 · 5 comments
Open

make fmt-test FORMATTERS=prettier-astro error #354

panglars opened this issue Mar 9, 2025 · 5 comments

Comments

@panglars
Copy link

panglars commented Mar 9, 2025

I want to contribut a new formatter for astro,but I cat't pass the fmt-test in docker shell.
This is code I add ,these codes work fine on my local machine.I'm not sure what's wrong there.

that is my error report

apheleia@c87d32dc326b:/src$ make fmt-test FORMATTERS=prettier-astro

Debugger entered--Lisp error: (error "Formatter prettier-astro exited with status 1")
  signal(error ("Formatter prettier-astro exited with status 1"))
  error("Formatter %s exited with status %S" "prettier-astro" 1)
  (if (= 0 exit-status) nil (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (insert-file-contents stderr-file) (princ (buffer-string))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (error "Formatter %s exited with status %S" forma...[truncated]
  (if (functionp command) (progn (funcall command :buffer (current-buffer) :scratch (current-buffer) :formatter formatter :callback #'(lambda nil)) (copy-to-buffer stdout-buffer (point-min) (point-max))) (let ((ctx (apheleia--formatter-context (intern formatter) command nil nil))) (setq command (cons (apheleia-formatte...[truncated]
  (save-current-buffer (set-buffer (find-file-noselect in-temp-file)) (setq stdout-buffer (get-buffer-create (format "*apheleia-ft-stdout-%S%s" formatter extension))) (save-current-buffer (set-buffer stdout-buffer) (erase-buffer)) (if (functionp command) (progn (funcall command :buffer (current-buffer) :scratch (curren...[truncated]
  (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-inputs formatter in-file)) (out-temp-file nil) (command (alist-get (intern formatter) apheleia-formatters)) (syms nil) (stdout-buffer nil) (stderr-file (make-temp-file "apheleia-ft-stderr-")) (...[truncated]
  (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-inputs formatter in-file)) (out-temp-file nil) (command (alist-get (intern formatter) apheleia-formatters)) (syms nil) (stdout-buffer nil) (stderr-file (m...[truncated]
  (while --dolist-tail-- (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-inputs formatter in-file)) (out-temp-file nil) (command (alist-get (intern formatter) apheleia-formatters)) (syms nil) (stdout-buff...[truncated]
  (let ((--dolist-tail-- (apheleia-ft--input-files formatter))) (while --dolist-tail-- (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-inputs formatter in-file)) (out-temp-file nil) (command (alist-get (i...[truncated]
  (let ((formatter (car --dolist-tail--))) (let ((--dolist-tail-- (apheleia-ft--input-files formatter))) (while --dolist-tail-- (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-inputs formatter in-file)) (...[truncated]
  (while --dolist-tail-- (let ((formatter (car --dolist-tail--))) (let ((--dolist-tail-- (apheleia-ft--input-files formatter))) (while --dolist-tail-- (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-input...[truncated]
  (let ((--dolist-tail-- (or formatters (apheleia-ft--get-formatters)))) (while --dolist-tail-- (let ((formatter (car --dolist-tail--))) (let ((--dolist-tail-- (apheleia-ft--input-files formatter))) (while --dolist-tail-- (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (...[truncated]
  apheleia-ft-test()
  funcall-interactively(apheleia-ft-test)
  call-interactively(apheleia-ft-test nil nil)
  command-execute(apheleia-ft-test)
  command-line-1(("-L" "." "-L" "test/formatters" "-l" "apheleia-ft" "--eval" "(setq debug-on-error t)" "--eval" "(setq backtrace-line-length 0)" "-f" "apheleia-ft-test"))
  command-line()
  normal-top-level()

[error] Cannot find package 'prettier-plugin-astro' imported from /tmp/apheleia-ft/noop.js
make: *** [Makefile:114: fmt-test] Error 255

@raxod502
Copy link
Member

raxod502 commented Mar 9, 2025

Are you able to reproduce the error by attempting to invoke prettier interactively from the command line from within the Docker shell?

@panglars
Copy link
Author

apheleia@ca61d3f59d29:/src$ prettier --plugin="prettier-plugin-astro" --parser=astro ./test/formatters/samplecode/prettier-astro/in.astro 
[error] Cannot find package 'prettier-plugin-astro' imported from /src/noop.js

maybe I need add

{
  "plugins": ["prettier-plugin-astro"],
  "overrides": [
    {
      "files": "*.astro",
      "options": {
        "parser": "astro",
      }
    }
  ]
}

in .prettierrc in somewhere

@raxod502
Copy link
Member

Oh right. Yeah, I think there is something like that that I remember having to do for prettier-ruby, maybe the same here?

@panglars
Copy link
Author

I tried, but failed.
prettier-ruby is also failed in this time

❯ make fmt-docker
apheleia@3d40fe637bc5:/src$ make fmt-test FORMATTERS=prettier-ruby 
Debugger entered--Lisp error: (void-function make-closure)
  make-closure(#f(compiled-function (arg) #<bytecode 0x158b89ab1ca1>) "/tmp/apheleia-ft/in.rb" ((file filepath)))
  apheleia--replq(("apheleia-npx" "prettier" "--stdin-filepath" filepath "--plugin=@prettier/plugin-ruby" "--parser=ruby" (apheleia-formatters-js-indent "--use-tabs" "--tab-width")) (file filepath) "/tmp/apheleia-ft/in.rb")
  apheleia--formatter-context(prettier-ruby ("apheleia-npx" "prettier" "--stdin-filepath" filepath "--plugin=@prettier/plugin-ruby" "--parser=ruby" (apheleia-formatters-js-indent "--use-tabs" "--tab-width")) nil nil)
  (let ((ctx (apheleia--formatter-context (intern formatter) command nil nil))) (setq command (cons (apheleia-formatter--arg1 ctx) (apheleia-formatter--argv ctx)) out-temp-file (apheleia-formatter--output-fname ctx)))
  (if (functionp command) (progn (funcall command :buffer (current-buffer) :scratch (current-buffer) :formatter formatter :callback #'(lambda nil)) (copy-to-buffer stdout-buffer (point-min) (point-max))) (let ((ctx (apheleia--formatter-context (intern formatter) command nil nil))) (setq command (cons (apheleia-formatte...[truncated]
  (save-current-buffer (set-buffer (find-file-noselect in-temp-file)) (setq stdout-buffer (get-buffer-create (format "*apheleia-ft-stdout-%S%s" formatter extension))) (save-current-buffer (set-buffer stdout-buffer) (erase-buffer)) (if (functionp command) (progn (funcall command :buffer (current-buffer) :scratch (curren...[truncated]
  (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-inputs formatter in-file)) (out-temp-file nil) (command (alist-get (intern formatter) apheleia-formatters)) (syms nil) (stdout-buffer nil) (stderr-file (make-temp-file "apheleia-ft-stderr-")) (...[truncated]
  (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-inputs formatter in-file)) (out-temp-file nil) (command (alist-get (intern formatter) apheleia-formatters)) (syms nil) (stdout-buffer nil) (stderr-file (m...[truncated]
  (while --dolist-tail-- (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-inputs formatter in-file)) (out-temp-file nil) (command (alist-get (intern formatter) apheleia-formatters)) (syms nil) (stdout-buff...[truncated]
  (let ((--dolist-tail-- (apheleia-ft--input-files formatter))) (while --dolist-tail-- (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-inputs formatter in-file)) (out-temp-file nil) (command (alist-get (i...[truncated]
  (let ((formatter (car --dolist-tail--))) (let ((--dolist-tail-- (apheleia-ft--input-files formatter))) (while --dolist-tail-- (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-inputs formatter in-file)) (...[truncated]
  (while --dolist-tail-- (let ((formatter (car --dolist-tail--))) (let ((--dolist-tail-- (apheleia-ft--input-files formatter))) (while --dolist-tail-- (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (apheleia-ft--read-file in-file)) (in-temp-file (apheleia-ft--copy-input...[truncated]
  (let ((--dolist-tail-- (or formatters (apheleia-ft--get-formatters)))) (while --dolist-tail-- (let ((formatter (car --dolist-tail--))) (let ((--dolist-tail-- (apheleia-ft--input-files formatter))) (while --dolist-tail-- (let ((in-file (car --dolist-tail--))) (let* ((extension (file-name-extension in-file)) (in-text (...[truncated]
  apheleia-ft-test()
  funcall-interactively(apheleia-ft-test)
  call-interactively(apheleia-ft-test nil nil)
  command-execute(apheleia-ft-test)
  command-line-1(("-L" "." "-L" "test/formatters" "-l" "apheleia-ft" "--eval" "(setq debug-on-error t)" "--eval" "(setq backtrace-line-length 0)" "-f" "apheleia-ft-test"))
  command-line()
  normal-top-level()

make: *** [Makefile:114: fmt-test] Error 255
apheleia@3d40fe637bc5:/src$ 
exit
exit status 2
make: *** [Makefile:100: fmt-docker] Error 2

I think it's a path problem. I'll look into it later.

@raxod502
Copy link
Member

For that one, you probably need to re-run byte-compilation after changing Emacs version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants