Skip to content

development.yml fails when there are YAML evals + long lines + prettier + format_on_save#1727

Description

@joelparkerhenderson

Loco uses the file config/development.yml and similar ones, but these are failing due to glitches with some editors and formatters, notably zed, prettier, and the zed "format_on_save" setting.

Example file line:

uri: {{ get_env(name="DB_URL", default="postgres://username:password@hostname:5432/database") }}

To reproduce the failure, open the file in the zed editor with zed default settings such as a fresh install. Make any edit, then save. This causes zed + prettier to do an automatic reformat that forces multi-line and inserts commas, like this:

uri:
  {
    { 
      get_env(name="DB_URL", default="postgres://username:password@hostname:5432/database") 
    },
  }

This glitch causes Loco to fail on start.

I've reported the problem here: zed-industries/zed#46632

The root cause seems to be that the Loco configuration file format is sort-of-YAML but sort-of-not YAML. I'm generally aware of these kinds of YAML glitches in other tools, such as with Ansible and also templating syntaxes.

My workaround is to add a zed settings file that disables the global "*_on_save" settings, and later I'll add specific syntax adjustments for specific languages and file names:

{
  "format_on_save": false,
  "remove_trailing_whitespace_on_save": false,
  "ensure_final_newline_on_save": false
}

Could Loco eventually upgrade to using Rust instead of YAML for the configuration files? IMHO upgrading from YAML to Rust would be safer, and also easier to edit, and also more like Rails which uses Ruby for its config files.

Thanks for your consideration, and for Loco.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions