Skip to content

[BUG] Default analysisExcludedFolders points at a path that does not exist #533

Description

@janne

Environment

  • flutter-tools.nvim 3.0.1 (0867b34)
  • Neovim 0.12.5, LazyVim
  • Flutter 3.47.1 (stable), installed via mise
  • Linux 7.1.9-arch1-2

Current behavior

get_defaults() in lua/flutter-tools/lsp/init.lua:111-114 builds the default
exclusion list from the resolved Flutter SDK path:

analysisExcludedFolders = {
  path.join(flutter_sdk_path, "packages"),
  path.join(flutter_sdk_path, ".pub-cache"),
},

The second entry assumes the pub cache lives inside the SDK. On a normal
install it does not — it lives in $HOME/.pub-cache (or $PUB_CACHE). On this
machine:

$ SDK=$(mise where flutter)
$ [ -d "$SDK/.pub-cache" ] && echo exists || echo "does not exist"
does not exist
$ du -sh ~/.pub-cache
986M    /home/user/.pub-cache

So the default excludes a directory that does not exist, and does not exclude
the 986 MB one that does.

This is not a new observation. In #463 two users independently arrived at the
same conclusion and worked around it by setting the value by hand:

I had the same problem, and the cause was that .pub-cache was NOT being
properly added to analysisExcludedFolders. [...] I was able to solve it by
adding to my config: analysisExcludedFolders = { vim.fn.expand("$HOME/.pub-cache") }

That issue was closed without the default being changed.

Expected behavior

The default should exclude the pub cache where it actually is: $PUB_CACHE if
set, otherwise $HOME/.pub-cache (%LOCALAPPDATA%\Pub\Cache on Windows).

Secondary problem: paths are not resolved through symlinks

Version managers commonly expose the SDK through a symlink. mise reports:

$ mise where flutter
/home/user/.local/share/mise/installs/flutter/3.47.1
$ realpath "$(mise where flutter)"
/home/user/.local/share/mise/http-tarballs/<hash>_strip_1

flutter_sdk_path is the first form, so the generated
<sdk>/packages entry is expressed in terms of the symlink, while the paths
Neovim sends in textDocument/didOpen are the resolved form. The two never
prefix-match.

Caveat, stated plainly: I could not isolate a behavioral effect for this half.
Adding the resolved variants to the list changed peak analysis-server RSS from
666 MB to 629 MB, i.e. nothing measurable — most likely because excluded folders
do not apply to files that are explicitly opened anyway. So treat this as a
correctness issue in the generated config, not as a performance fix.

Suggested fix

Resolve the SDK path with vim.uv.fs_realpath() before joining, and derive the
pub cache location from the environment rather than assuming it is under the SDK.

Steps to reproduce

  1. Install Flutter through any version manager that symlinks its installs
    (mise, asdf).
  2. Open any Dart file in a Flutter project.
  3. Inspect the config the plugin generated for dartls — the
    analysisExcludedFolders entries point at <sdk>/.pub-cache, which does not
    exist, and at the unresolved symlink form of <sdk>/packages.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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