0

You've edited your master.key or credentials.yml.enc file in VScode, and are running into issues when you saved the file because your editor is configured to ensure files have a trailing newline and rails doesn't strip the content before decrypting it.

2 Answers 2

0

I generally only read/write that type of file in Vi or BBEdit, but you can get around this in VScode by configuring those file extensions to use a specific Language Mode and then disable the setting for that Language Mode:

// .vscode/settings.json
{
  // Global Settings:
  "editor.tabSize": 2,
  "editor.indentSize": "tabSize",
  "files.insertFinalNewline": true,
  "files.trimTrailingWhitespace": true,
  "files.trimFinalNewlines": true,
  // Define the Language Mode for specific file extensions:
  "files.associations": {
    "*.enc": "shellscript",
    "*.key": "shellscript"
  },
  // Define override settings for specific Language Mode:
  "[shellscript]": {
    "files.insertFinalNewline": false
  }
}

Note: The settings documentation leaves something to be desired, but you effectively need to use an identifier recognized as a VScode valid Language Mode (i.e., the feature that VScode uses to determine which syntax highlighting to use for your file). I am using shellscript here, which is VScode's identifier for the Shell Script Language Mode.

Sign up to request clarification or add additional context in comments.

Comments

-1

All projects should have an https://editorconfig.org/ file. And all devs should configure their editors to use it.

4 Comments

My goal was to show how to configure it in VScode because it was made clear to me that many people don't know how/why this breaks, which is why I specified VScode in the title. Your solution requires people spend time reading the documentation for EditorConfig's DSL, then spend more time writing and testing a config file that satisfies all their needs, then install a VScode extension, and then hope that the extension is maintained. I appreciate that you're trying to share a more universal resource for editor configuration, but it isn't appropriate in this context.
FWIW, editorconfig is way older than vscode. I would worry about vscode becoming unmaintained before editorconfig. What's more, my solution solves the problem for all users of the project for all file types without thinking about it or having to learn the dsl/settings for their particular ide[s]/editor[s] - as long as they use editorconfig for them. So, yes, you did request a solution to one problem. My suggestion is to solve the general problem set for all users in one file once.
Again, your solution requires many layers + a lot of time from the individual and provides no guidance beyond a website link that has nothing to do with vscode. The extension itself hasn't been updated in 3 years. Sure, the editorconfig website is a measly 3 years older than the initial release of today's VScode branded product, but Microsoft has been making code editors since at least 1991. If you're going to provide information that only has tangential relationship to the topic, at least put in minimal effort to demonstrate how it would be applied to the topic at hand.
Your answer seems like its only purpose is to try to promote a tiny OpenSource project that only has 288 followers on GitHub, which I wouldn't necessarily take issue with if you had actually provided anything that would educate someone reading this post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.