denoland / vscode_deno

Visual Studio Code plugin for Deno
https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno
MIT License
1.5k stars 146 forks source link

Perplexing effect of `deno cache` #1136

Closed oscar6echo closed 4 months ago

oscar6echo commented 4 months ago

I have a folder with a deno project with a .vscode/settings.json file below and a maint.ts file, opened in VS Code installed with the deno vs_code extension latest version.

{
    "deno.enable": true,
    "deno.cache": ".cache", // ---> local folder
    "deno.enablePaths": [
        "./"
    ],
    "editor.formatOnSave": true,
    "editor.formatOnPaste": true,
    "[typescript]": {
        "editor.defaultFormatter": "denoland.vscode-deno"
    },
    "editor.inlayHints.enabled": "off"
}

In my setup DENO_DIR is not set so defaults to ~/.cache/deno.

When I do deno cache -c deno.json --reload main.ts, local folder .cache is not impacted.
In order to hard clear the cache I must do rm -rf ~/.cache.
(And then reload the vs code window - but this is a separate topic).

Do you confirm the behavior ?
Is it because deno cache is driven by DENO_DIR only ?

Questions:

I ran into this puzzling (at first sight) behavior in this honojs issue.

oscar6echo commented 4 months ago

Do you recommend against using a local .cache folder and stick to a single location set by DENO_DIR ?

I can answer my own question: DO NOT SET YOU CACHE TO A FOLDER INSIDE YOUR NAMESPACE if you use VS Code with deno extention.

There seems to be a sort of catch22 situation - which could be potentially be escaped by a negative use of "deno.enablePaths" but (1) I don't think this is possible (2) anyway this would be uselessly cumbersome (just set the cache folder outside view).

It works fine with any other location, default or custom.

Cf. this issue comment for a specific example and context.

oscar6echo commented 4 months ago

If not, would it make sense to make CLI deno cache read cache config from a potential ./vscode/settings.json ?

I can share my observations:


BEWARE: there are 2 caches:

To refresh the first cache do:

To refresh the second cache do:

If you do deno check main.ts the CLI uses the DENO_DIR cache.
If you use vscode code analysis the settings.json/"deno.cache" folder is used.

This can be a bit confusing but makes some sense as the 2 pieces of software are independent.
If the CLI and the language server logs were explicit about where the cache used is, this would help users.

Conclusion: From there it seems a good practice to use always the same cache - some folder with enough space.

oscar6echo commented 4 months ago

Closing as no more 'perplexing' behavior.