Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue to open credentials file

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.

like image 492
Emma.D Avatar asked Sep 17 '18 14:09

Emma.D


People also ask

How do I open a credential file?

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.

How do I change my rails credentials?

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.


2 Answers

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:

  • 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

There might be a similar missing step for Sublime users.

like image 85
Thomas Van Holder Avatar answered Oct 11 '22 10:10

Thomas Van Holder


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.

like image 34
nuaky Avatar answered Oct 11 '22 09:10

nuaky