lsp-dart
lsp-dart copied to clipboard
lsp-dart not work with a new created dart console-full project.(non flutter)
Describe the bug i create a new project use following command:
$: dart create test_dart -t console-full
when open this folder, and specify the correct lsp root, lsp server start failed.
Following is log:
lsp-log
Command "/home/zw963/flutter/bin/dart /home/zw963/flutter/bin/snapshots/analysis_server.dart.snapshot --lsp --client-id emacs.lsp-dart --client-version 1.21.0" is present on the path.
Command "/home/zw963/flutter/bin/dart /home/zw963/flutter/bin/snapshots/analysis_server.dart.snapshot --lsp --client-id emacs.lsp-dart --client-version 1.21.0" is present on the path.
Found the following clients for /home/zw963/Dart/test_dart/lib/test_dart.dart: (server-id dart_analysis_server, priority 1)
The following clients were selected based on priority: (server-id dart_analysis_server, priority 1)
dart_analysis_server::stderr
Could not find a command named "/home/zw963/flutter/bin/snapshots/analysis_server.dart.snapshot".
Usage: dart <command|dart-file> [arguments]
Global options:
-h, --help Print this usage information.
-v, --verbose Show additional command output.
--version Print the Dart SDK version.
--enable-analytics Enable analytics.
--disable-analytics Disable analytics.
Available commands:
analyze Analyze Dart code in a directory.
compile Compile Dart to various formats.
create Create a new Dart project.
devtools Open DevTools (optionally connecting to an existing application).
doc Generate HTML API documentation from Dart documentation comments.
fix Apply automated fixes to Dart source code.
format Idiomatically format Dart source code.
migrate Perform null safety migration on a project.
pub Work with packages.
run Run a Dart program.
test Run tests for a project.
Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
Process dart_analysis_server stderr finished
[LSP Dart] 1.21.0 at 2022.03.11 @ Emacs 28.0.91
[Dart SDK] Dart SDK version: 2.16.1 (stable) (Tue Feb 8 12:02:33 2022 +0100) on "linux_x64"
[Flutter SDK] /home/zw963/flutter/
[Flutter project] false
[Project entrypoint] Not found
[LSP Dart] 1.21.0 at 2022.03.11 @ Emacs 28.0.91
[Dart SDK] Dart SDK version: 2.16.1 (stable) (Tue Feb 8 12:02:33 2022 +0100) on "linux_x64"
[Flutter SDK] /home/zw963/flutter/
[Flutter project] false
Will try to repro and fix if any issues soon, thank you for the report
@zw963 couldn't repro creating a new project with the same flutter version, flutter-sample. lsp-dart starts properly to me on that repo, could you try as well?
oh, it seems lsp-dart it's considering the dart-sdk of yours as "/home/zw963/flutter/bin/snapshots/analysis_server.dart.snapshot"., which is wrong and should be "/home/zw963/flutter/bin/cache/dart-sdk/snapshots/analysis_server.dart.snapshot".
Maybe some
You can see how it says it's not a flutter project which is wrong:
[Flutter SDK] /home/zw963/flutter/ [Flutter project] false
What are the values of lsp-dart-sdk-dir and lsp-dart-flutter-sdk-dir variable in your emacs?
@zw963 couldn't repro creating a new project with the same flutter version, flutter-sample.
Hi, it work well when use with flutter, current, i am trying with a dart project instead, it have a folder structure like this:
╰─ $ tree
.
├── analysis_options.yaml
├── bin
│ └── test_dart.dart
├── CHANGELOG.md
├── lib
│ └── test_dart.dart
├── pubspec.lock
├── pubspec.yaml
├── README.md
└── test
└── test_dart_test.dart
You can see how it says it's not a flutter project which is wrong:
In fact, it not a flutter project indeed, it just a normally dart new project.
What are the values of lsp-dart-sdk-dir and lsp-dart-flutter-sdk-dir variable in your emacs?
I never set both of them manually.
my flutter is just a git repo which live in /home/zw963/flutter, and only add following into PATH
PATH="$HOME/flutter/bin:$PATH"
PATH="$HOME/.pub-cache/bin:$PATH"
I get following result when start with a minimum config:
lsp-dart-sdk-dir => nil sp-dart-flutter-sdk-dir => nil.
I think you can reproduce this with:
-
dart create test_dart -t console-full
-
cd test_dart
-
git init (this step for make lsp can find the root folder correctly)
-
open lib/test_dart.dart
you will get following screeshot error.

Hi, it works now after i specify my dart sdk dir explicitly with my others config.
(setq lsp-dart-sdk-dir (expand-file-name "~/flutter/bin/cache/dart-sdk"))
I couldn't repro following your steps on flutter_sample indeed, not sure if there is a issue here.
I couldn't repro following your steps on flutter_sample indeed, not sure if there is a issue here.
Yes, it works on any new created flutter project for me too. (use flutter create project_name)
So, lsp-dart only support auto configuration for flutter project, not support dart (non-flutter) project, right?
Try to reproduce like me is trival, only need
dart create test_dart -t console-full
cd test_dart
git init
emacs lib/test_dart.dart
Anyway, it works well after i set correct dart sdk folder, if you think this is expected behavior, i will close it.
no, lsp-dart works too for dart only projects, even that project is called flutter_sample that branch was created following only your steps
no, lsp-dart works too for dart only projects, even that project is called flutter_sample that branch was created following only your steps
Sorry for miss flutter_sample new branch, i test on it, not work for me, always, are you sure you are not set lsp-dart-sdk-dir variable or maybe some environment variable (don't know if any) to teach lsp-dart to find the correct dart sdk ?
lsp-dart works too for dart only projects,
Hi, lsp-dart still not work for dart only project if not set lsp-dart-sdk-dir manually.
Following is reproduce:
dart create test_dart -t console-full
cd test_dart
git init
git add -A
git commit -m 'initialize commit'
emacs lib/test_dart.dart
# When ask
# i ==> Import project root ~/Dart/test_dart/
# then pressing i
Get following error:
LSP :: dart_analysis_server has exited (exited abnormally with code 64)
i can see log in dart_analysis_server:stderr log.
Could not find a command named "/home/zw963/flutter/bin/snapshots/analysis_server.dart.snapshot".
Usage: dart <command|dart-file> [arguments]
Global options:
-h, --help Print this usage information.
-v, --verbose Show additional command output.
--version Print the Dart SDK version.
--enable-analytics Enable analytics.
--disable-analytics Disable analytics.
Available commands:
analyze Analyze Dart code in a directory.
compile Compile Dart to various formats.
create Create a new Dart project.
devtools Open DevTools (optionally connecting to an existing application).
doc Generate HTML API documentation from Dart documentation comments.
fix Apply automated fixes to Dart source code.
format Idiomatically format Dart source code.
migrate Perform null safety migration on a project.
pub Work with packages.
run Run a Dart program.
test Run tests for a project.
Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
Process dart_analysis_server stderr finished
The currect path should be
~/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot
Not
~/flutter/bin/snapshots/analysis_server.dart.snapshot".
This issue can be fixed with
(setq lsp-dart-sdk-dir (expand-file-name "~/flutter/bin/cache/dart-sdk"))
Im not sure if this is related or not #199 .
The suggested fix above doesnt fix it.
I lost the context, feel free to close this issue.