LSP: Request textDocument/codeAction failed. Invalid file path
See original GitHub issueDescribe the bug
This just came up, have never seen it before. Whenever I type something in a specific dart
file VSCode’s Output panel opens up with an error message along with a notification about it. The message is as follows:
[Error - 20:39:21] Request textDocument/codeAction failed.
Message: Invalid file path
Code: -32003
c:\Users\myuser\dev\project\lib\core\widgets\sidebar.dart
As I said, it only happens within this one specific file. No other files. It actually happens when clicking around in the file too. I’ve tried reloading the window, restarting VSCode, disabling and reenabling the Dart extension, disabling the Vim extension. Removing the file and recreating it pasting the stuff I previously had present in the file. Nothing works at this point. As I also said, this just started happening, and I have never seen it before. Nor do I have any idea on my own what I could have done to cause anything.
To Reproduce I really don’t know how to reproduce, to be honest…
Hmm… So while writing I started fiddling around a little bit. Started by removing everything in the file I had problems with and retyped it from a copy in Notepad. ~As soon as I came to adding the square brackets to this line~ I had actually typed out all the other stuff, since I used the tools present in VSCode to generate most of it:
static final List<String> _items = [];
It started freaking out. The type doesn’t seem to matter. I think it’s the combination of static
, final
, and the list square brackets OR curly braces, instead of square brackets. Also, the underscore does not matter, just so you know.
Also, to add for clarification: This works without errors:
static final String _string = "dwadnwaj";
// this too, although it doesn't compile of course
static final List<String> _grndjkgr = "adsnfshjfs";
The snippets above should be surrounded by the other content of the file in the steps below. Otherwise I cannot reproduce.
I’m gonna give my computer a restart a try. I’ll report back if anything changes.
- Create a file from root flutter project,
lib/core/widgets/sidebar.dart
, with the following contents: - Add the following contents to the file:
import 'package:flutter/widgets.dart'; /// This widget is a reimplementatino of the [Drawer] widget with the added /// ability to act as a collapsable sidebar on desktop sized screens. class Sidebar extends StatelessWidget { static final List<Widget> _items = [ _SidebarItem(), ]; final bool expanded; const Sidebar({ Key key, this.expanded = false, }) : super(key: key); @override Widget build(BuildContext context) { return LayoutBuilder( builder: (context, constraints) => ListView.builder( scrollDirection: Axis.vertical, itemCount: _items.length, itemBuilder: (context, index) => _items[index], ), ); } } // class _SidebarItem {}
Sad truth is that I can’t reproduce the narrowed problem in any other file. Just the sidebar.dart
one.
I have a really hard time believing anyone else will be able to reproduce, it feels like it has to do something with my exact setup. But I guess we’ll find out.
English is not my native language.
I’ll be here for questions if anyone has them.
Thanks for everyone’s time!
Expected behavior No errors should be thrown.
Versions (please complete the following information):
- VS Code version: 1.52.1 (user setup)
- Dart extension version: v3.18.1 (LSP enabled)
- Dart/Flutter SDK version: Dart 2.12.0 (build 2.12.0-133.2.beta) / Flutter 1.25.0-8.2.pre • channel beta
- OS: Windows 10 2004 (since it might have to do with file paths?)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:51 (22 by maintainers)
Top GitHub Comments
Probably someone has workarounds? Have the same error
You don’t need to restart the entire system. just restart VS code