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

Prettier should be able to resolve symlinks when explicitly passed. #15723

Closed
charlesoconor opened this issue Nov 28, 2023 · 8 comments
Closed
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@charlesoconor
Copy link

charlesoconor commented Nov 28, 2023

Environments:

  • Prettier Version: 3.1.0
  • Running Prettier via: cli in bazel
  • Runtime: Nodejs 18 and 20
  • Operating System: mac OS
  • Prettier plugins (if any):

Steps to reproduce:

$ touch t.js
$ ln -s t.js link.js
$ ./node_modules/.bin/prettier --check link.js
Checking formatting...
[error] Explicitly specified pattern "link.js" is a symbolic link.
All matched files use Prettier code style!

This change was introduced here. #14627

Expected behavior:

Prettier doesn't seem to have a way for a user to supply explicit paths that should be allowed to resolve symlinks. There are a number of reasons why symlinks might be used. For my use case, I'm using bazel to build and test. One of the core things bazel does to ensure hermeticity is to sandbox each execution. A sandbox will only have the required inputs and outputs for each action. To create these sandboxes quickly on Mac symlinks are used not to copy the files all the time.

Missed this in my CI system since Linux sandboxes in a slightly different way and creates hard links that then get cleaned up.

Actual behavior:

Fails when a symlink is passed.

It would be nice if there was a way to turn off this check as an option on the CLI or in the config. Since the issue, this was trying to fix where circular links cause a stack overflow, which won't happen if the symlinks are created in a reasonable way. Allowing a user to opt into turning off this check seems to me the correct way to go. When someone is setting up the tool for the first time they still have the default protection in default behavior but allowing this to be turned off allows for more complicated workflows that are currently broken.

@junaga
Copy link

junaga commented Nov 28, 2023

lmao, what is the prettier team doing

@sanmai-NL
Copy link
Contributor

I addressed this issue in #15533. Please upvote or review there.

@junaga
Copy link

junaga commented Dec 9, 2023

@sosukesuzuki you are not reducing complexity, you are sabotaging developers, today. thinking that prettier is that solution, is comical. AI will replace you + this repo.

@EldinZaimovic
Copy link

Is it now possible to use symlinks or I should revert to 2.8.8 ?

@sanmai-NL
Copy link
Contributor

It's not possible. It requires some implementation work.

@EldinZaimovic
Copy link

can we expect it in future versions?

@sanmai-NL
Copy link
Contributor

I don't know. I made a PR and I'm not much of a JavaScript programmer. Maybe you can too?

@pauldraper
Copy link

https://prettier.io/blog/2023/07/05/3.0.0.html#dont-expand-globs-via-symbolic-links-14627httpsgithubcomprettierprettierpull14627-by-anderskhttpsgithubcomandersk

Don’t expand globs via symbolic links (#14627 by @andersk)
Prettier no longer follows symbolic links while expanding command line arguments. This avoids problems in many scenarios such as symlinks outside the source tree, symlinks to ignored files, and cycles of symlinks.

I don't understand either, but this was a deliberate choice.

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Apr 7, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

6 participants