I am trying to open credentials file with this command.
rails credentials:edit
It returns :
No $EDITOR to open file in. Assign one like this:
EDITOR="mate --wait" bin/rails credentials:edit
For editors that fork and exit immediately, it's important to pass a wait flag, otherwise the credentials will be saved immediately with no chance to edit.
So I make this command :
EDITOR="subl --w" bin/rails credentials:edit
However, terminal responds with "New credentials encrypted and saved" without opening an editor.
Launch VS Code. Open the Command Palette (⇧⌘P) and type shell command to find the Shell Command: Install code command in PATH command. Now run EDITOR="code --w" bin/rails credentials:edit.
Your text editor will open an unencrypted version of your credentials. If you don't have EDITOR set, you can run EDITOR=vi bin/rails credentials:edit or use your favorite text editor. After saving the file, the encrypted version will be saved to config/credentials. yml.
As a VS Code user, this took me a while to figure out. What was missing to install the code
command through VS Code's interface.
Crossposting Bryan's answer here:
shell command
to find the Shell Command: Install code
command in PATH command.EDITOR="code --w" bin/rails credentials:edit
There might be a similar missing step for Sublime users.
Are you using the correct alias for wait
?
In official documentation there is:-w or --wait: Wait for the files to be closed before returning
So it should be:EDITOR="subl --wait" bin/rails credentials:edit
.
I've just tested this on ubuntu with vs code, and atom and it worked correctly:EDITOR="code --wait" rails credentials:edit
.EDITOR="atom --wait" rails credentials:edit
.
Also check if subl is correctly added to system variable path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With