Skip to content

On Windows machines using Rails 6 or 7 (tested both) you can not run rails credentials:edit if the Windows username has a space in it. #48392

@Milella

Description

@Milella

I have been trying to figure out why on my home machine I have been unable to run rails credentials:edit no matter WHAT editor I choose it simply would NOT work. Had this problem for a good year or so. It would pull up a blank file or sometimes 2 files in some editors, but never would it EVER decrypt the rails credentials. I discovered this when I was trying to troubleshoot an app using the production mode on my home development machine. It told me it couldn't find the SECRET_KEY_BASE. This is because it is in the encrypted credentials file and it can't decrypt it. So I had to add it to my yaml file which I have had to use on my home dev machine to handle the ENV variables BECAUSE rails credentials:edit has never worked.

My work machine I login using scottm (my company username). On my home machine I sign in using Scott Milella (my real name).

When I first ran into this I tried EVERYTHING on my home machine to fix this but nothing I did worked.
SO I reloaded my machine from scratch and to my surprise the very same problem exists.
I re-setup my entire setup with the same username Scott Milella and the same thing happened despite everything being fresh.

So I then tried on another machine which is my laptop. I again setup my account using Scott Milella.
On this laptop I had installed a fresh load of Windows 10 22H2, VSCODE latest, install NodeJS v16.18.1 (the v Heroku uses), SQLite3 (Latest), GIT( Latest), installed Ruby 3.2.0 (also tried 2.7.7 and 3.1), and then gem install rails -v 6.1.7.3. Same problem existed.
To rule out if this was a bug in just v6.1 of Rails I then installed Rails 7 just to be thorough and it does the very same thing.
So on my laptop I create a new account called stech. I then logged in and went to the terminal, spun up a new rails app and to my complete surprise it decrypted the credentials! All the very same software just an account name without a space.

SO on my home PC I did the same thing, I created a new account, didn't configure anything. Just launched Windows Terminal again (using Git Bash). went to my app I previously couldn't decrypt and to my complete surprise and ANNOYANCE it worked!

I also can not run the rails credentials:edit command in Windows Command Prompt or Powershell.
There is something you are doing in your rails credentials:edit that is not passing the information correctly WHEN there is a space in the username.
I tried everything with regards to using quotes on paths and anything and everything I could think of and I can find no way to defeat this bug in Rails with regards to the rails credentials:edit command.

This is the ONLY THING I have ran into on a Windows machine using Rails v6 and Ruby 2.7.7 or higher I have ran into that I can not seem to overcome (with a space in the username that is).

If you look at the way it is constructing the path when I login with Scott Milella it is somehow passing the path as:
"C:\Users\SCOTTM\~1\AppData\Local\Temp\4384.credentials.yml"
So if you look at that path it should be Users\Scott Milella but instead it is changing my name to all UPPERCASE and somehow it is also truncating it to just SCOTTM and then it is adding a "\~1\" as a separate folder. I understand windows can modify the path and add a ~1 to the end of something but in this case it isn't doing that, it is adding a complete new folder with \~1\ . SO when it hits that space it is incorrectly pathing the file. The folder it is talking about doesn't even exist.

I have been trying to figure this out off and on for a good year or so and now I have PROVEN it is a Rails bug
.
It isn't a bash problem because it has no other issues of ANY KIND with Bash, Rails, Windows Terminal anything. Everything works PROPER except the rails credentials:edit

I have attached a picture of it not working when I login with Scott Milella.
rails credentials edit does NOT WORK with a SPACE in the username

Here is a picture showing that it DOES work when I login with stech.
rails credentials edit works with username with no space

By the way rails incorrectly creates that weird pathname with the ~1\ on both my LAPTOP and my DESKTOP, the very SAME PATH if I login on both machines as Scott Milella. This is why I never ran into the problem on my work DEV Machine because I have our company on a domain and at work my login name is the scottm instead of Scott Milella.

If you need any further information please let me know.
I would LOVE to know how to solve this without having to redo my Windows machine AGAIN to just remove a space from a Username.

Thank You,
Scott Milella

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions