nvim-flutter / nvim-flutter/flutter-tools.nvim
[BUG] Default `analysisExcludedFolders` points at a path that does not exist
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 1.4k
- Forks
- 116
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
Environment
- flutter-tools.nvim
3.0.1(0867b34) - Neovim
0.12.5, LazyVim - Flutter
3.47.1(stable), installed viamise - 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
- Install Flutter through any version manager that symlinks its installs
(mise,asdf). - Open any Dart file in a Flutter project.
- Inspect the config the plugin generated for
dartls— the
analysisExcludedFoldersentries point at<sdk>/.pub-cache, which does not
exist, and at the unresolved symlink form of<sdk>/packages.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lua/flutter-tools/lsp/init.lua at get_defaults() lines 111-114, and inspect how the Flutter SDK path and environment variables are read. Update the generated analysisExcludedFolders entries to use the resolved SDK path and the actual pub cache location. Done means the config points to existing, correct paths for normal, PUB_CACHE, and symlinked SDK installations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100