Skip to content

lsp-dart-run can't find a java executable or JAVA_HOME #194

Open
@toniz4

Description

@toniz4

Describe the bug

When trying to run lsp-dart-run, using envrc to populate the env variables based on a shell.nix. The debbuger or runner exits with the following message:

Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

Exception: Gradle task assembleDebug failed with exit code 1

The weird thing is, the flutter and dart executables and sdks and the jdk are being set up in the same way, at the same time. So, if the flutter command is avaliable to emacs, I don't know why it only fails with the java command.

To Reproduce

Have JAVA_HOME and the java executable path set by envrc.
Run dap-debug or lsp-dart-run in a flutter project.

Expected behavior
That lsp-dart-run executes my app

Version

[LSP Dart] 1.24.1 at 2023.03.19 @ Emacs 28.2
[Dart SDK] Dart SDK version: 2.18.4 (stable) (Tue Nov 1 15:15:07 2022 +0000) on "linux_x64"

[Flutter SDK] /nix/store/zdvb6d47hnmgp6ccsm7n6jr60q3yczfb-flutter-3.3.8-unwrapped
[Flutter project] true
[Project entrypoint] /home/cassio/src/namer_app/lib/main.dart

What I think is hapening is that somewere, the process-environment and exec-path are being reseted to the default value, I tried to identify where, but my skills to debug elisp are not the best. But I found those possible related issues:

greghendershott/racket-mode#539
rust-lang/rust-mode#447
magit/magit#4160
purcell/envrc#31

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