Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to Save and Edit credentials.yml.enc in Rubymine or Vim for Rails 6

I am trying to add an API key and token to my credentials.yml.enc file in Rubymine. I can't seem to find a --wait flag or save the generated file from

EDITOR=rubymine rails credentials:edit

or

EDITOR="rubymine --wait" rails credentials:edit

What happens is I add my keys to the file for example:

api_client:
  api_key: 123

but just by opening the file I see a

File encrypted and saved.

message before I can enter anything, so when I spin up my rails console to test my keys like:

 Rails.application.credentials.api_client[:api_key]

I just get back a 'nil' value error.

When I try to edit in vim I get similar results. I can't seem to find any answers online, I am running ruby '2.6.3' with Rails 6.0.2.2 on MacOS Catalina 10.15.4. Thank you all for your time.


Solution: at this time I have found that using a different editor (ATOM) solves the short term problem. I will continue to try and understand if rubymine has this capability as well.

like image 517
mrtriangle Avatar asked Apr 18 '20 01:04

mrtriangle


People also ask

How do you change credentials in rails?

$ rails credentials:edit 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.

What is config credentials Yml ENC?

credentials. yml. enc file is used to manage configuration such as environment variable, ID or password. This file is encrypted by config/master.

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.


3 Answers

Try this.. EDITOR="vim" bin/rails credentials:edit Works like charm with MacOS Catalina

like image 85
Sathish Avatar answered Oct 17 '22 12:10

Sathish


How about

EDITOR = "/Applications/RubyMine.app/Contents/MacOS/rubymine --wait" rails credentials:edit

in macOS Big Sur that is.

like image 30
Filippos Avatar answered Oct 17 '22 14:10

Filippos


I also got "File encrypted and saved." trying to run EDITOR="vim" bin/rails credentials:edit in a Rails 6.1 project.

It was simply a matter of the editor not being installed – I tried just the vim command to confirm this. After installing Vim (apt-get install vim on this Ubuntu system), it worked as expected.

like image 4
Henrik N Avatar answered Oct 17 '22 14:10

Henrik N