I've been using GNU Emacs on Windows for many years and in order to make it work, I've always had to define several environment variables. I've had these defined as system variables all this time:


I recently upgraded my Emacs from the "NTEmacs" port of 24.3 to the official GNU port of 26.1 and I've found that the values I was using for these were wrong. Furthermore, the current version can auto-detect all but the EMACSPATH variable.

So I went into the environment variables control panel, changed EMACSPATH to point to the new installation's location and deleted the rest. Emacs now works great.

But I found out that after a logout/login, all of the deleted variables are back, and with the old values. More precisely, they're not in the control panel, but if I open a command prompt and type set, they're there and the prevent Emacs from working. (Other environment variables I've deleted also come back, but they don't interfere with any of my apps so I don't care as much).

If I modify, add or remove any system environment variable with the control panel, the environment resets to match it and Emacs works again until the next time I log out or reboot.

Clearly, these environment variables are being cached somewhere, but I have no clue where to look in order to completely delete them.

I searched the registry with regedit and couldn't find any trace of these old variables. Is there any place else I should be looking? This is clearly a Windows bug, but I don't want to have to put up with this for as long as it takes for Microsoft to fix it.

I can, of course, get the values Emacs computes and re-create the system environment variables with these values, but I'd prefer to avoid that unless there is no other option available.

  • In my Win10v1803 setup with Windows Subsystem for Linux Ubuntu 1804 installed, without emacs installed for Windows, I do not see those system variables. I suspect there was a Scheduled Task or other script that runs on login (look in Task Scheduler , and also look in Task Manager->Startup and msconfig to see what runs on login and startup). There may be other ways to automatically set the variables. See superuser.com/questions/15596/… . – Christopher Hostage Nov 7 '18 at 17:36
  • What does the question really have to do with Emacs? – Drew Nov 7 '18 at 17:55
  • There are two parallel sets of environment variables : System and User. Have you checked both? – harrymc Nov 7 '18 at 18:22
  • It's not an Emacs problem. Emacs is the reason I discovered the problem. It occurs with any environment variables that you may have set at some time in the past and later deleted. As for system vs. user, yes, I've checked both - I only created them in system and I have only deleted them from System. – David C. Nov 8 '18 at 18:26
  • They must be recreated by some program you have installed. Environment variables don't reappear by themselves. – harrymc Nov 8 '18 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.