# When rails credentials:edit Won't Save Your Credentials

DevFeed: [When rails credentials:edit Won't Save Your Credentials](<https://devfeed.tech/articles/when-rails-credentials-edit-won-t-save-your-credentials-28255.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/rails/2020/01/24/when-rails-credentials-edit-won-t-save-your-credentials.html>)

Author: Fuzzygroup

Published: 2020-01-24T00:00:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Rails](<https://devfeed.tech/topics/rails.md>), [API keys](<https://devfeed.tech/topics/api-keys.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [api-keys](<https://devfeed.tech/tags/api-keys.md>), [credentials](<https://devfeed.tech/tags/credentials.md>), [development](<https://devfeed.tech/tags/development.md>), [rails](<https://devfeed.tech/tags/rails.md>)

## AI overview

This tutorial explains why Rails credentials may not save when using rails credentials:edit. It identifies the $EDITOR setting and explains that the encrypted credentials file must be closed after saving; it demonstrates running the command with EDITOR=vi.

## Source excerpt

Rails 5.2 and Rails 6 introduced the idea of rails credentials:edit which allowed you to create encrypted credentials that stored things like API keys with commands like this: rails credentials:edit --environment development What this does is create a file in config/credentials and edit and then (theoretically) save it, in an encrypted state. I was recently using this on a Rails 6 application and I found that no matter what I did my credentials did not save. A colleague of mine traced this to an issue with the $EDITOR variable I had set via this Stack Overflow post: I had this problem in rails 5.2.0 using textmate as the editor. It turns out the credentials file must be closed after save in order for the changes to persist. My $EDITOR variable was set to: echo $EDITOR /usr/local/bin/mate The solution was actually simple - specify the editor before you run the command (and use VI as the editor) so: EDITOR=vi rails credentials:edit --environment development And bada bing, bada boom - my credentials were actually saved. See Also Big Binary Stack Overflow CedarCode