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

fix(docker): node-jiti directory created in project root #120

Closed
dargmuesli opened this issue Feb 23, 2023 · 10 comments · Fixed by #123
Closed

fix(docker): node-jiti directory created in project root #120

dargmuesli opened this issue Feb 23, 2023 · 10 comments · Fixed by #123

Comments

@dargmuesli
Copy link
Contributor

dargmuesli commented Feb 23, 2023

Environment

Docker
jiti 1.17.1
node 19.7.0-alpine

Reproduction

https://github.com/dargmuesli/nuxt-jiti

Describe the bug

  1. docker build -t nuxt-jiti .
  2. docker run --rm -it nuxt-jiti /bin/sh
  3. ls -la
  4. see that there is a node-jiti directory in the project's root

I'd expect the directory to be under /tmp.

Additional context

  1. remove "postinstall": "nuxt prepare" from the package.json
  2. append RUN pnpm nuxt prepare to the Dockerfile
  3. run all steps above
  4. see that node-jiti is created in /tmp, as expected
@pi0
Copy link
Member

pi0 commented Feb 24, 2023

Hi thanks for reporting the issue and repro. I still didn't check repro but we do use os.tmpDir() it is strange not happening. Is tmpDir inside container also / ??

@dargmuesli
Copy link
Contributor Author

dargmuesli commented Feb 24, 2023

I've checked that as well and looked into the code, I'm wondering the same. $TMPDIR is /tmp inside that container. Almost sounds like a NodeJS bug on alpine Linux maybe.

@dargmuesli
Copy link
Contributor Author

dargmuesli commented Feb 27, 2023

Manually running path.join(os.tmpdir(), "node-jiti") works without a flaw.

/srv/app # node
Welcome to Node.js v19.7.0.
Type ".help" for more information.
> path.join(os.tmpdir(), "node-jiti")
'/tmp/node-jiti'

The difference lies in whether nuxt prepare is run in the postinstall hook or outside. How could that be? 🤔

@dargmuesli
Copy link
Contributor Author

dargmuesli commented Feb 27, 2023

It seems this is a problem with pnpm only. I've updated the linked repo and created a ticket for pnpm:

As it looks like this is not a problem with this repo, I'm closing this issue.

@pi0
Copy link
Member

pi0 commented Feb 27, 2023

Nice finding!! Is there a way we can hotfix maybe detecting TMPDIR===CWD()?

@dargmuesli
Copy link
Contributor Author

We could detect that, but I don't know what we shall set it to then... 🤔

@pi0
Copy link
Member

pi0 commented Feb 27, 2023

we can try to clear the env, use os.tmpdir() (and restore to keep pnpm working as it was)

@pi0
Copy link
Member

pi0 commented Feb 27, 2023

image

@dargmuesli
Copy link
Contributor Author

Good idea, that looks like a fair workaround! 🙌

@dargmuesli
Copy link
Contributor Author

Reopening this to have it closed by the #123

@dargmuesli dargmuesli reopened this Mar 6, 2023
@pi0 pi0 closed this as completed in #123 Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants