After beating my head against the wall for a bit related to synchronizing cookies after updating Erlang to 20.2 in Windows, I stumbled on an item in the
release notes:
OTP-14691 Application(s): erts
The fallback home directory for windows has been
changed to be the PROFILE directory instead of the
WINDOWS directory. The fallback is used when the
environment variables HOMEDRIVE and HOMEPATH have not
been set.
The impact of this is that the RabbitMq documentation is now incorrect when used with Windows and Erlang 20.2 or greater. The
Manual Windows Installation page, the
Clustering page, and the
CLI page all reference the location of the .erlang.cookie file as C:\Windows where now that location is C:\WINDOWS\system32\config\systemprofile (assuming default Windows installation). Perhaps the documentation could be altered to be a bit more specific regarding this. I would suggest putting a fuller explanation in the
Windows Quirks page and linking to the longer explanation from the other three pages cited above:
On Windows, Erlang's home dir is where the .erlang.cookie is located. Erlang will first try to use the combination of environment variables %HOMEDRIVE% and %HOMEDIR% (appended without spaces) if one or both are set. If neither are set, the fallback differs between Erlang versions. If Erlang prior to 20.2, the fallback is %WINDIR% (usually C:\Windows), in later versions the user's FOLDERID_Profile (via SHGetKnownFolderPath) is utilized (which should be the same as %USERPROFILE%). The value of any of these variables can vary between users. As an example %USERPROFILE% will vary based on the user account RabbitMq, and therefore Erlang, is running under - if running as the console/desktop user, it may be "C:\Users\UserName", however if running as LocalSystem (the default when installed as a service) it may be "C:\WINDOWS\system32\config\systemprofile". You can determine with 100% confidence the home dir, and thus the location of the cookie file used by RabbitMq server, by looking at the rab...@NODENAME.log file for where it logs "home dir". This will be the source directory where the .erlang.cookie is that you would need to synchronize. In clustering situations, after upgrading Erlang, you should be sure to copy the cookie from %WINDIR% to the new location prior to restarting the node to keep everything in sync.
Note that there is additional hassle involved here (other than filesystem permissions) if you are attempting to synchronize cookies from (or to) a location (almost) anywhere under "C:\WINDOWS\system32" under the following conditions:(1) You are running a 64 bit Windows OS and (2) You are executing code to read or check for this file inside a 32-bit process. Due to the
File System Redirector, under these circumstances, you can replace 'System32' with the 'SysNative' alias or disable/reenable redirection for that thread via Windows API calls surrounding checking/manipulating these files (see previous link).