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.

  • Great catch! I would vote up an answer explaining that or better how you figured it out. – bmike May 19 at 2:10
  • 1
    Thanks @bmike - I deleted that comment but for those looking I ran ` export TMPDIR=~/` to reset the TMPDIR to the root folder which has a tmp folder. I don't know if this is the default location of it but seems to have fixed my node app's issues. If anyone has info on how env vars work, would love to know and where updating them gets stored. – flynnstone9 May 19 at 2:18
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.

| improve this answer | |
-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.

| improve this answer | |
  • 1
    Exporting a variable just puts it in the current session. – bmike May 19 at 4:20
  • Ah so restarting terminal would have resolved than too, most likely. Good to know, thanks for the help. – flynnstone9 May 19 at 4:45
  • 2
    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 May 19 at 6:01

You must log in to answer this question.

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