Skip to content

What to do about use_air() and JSON files with comments in them? #2114

@DavisVaughan

Description

@DavisVaughan

use_air() modifies a settings.json file using jsonlite, but #2109 (comment) let us know that jsonlite will fail to parse JSONC (json with comments), and settings.json is a JSONC file.

This is fairly annoying because it is somewhat common to put comments in a file type like this.

I'm not sure what the right thing for use_air() is. Ideally we'd have a parser that supports JSONC, but in the meantime...?

Maybe we'd:

  • Create settings.json and extensions.json if they don't exist, and dump in the template containing what we know we want to put there
  • Open settings.json or extensions.json if they do exist, and output stuff in the console telling the user what they should add to those files (since we can't reliably do that for them). Opening the file at least makes it slightly harder to miss that you are supposed to do something here, but it is still less optimal than just modifying it for the user.
  • OR we could take a hammer to an existing settings.json or extensions.json and overwrite it completely with our template for air settings, relying on the user to use git diffs to work backwards from there and re-add anything we removed (merging with the new air settings). This is what we do for github actions workflows, but does feel kind of aggressive here

It's worth giving this some thought because we are likely going to have other helpers that touch settings.json as time goes on and more people use Positron (See #2111 too)

Metadata

Metadata

Assignees

No one assigned

    Labels

    tooling 🔨Internal usethis tooling

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions