Programming

Rails credentials coming up empty

Ran into a problem today where trying to edit rails credentails with rails credential:edit was bringing up an empty editor window. The credentials themselves were fine, I could read them with rails credentials:show, but the editor itself was blank.

On top of that, even though the command line was telling me that my credentials were saved, nothing seemed to be changing about the file.

Turns out that windows still supports a legacy file format called 8.3. The result is that a long file path can container a ~ character. A change was made to rails back in July 2021 to escape spaces in paths. That same code is also escaping the ~ character.

So a once innocuous path of C:\users\Josh~1\AppData\... became C:\users\Josh\~1\AppData\.... Obviously the resulting path doesn’t exist, so the editor was bringing up a new file!

A quick patch to rails to expand 8.3 filenames fixes the problem.

https://github.com/rails/rails/pull/44890

Adding syntax highlighting to micro.blog.

If you wrap code in fences (```) on micro.blog, you’ll be presented with a code block with no syntax highlighting. This just won’t do.

To enable syntax highlighting on any theme, head to your Design tab, click on “Edit Custom Theme”, then “New Plugin”.

Enter whatever name floats your boat, and paste https://github.com/joshleblanc/plugin-syntax-highlighting into the Clone URL box.

Give micro.blog a few seconds to update, and you should see your code in all its highlighted glory. To specify the language, just add the language name after the fences (```ruby for example)

For example:

def hello_world
  p "Hello, World!"
end
function helloWorld() {
  console.log("Hello, World!");
}