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

6

8

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.

Durning answered 18/4, 2020 at 1:17 Comment(1)
Have you tried using other editor?Cochlea
L
7

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

Lauraine answered 22/6, 2020 at 8:22 Comment(0)
H
6

How about

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

in macOS Big Sur that is.

Howdoyoudo answered 26/2, 2021 at 16:15 Comment(0)
O
4

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.

Otey answered 2/10, 2021 at 18:2 Comment(3)
I have vim installed as I use it as a primary editor and I get this error locally. Any idea?Cooncan
Sorry, no idea, assuming you get this error even when running with an explicit editor like EDITOR="vim" bin/rails credentials:edit and which vim shows an installed Vim.Otey
I figured the issue was due to an alias I use that looks like set RAILS_ENV development && bin/rails. I changed it to RAILS_ENV=development bin/rails and it's working. I have no clue about the why tho.Cooncan
G
1

I was having a similar issue when trying to use Atom. I realised that I needed to install the Atom shell commands:

Click Atom → Install Shell Commands

enter image description here

Grizzle answered 26/3, 2022 at 23:32 Comment(0)
W
1

For macOS you can use the following command to open in RubyMine:-

EDITOR="/Applications/RubyMine.app/Contents/MacOS/rubymine --wait" rails credentials:edit
Wagram answered 30/5, 2023 at 11:33 Comment(0)
A
1

UPDATE!

VISUAL='kate --block' bin/rails credentials:edit

I'm using kate as a visual editor with linux and the '--block' flag is for wait to close the editor to save and encrypt the credentials

Accepter answered 30/11, 2023 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.