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

(pnpm) Using tsx in postinstall script generates unexpected file at ./tsx-0/ #596

Closed
4 of 6 tasks
NamesMT opened this issue Jun 22, 2024 · 9 comments
Closed
4 of 6 tasks
Labels
bug Something isn't working

Comments

@NamesMT
Copy link

NamesMT commented Jun 22, 2024

Acknowledgements

  • I read the documentation and searched existing issues to avoid duplicates
  • I am reporting a confirmed bug (not seek debugging help)
  • I understand this is a collaborative project and relies on my contributions
  • I read and understood the Contribution guide

Minimal reproduction URL

https://stackblitz.com/github/namesmt/repro-tsx

Problem & expected behavior (under 200 words)

Alternative github repo because stackblitz could not load for me, idk if it's just me: https://github.com/NamesMT/repro-tsx

Simply run pnpm install, an unexpected file is created along with the folder tsx-0
image

It does not happen with normal npm

Bugs are expected to be fixed by those affected by it

  • I'm interested in working on this issue

Compensating engineering work will speed up resolution and support the project

  • I'm willing to offer $10 for financial support
@NamesMT NamesMT added bug Something isn't working pending triage labels Jun 22, 2024
@privatenumber
Copy link
Owner

I can't reproduce this on my end. Can you use GitHub Actions or something to demonstrate it?

@privatenumber privatenumber closed this as not planned Won't fix, can't repro, duplicate, stale Jun 22, 2024
@NamesMT
Copy link
Author

NamesMT commented Jun 23, 2024

Hello @privatenumber,

Here is a oneline reproduction using docker run: docker run -it --rm namesmt/images-alpine:node-dev zsh -c "cd home && nlx giget gh:namesmt/repro-tsx repro-tsx && cd repro-tsx && ni && ls && ls tsx-0 && zsh"

image

@privatenumber
Copy link
Owner

privatenumber commented Jun 23, 2024

Sorry but a screenshot doesn't help. And I don't use Docker.

I need a reproduction env for me to debug and test fixes in. GitHub Actions or any kind of CI would work best.

NamesMT added a commit to NamesMT/repro-tsx-action that referenced this issue Jun 23, 2024
@NamesMT
Copy link
Author

NamesMT commented Jun 23, 2024

Hello @privatenumber, idk why but for github's default runners I could not reproduce it, but does indeed exists because I could reproduce the issue on my work machine which uses plain Ubuntu,

I have also do more tests and it is indeed reproducible on various docker images: ubuntu, node/node:slim, alpine.

I have also able to reproduce it on my company Gitlab CI with node:alpine image.

For your convenience, I have setup a repo in which I was able to use Github Actions to reproduce it (using docker container action): https://github.com/NamesMT/repro-tsx-action
You could simply fork it and push commits/PR to test.

Thanks a lot.

@privatenumber
Copy link
Owner

I appreciate it, thanks @NamesMT

I haven't confirmed this, but I believe this is actually pnpm/pnpm#7330

tsx creates a cache directory in os.tmpdir() which implies pnpm in Alpine is returning the current working directory in the env variables.

Will take a closer look later on.

@privatenumber privatenumber reopened this Jun 23, 2024
@NamesMT
Copy link
Author

NamesMT commented Jun 23, 2024

That seems to be it, maybe we can apply a workaround like jiti#123?

@privatenumber
Copy link
Owner

If it's rooted in pnpm, then it's not a tsx bug. And I would rather not patch bugs from other tools via tsx.

This is for the same reasons I would relay any Node bugs we get to https://github.com/nodejs/node. Encouraging fixes to be made in the right places maximizes benefit to the community.

Can you verify this is what's causing it by running pnpm with unsafe-perm? https://github.com/pnpm/npm-lifecycle/blob/1e0f149176877f906968a01087cf63290652ccbc/index.js#L100
If so, try opening a PR there.

@NamesMT
Copy link
Author

NamesMT commented Jun 24, 2024

Yes I can verify that running pnpm with unsafe-perm, the issue is not present, thanks a lot for finding the root cause.
Don't have time to open a PR yet but I'll do it when I do and no one has created one specific to it.

@privatenumber
Copy link
Owner

Closing as it's a bug in pnpm rather than tsx

@privatenumber privatenumber closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants