Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsp-dart not work with a new created dart console-full project.(non flutter) #150

Open
zw963 opened this issue Mar 11, 2022 · 14 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@zw963
Copy link

zw963 commented Mar 11, 2022

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
@ericdallo
Copy link
Member

Will try to repro and fix if any issues soon, thank you for the report

@ericdallo ericdallo self-assigned this Mar 11, 2022
@ericdallo ericdallo added the bug Something isn't working label Mar 11, 2022
@ericdallo
Copy link
Member

@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?

@ericdallo
Copy link
Member

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

@ericdallo
Copy link
Member

What are the values of lsp-dart-sdk-dir and lsp-dart-flutter-sdk-dir variable in your emacs?

@zw963
Copy link
Author

zw963 commented Mar 12, 2022

@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:

  1. dart create test_dart -t console-full

  2. cd test_dart

  3. git init (this step for make lsp can find the root folder correctly)

  4. open lib/test_dart.dart

you will get following screeshot error.

image

@zw963
Copy link
Author

zw963 commented Mar 12, 2022

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"))

@ericdallo
Copy link
Member

I couldn't repro following your steps on flutter_sample indeed, not sure if there is a issue here.

@zw963
Copy link
Author

zw963 commented Mar 12, 2022

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?

@zw963
Copy link
Author

zw963 commented Mar 12, 2022

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.

@zw963 zw963 closed this as completed Mar 12, 2022
@ericdallo
Copy link
Member

no, lsp-dart works too for dart only projects, even that project is called flutter_sample that branch was created following only your steps

@zw963
Copy link
Author

zw963 commented Mar 12, 2022

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 ?

@zw963
Copy link
Author

zw963 commented Jun 12, 2022

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"))

@zw963 zw963 reopened this Jun 12, 2022
@rileyrg
Copy link

rileyrg commented Jul 23, 2023

Im not sure if this is related or not #199 .

The suggested fix above doesnt fix it.

@zw963
Copy link
Author

zw963 commented Jul 28, 2023

I lost the context, feel free to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants