Skip to content

Handle Windows and remote buffers using default formatters #357

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jkxyz
Copy link
Contributor

@jkxyz jkxyz commented Mar 30, 2025

Various fixes to ensure that the default formatters work over Tramp
and on Windows:

  1. Replace the apheleia-npx command with npx when the buffer is remote
    or running on Windows. This uses the built-in npx handling to lookup
    the binary, so npx never gets called. Since the apheleia-npx script
    isn't available on remote hosts, it makes sense to remove this. The
    same is done for Windows to capture the case of using WSL, in which
    case calling bash will enter WSL and so the script cannot be accessed
    using the Windows path.

  2. Use local file name when returning binary path.

  3. Don't use executable-find if the binary is already an absolute path.

  4. Pass the -l option to sh to ensure that it loads the user's profile.

Various fixes to ensure that the default formatters work over Tramp
and on Windows:

1. Replace the apheleia-npx command with npx when the buffer is remote
or running on Windows. This uses the built-in npx handling to lookup
the binary, so npx never gets called. Since the apheleia-npx script
isn't available on remote hosts, it makes sense to remove this. The
same is done for Windows to capture the case of using WSL, in which
case calling bash will enter WSL and so the script cannot be accessed
using the Windows path.

2. Use local file name when returning binary path.

3. Don't use executable-find if the binary is already an absolute path.

4. Pass the -l option to sh to ensure that it loads the user's profile.
Comment on lines +975 to +979
;; Just use npx when buffer is remote or we're running on Windows,
;; since in these cases bash won't be able to find the script
(when (and (member "apheleia-npx" command)
(or run-on-remote (eq system-type 'windows-nt)))
(setq command (cons 'npx (remove "apheleia-npx" command))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be an issue for any of the scripts in the Apheleia scripts directory, just just the npx one. What would you think of having Apheleia copy the script to the remote host before first execution, if anything apheleia-prefixed is used in the command?

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

Successfully merging this pull request may close these issues.

2 participants