AdaCore / ada_language_server

Server implementing the Microsoft Language Protocol for Ada and SPARK
GNU General Public License v3.0
226 stars 54 forks source link

Can't find a toolchain for the following configuration #1160

Open Joebeazelman opened 11 months ago

Joebeazelman commented 11 months ago

I get a strange error message when I try to compile my file. If I build using the build command in Visual Studio, I get the following error:

can't find a toolchain for the following configuration

I also get an error message in the problems tab area:

imported project file "pico_bsp.gpr" not found

However, it compiles successfully when I build from VS Code's terminal using alr build. If I go back and execute the build command again, I get:

gprconfig: can't find a toolchain for the following configuration:
gprconfig: language 'ada', target 'arm-eabi', runtime 'light-cortex-m0'
cpu_controller_config.gpr:2:06: imported project file "pico_bsp.gpr" not found
cpu_controller_config.gpr:2:06: imported by "/Users/joebeazelman/Projects/Repos/cpu_controller/config/cpu_controller_config.gpr"
cpu_controller_config.gpr:2:06: imported by "/Users/joebeazelman/Projects/Repos/cpu_controller/cpu_controller.gpr"
gprbuild: "cpu_controller.gpr" processing failed
reznikmm commented 11 months ago

Hello @Joebeazelman ! How can I reproduce this? What is the build command?

I tried to reproduce and it works for me. My steps:

Joebeazelman commented 11 months ago

Not sure what happened, but I tried to set the GNAT version inside the project toml file and the issue started.

Joebeazelman commented 11 months ago

The issue started up again. I can build the project without issue if I execute alr build outside of VSC or directly from its terminal. It consistently complains it cannot find the imported file and that it can't locate the runtime. It only works when I launch VSCode using alr edit from the command-line.

Is there a way of outputting what the LSP extension sees as Alire's environment variables? Usually when you get this error it means it's not seeing Alire's environment's toolchain variables. I suspect it may be confused by my Path.

reznikmm commented 11 months ago

@Joebeazelman I suggest you to create $HOME/.als/traces.cfg file with content

ALS.MAIN=yes

Then ALS starts to write log files in that directory. You should see environment variables in the corresponding log file.

Joebeazelman commented 10 months ago

I examined the dump file and the gprpath is blank. I also didn't see any Alire configured paths. So how is LSP retrieving the paths? Apparently, it's obtaining enough configuration to perform a compile. For what it's worth, this is occurring on a fresh MacOS install. I will investigate some more.

Joebeazelman commented 10 months ago

Below please see the included dump file. As you can see, GPR PATH is blank also there's an exception with a message it can't find the toolchain for the project. Interestingly, LSP is using a toolchain to perform the compilation, although it's unclear which one it's using. This may be related to another issue I opened where it ALS reports more errors than the compiler does.

With the recent new issue opened, I suspect the issue is either unique to MacOS or you may already have a toolchain configured outside of ALR, but it's only a guess.

There's a On_SetTrace_Notification: OFF, would it be helpful to you if I turn this setting on? If so, how do I do it?

[ALS.MAIN] ALS version: 23.0.21 [ALS.MAIN] Initializing server ... [ALS.MAIN] GPR PATH: [ALS.MAIN] PATH: /usr/local/bin:/usr/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin [ALS.MAIN] Ada version used for predefined completion: ADA_2012 [ALS.MAIN] Initialize_Request: Request 0 /Users/joe/Development/pico_examples/adc_hello [ALS.MAIN] Context root: /Users/joe/Development/pico_examples/adc_hello [ALS.MAIN] Initialize_Response: Response 0 [ALS.MAIN] Exit_Notification: [ALS.MAIN] DidChangeConfiguration_Notification: ada=(trace=(server=off)projectFile=scenarioVariables=()defaultCharset=iso-8859-1documentationStyle=gnatdisplayMethodAncestryOnNavigation=usage_and_abstract_onlyenableDiagnostics=...JSON_BOOLEAN_TYPEenableIndexing=...JSON_BOOLEAN_TYPEfoldComments=...JSON_BOOLEAN_TYPEfollowSymlinks=...JSON_BOOLEAN_TYPEnamedNotationThreshold=...JSON_INT_TYPErelocateBuildTree=rootDir=useCompletionSnippets=...JSON_BOOLEAN_TYPErenameInComments=...JSON_BOOLEAN_TYPEonTypeFormatting=(indentOnly=...JSON_BOOLEAN_TYPE)) [ALS.MAIN] Looking for a project... [ALS.MAIN] Root : /Users/joe/Development/pico_examples/adc_hello [ALS.MAIN] Loading /Users/joe/Development/pico_examples/adc_hello/adc_hello.gpr [ALS.MAIN] On_SetTrace_Notification: OFF [ALS.MAIN] On_SetTrace_Notification: OFF [ALS.MAIN.EXCEPTIONS] Unexpected exception: raised GPR2.PROJECT_ERROR : /Users/joe/Development/pico_examples/adc_hello/adc_hello.gpr: fatal error, cannot load the project tree ALS.MAIN.EXCEPTIONS 0x000000010A964A7F 0x000000010A9672E2 0x000000010A969910 0x0000000109361515 0x0000000109364A23 0x0000000109365993 0x0000000109366EC0 0x00000001091944B9 0x0000000109194AF8 0x000000010B1216F8 0x00007FF8148F61D1 [ALS.MAIN] Loading the implicit project [ALS.MAIN] Show_Message: kb: warning: can't find a toolchain for the following configuration: language 'Ada', target 'arm-eabi', runtime 'light-cortex-m0p' [ALS.MAIN] Show_Message: Unable to load project file: /Users/joe/Development/pico_examples/adc_hello/adc_hello.gpr ALS.MAIN adc_hello.gpr:1:06: error: imported project file "pico_bsp.gpr" not found [ALS.MAIN] RegisterCapability_Request: Request 2 1 [ALS.MAIN] RegisterCapability_Request: Request 3 6 [ALS.MAIN] Shutting server down ... [ALS.MAIN] UnregisterCapability_Request: Request 4 1

reznikmm commented 10 months ago

Do you have alr in the PATH? I don't see any alire invocation in your trace :thinking:

Which is alr on your system? According to the trace PATH is

PATH: /usr/local/bin:/usr/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin

Joebeazelman commented 10 months ago

/usr/local/bin