Rails credentials coming up empty

Ran into a problem today where trying to edit rails credentails with rails credential:edit was bringing up an empty editor window. The credentials themselves were fine, I could read them with rails credentials:show, but the editor itself was blank.

On top of that, even though the command line was telling me that my credentials were saved, nothing seemed to be changing about the file.

Turns out that windows still supports a legacy file format called 8.3. The result is that a long file path can container a ~ character. A change was made to rails back in July 2021 to escape spaces in paths. That same code is also escaping the ~ character.

So a once innocuous path of C:\users\Josh~1\AppData\... became C:\users\Josh\~1\AppData\.... Obviously the resulting path doesn’t exist, so the editor was bringing up a new file!

A quick patch to rails to expand 8.3 filenames fixes the problem.

https://github.com/rails/rails/pull/44890