community: If TMPDIR environment variable is set, vscode integration does not accept commands

A random piece of software on my machine (Windows 10) had set this the system environment variable TMPDIR, which caused the vscode integration to not accept commands. I believe this is because the function get_communication_dir_path() uses gettempdir(): https://github.com/knausj85/knausj_talon/blob/main/apps/vscode/command_client/command_client.py#L211-L224

which checks TMPDIR, TEMP, and TMP, in order, to choose a temporary directory.

On the extension side, node’s os.tmpdir() is used to select a temporary directory: https://github.com/pokey/command-server/blob/main/src/paths.ts#L4-L12

It’s not documented, but I believe this must not check the TMPDIR env variable, causing the two ends of the connection to choose different directories and miss each other.

(Not sure how to fix this. You could override the directory lookup, or just switch to using a socket lol.)

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 42 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Something like that. We probably don’t need the corresponding setting Talon side if this is just a problem where one vscode extensions incorrectly sets an environment variable. So the change on the command server would be to use this order:

1. Explicit users set vscode setting

2. TMPDIR env var

3. os.tmpDir()

That implies you always know in advance what the talon side will use and set that on vscode side, but if talon side is using env variables that could change (even system wide or whatever), then you won’t know no? Hardcoding on both sides seems less error prone to me, but maybe I’m missing something.

The client will give you an error message with the path it’s trying to use so you can just mirror that in the extension. I don’t want to make things more complicated than they have to be so until we have an actual need for the setting client side I would prefer to not have it.

In that case a vscode setting sounds much simpler. I think it’s absurd that vscode extension can change environment variables for other extensions though. That is definitely a red flag.

The ability to move temp to a ram disk or similar is quite nice so we should probably still respect env by default.

to be clear, if we need to put this somewhere other than a temp directory to make it work for more people out of the box, I think we should do that. I just want to (a) avoid overcomplicating things if we don’t have to (b) make sure the alternative solution does work for more people out of the box. being able to use a ramdisk/tmpfs is a nice-to-have not a necessity.

If we put anything in the home dir, we’d also have to put it outside of a dot directory, since we’ve also seen snaps prevent access to dotfiles.

I mildly prefer using the temporary directory. I’ve put my temp dir on an in-memory filesystem so that all this command client traffic doesn’t have to hit my hard drive at all.