rails: rails credentials:edit doesn't work

Steps to reproduce

Run the command in CLI:

EDITOR=st rails credentials:edit

Expected behavior

Expect to see an editor open up with unencrypted content of the credentials.yml.enc.

Actual behavior

The following output is generated in the CLI:

New credentials encrypted and saved.

System configuration

5.2 2.3.3

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Guys, don’t know if someone is facing this kind of error… but basically this was what I did and worked perfectly!

on terminal, run (for Sublime Text 3):
ln -sv "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
then run:
EDITOR='subl --wait' rails credentials:edit

PS: I did same with vscode but first installed to men path: https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line

🎉

thanks to martinbuberl for the config on sublime

Thank You Vladimir-19, That solved a problem I was having too.

I just had the same problem. This is how i solved it (working with VSCode on Catalina):

  1. delete config/credentials.yml.enc file (back it up in a different folder)
  2. delete config/master.key (back it up in a different folder)
  3. Run: EDITOR="code --wait" rails credentials:edit (or EDITOR="subl --w" bin/rails credentials:edit) in your app terminal. It should create new credentials.yml.enc and master.key. At the same time this command should open credentials file in edit format.
  4. Make sure your project is working fine so you can delete backed up credentials.yml.enc & master.key (from step 1, 2).

In mac, the credentials file opening with vim editor.

The silent exit and New credentials encrypted and saved. can be reproduced on any app if starting the editor throws any kind of error. The simplest might be setting EDITOR to something that obviously doesn’t work.

Make sure to pass in a wait flag that st supports, likely EDITOR="st --wait". See credentials:help for more.