Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
DavisVaughan opened this issue Mar 14, 2025 · 1 comment
Open
Labels
tooling 🔨 Internal usethis tooling

Comments

@DavisVaughan
Copy link
Member

DavisVaughan commented Mar 14, 2025

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)

@DavisVaughan
Copy link
Member Author

DavisVaughan commented Mar 14, 2025

(Also, what ends up happening is that a settings.json containing JSON with comments is actually lexed correctly, but the comments are completely dropped, and so they end up getting dropped from the output we write back as well, but everything else works right. This is actually slightly less bad than i thought, but still not great)

@jennybc jennybc added the tooling 🔨 Internal usethis tooling label Mar 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling 🔨 Internal usethis tooling
Projects
None yet
Development

No branches or pull requests

2 participants