4

Hey I ran export TMPDIR=~/tmp/ and it changed my temp folder. I was trying to get a Go backend working and an article suggested it. I was a little trigger happy and now this is causing issues with a once working Node app I have.

The node app is now saying:

Error: ENOENT: no such file or directory, mkdtemp '/Users/myName/tmp/puppeteer_dev_chrome_profile-VYUdd3'

Is there a way to revert the temp var back and fix this problem. Where do env vars live on a mac. I also updated my mac from Mojave to Catalina during this process. Not sure if that has something to do with it too.

Any help would be appreciated.

0

2 Answers 2

2

TMPDIR needs to point to an existing, user-writable directory. So setting it to ~/tmp is fine as long as ~/tmp actually exists.

By default it points to /var/folders/_d/_SOMERANDOMLOOKINGSTRING/T/ to ensure that every user has their private temp folder. If for whatever reason you loose the definition you can run find /var/folders/_d -user $(whoami) -type d -maxdepth 1 to check that it still exists, and then do

export TMPDIR="$(find /var/folders/_d -user $(whoami) -type d -maxdepth 1)"

to set it back.

In case it doesn't exist any more (which is unlikely as it is protected by SIP), either reboot to have it recreated or run (all three lines)

export TMPDIR=/tmp
export TMPDIR="$(mktemp -d)"
chmod 700 "${TMPDIR}"

to create and assign a new temp folder.

-1

Found the answer. I ran export TMPDIR=~/ to reset the TMPDIR to the root folder which has a tmp folder. You can check that the tmp folder is in the root by running cd / then ls -a to see the tmp directory you routed it to.

After resetting the temp to the mac's root directory all node applications ran as expected.

3
  • 1
    Exporting a variable just puts it in the current session.
    – bmike
    Commented May 19, 2020 at 4:20
  • Ah so restarting terminal would have resolved than too, most likely. Good to know, thanks for the help. Commented May 19, 2020 at 4:45
  • 3
    TMPDIR=~/ sets it to your home folder, not the root folder. Both is wrong, actually, as TMPDIR is set to /var/folders/_d/_SOMERANDOMLOOKINGSTRING/T/ or similar by default.
    – nohillside
    Commented May 19, 2020 at 6:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .