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

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

Open
Joebeazelman opened this issue Jul 30, 2023 · 15 comments
Open

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

Joebeazelman opened this issue Jul 30, 2023 · 15 comments

Comments

@Joebeazelman
Copy link

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

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

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

  • Setup hello_pico.gpr as described there: Create a new project
  • Launch code . in hello_pico/ directory
  • Click "/Terminal/Run Build Task..." (Ctrl+Shift+B) and select "ada: Build current project" in the list
  • VScode launch alr exec -- gprbuild -cargs -gnatef in the terminal and it build my project without error.

@Joebeazelman
Copy link
Author

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

@Joebeazelman
Copy link
Author

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

reznikmm commented Aug 8, 2023

@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
Copy link
Author

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
Copy link
Author

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

reznikmm commented Aug 12, 2023

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

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
Copy link
Author

/usr/local/bin

@mgrojo
Copy link

mgrojo commented Aug 23, 2024

I have the same problem or a similar one. When opening the repository with "code .", I get this error: "can't find a toolchain for the following configuration: language 'Ada', target 'x86_64-linux', default runtime", and navigation to predefined library is not working. The build task works fine invoking alr build.

My trace file:

[ALS.MAIN] ALS version: 24.0.6 ()
[ALS.MAIN] Initializing server ...
[ALS.MAIN] GPR PATH: 
[ALS.MAIN] PATH: /home/mgr/.nvm/versions/node/v20.15.1/bin:/home/mgr/gems/bin:/home/mgr/.cargo/bin:/home/mgr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/mgr/.local/bin:/home/mgr/.alire/bin
[ALS.MAIN] Ada version used for predefined completion: ADA_2020
[ALS.MAIN] Looking for a project... Root:
[ALS.MAIN] file:///home/mgr/src/github/mgrojo/play_2048
[ALS.MAIN] Check alire:
[ALS.MAIN] Project:
[ALS.MAIN] play_2048.gpr
[ALS.MAIN] GPR2 Log Messages:
[ALS.MAIN] embedded_kb/kb can't find a toolchain for the following configuration: language 'Ada', target 'x86_64-linux', default runtime
[ALS.MAIN] /home/mgr/src/github/mgrojo/play_2048/play_2048.gpr Parsing "/home/mgr/src/github/mgrojo/play_2048/play_2048.gpr"
[ALS.MAIN] /home/mgr/src/github/mgrojo/play_2048/play_2048.gpr project search path: /home/mgr/src/github/mgrojo/play_2048:/home/mgr/.local/share/alire/builds/ada_toml_0.2.0_f07de487/b39da9561a1f1795e468c12b8cc1c7fbffc6cd8fc69a84bbb6109657c2263514:/home/mgr/.local/share/alire/builds/asfml_2.5.4_c428084e/0e975554e16eff250ccb2634e648c88667e108ae391d82c5971ddbc91268ac7d
[ALS.MAIN] In Message_Handler Text_Document_Did_Open URI:
[ALS.MAIN] file:///home/mgr/src/github/mgrojo/play_2048/src/play_2048.adb
[ALS.MAIN] Out Message_Handler Text_Document_Did_Open
[ALS.MAIN] In Message_Handler Text_Document_Did_Open URI:
[ALS.MAIN] file:///home/mgr/.local/share/alire/builds/asfml_2.5.4_c428084e/0e975554e16eff250ccb2634e648c88667e108ae391d82c5971ddbc91268ac7d/include/sf-window-keyboard.ads
[ALS.MAIN] Out Message_Handler Text_Document_Did_Open
[ALS.MAIN] In Message_Handler Text_Document_Did_Open URI:
[ALS.MAIN] file:///home/mgr/src/github/mgrojo/play_2048/src/game.adb
[ALS.MAIN] Out Message_Handler Text_Document_Did_Open
[ALS.MAIN] In Message_Handler Text_Document_Did_Open URI:
[ALS.MAIN] file:///home/mgr/src/github/mgrojo/play_2048/src/game.ads
[ALS.MAIN] Out Message_Handler Text_Document_Did_Open
[ALS.MAIN] In Message_Handler Text_Document_Did_Open URI:
[ALS.MAIN] file:///home/mgr/src/github/mgrojo/play_2048/src/game.ads
[ALS.MAIN] Out Message_Handler Text_Document_Did_Open
$ alr version
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
APPLICATION
alr version:               2.0.1
libalire version:          2.0.1
compilation date:          2024-03-21 11:05:29
compiled with version:     10.5.0

CONFIGURATION
settings folder:           /home/mgr/.config/alire
cache folder:              /home/mgr/.local/share/alire
vault folder:              /home/mgr/.local/share/alire/releases
build folder:              /home/mgr/.local/share/alire/builds
temp folder:               /run/user/1000
force flag:                FALSE
non-interactive flag:      FALSE
community index branch:    stable-1.3.0
compatible index versions: ^1.1 & <=1.3.0
indexes folder:            /home/mgr/.config/alire/indexes
indexes metadata:          OK
index #1:                  (community) git+https://github.com/alire-project/alire-index#stable-1.3.0
toolchain folder:          /home/mgr/.local/share/alire/toolchains
toolchain assistant:       disabled
tool #1 gnat:              gnat_external=12.3.0
tool #2 gprbuild:          gprbuild=18.0.0
system package manager:    /usr/bin/apt
distro detection disabled: FALSE

WORKSPACE
root status:               VALID
root release:              play_2048=1.0.1-beta
root load error:           none
root folder:               /home/mgr/src/github/mgrojo/play_2048
current folder:            /home/mgr/src/github/mgrojo/play_2048

SYSTEM
distribution:              UBUNTU
host-arch:                 X86_64
os:                        LINUX
target:                    NATIVE
toolchain:                 SYSTEM
word-size:                 BITS_64
$ alr toolchain
CRATE         VERSION       STATUS    NOTES                               
gprbuild      18.0.0        Default   Detected at /usr/bin/gprbuild       
gprbuild      22.0.1        Available                                     
gprbuild      2021.0.0+0778 Available Provided by system package: gprbuild
gnat_native   11.2.4        Available                                     
gnat_native   13.2.1        Available                                     
gnat_external 12.3.0        Default   Detected at /usr/bin/gnat           
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.4 LTS
Release:	22.04
Codename:	jammy

@mgrojo
Copy link

mgrojo commented Aug 23, 2024

alr location:

$  which alr
/home/mgr/bin/alr
$ ls -l /home/mgr/bin/alr
lrwxrwxrwx 1 mgr mgr 45 may  4 21:04 /home/mgr/bin/alr -> /home/mgr/programas/alr-2.0.1-x86_64.AppImage

@mgrojo
Copy link

mgrojo commented Aug 23, 2024

Also affected without Alire. The same error message following the tutorial just before point Explore Intellisense, and then Intellisense for Ada.Text_IO does not work.

Nevertheless, pressing the Run button in the main, the program is built and run without problem.

gprbuild on PATH is from Ubuntu package gprbuild 2021.0.0.0778b109-5. GNAT is from gnat-12 12.3.0-1ubuntu1~22.04 package.

$ gprbuild  -vh
GPRBUILD Pro 18.0w (19940713) (x86_64-pc-linux-gnu)
Copyright (C) 2004-2016, AdaCore
using project file hello_world.gpr
 8 lines: No errors
TMPDIR = "/tmp"
/usr/bin/gprconfig --batch -o /tmp/GNAT-TEMP-000001.TMP --target=x86_64-linux-gnu --fallback-targets --config=ada,,,,
Checking configuration /tmp/GNAT-TEMP-000001.TMP
Setting the default project search directories
   Adding directory "/usr/x86_64-linux-gnu/share/gpr"
   Adding directory "/usr/x86_64-linux-gnu/lib/gnat"
   Adding directory "/usr/share/gpr"
   Adding directory "/usr/lib/gnat"
/usr/bin/gprconfig --batch -o /tmp/GNAT-TEMP-000002.TMP --target=x86_64-linux-gnu --fallback-targets --config=ada,,,,
Checking configuration /tmp/GNAT-TEMP-000002.TMP
Setting the default project search directories
   Adding directory "/usr/x86_64-linux-gnu/share/gpr"
   Adding directory "/usr/x86_64-linux-gnu/lib/gnat"
   Adding directory "/usr/share/gpr"
   Adding directory "/usr/lib/gnat"
   Checking /home/mgr/tmp/projects/helloworld/hello_world.adb ... 
      -> object file /home/mgr/tmp/projects/helloworld/.objs/hello_world.o does not exist
Changing to object directory of "Hello_World": "/home/mgr/tmp/projects/helloworld/.objs/"
Creating temp file "/tmp/GNAT-TEMP-000003.TMP"
/usr/bin/gnatgcc -c -x ada -gnatA -g -gnatec=/tmp/GNAT-TEMP-000003.TMP -gnatem=/tmp/GNAT-TEMP-000004.TMP /home/mgr/tmp/projects/helloworld/hello_world.adb
   Checking binder generated files for hello_world.adb...
      -> binder exchange file hello_world.bexch does not exist
ADA_PRJ_OBJECTS_FILE = /tmp/GNAT-TEMP-000006.TMP
/usr/lib/gprbuild/gprbind hello_world.bexch
/usr/bin/gnatbind -o b__hello_world.adb /home/mgr/tmp/projects/helloworld/.objs/hello_world.ali -x -F=/tmp/GNAT-TEMP-000005.TMP -O=/tmp/GNAT-TEMP-000007.TMP
/usr/bin/gnatgcc -c -x ada -gnatA -c -gnatA -gnatWb -gnatiw -gnatws -g -mtune=generic -march=x86-64 b__hello_world.adb -o b__hello_world.o
Adalib_Dir = "/usr/lib/gcc/x86_64-linux-gnu/12/adalib/"
Prefix_Path = "/usr/lib/gcc/x86_64-linux-gnu/12:/usr/lib/gcc/x86_64-linux-gnu:/usr/lib"
   Checking libhello_world.a ...
      -> archive does not exist
      -> there is no global archive
   Checking executable for hello_world.adb ...
      -> executable does not exist
/usr/bin/gnatgcc hello_world.o b__hello_world.o -L/home/mgr/tmp/projects/helloworld/.objs/ -L/home/mgr/tmp/projects/helloworld/.objs/ -L/usr/lib/gcc/x86_64-linux-gnu/12/adalib/ -shared-libgcc -lgnat-12 -ldl -Wl,-rpath-link,/usr/lib/gcc/x86_64-linux-gnu/12//adalib -Wl,-z,origin,-rpath,$ORIGIN/:/usr/lib/gcc/x86_64-linux-gnu/12/adalib:/usr/lib64:/usr/lib -o hello_world
$ gprconfig --show-targets
List of targets supported by a compiler:
x86_64-linux-gnu

I see in the output two possible causes:

  • The compiler executable is gnatgcc (I think it's a Debian customization). Is vscode querying gcc directly? But in any case, gcc -v says it also has Ada as enabled language. (gcc is from package gcc 4:11.2.0-1ubuntu1)
  • The used target is x86_64-linux-gnu and not to x86_64-linux as put in the error message.

@ogorodnik
Copy link
Contributor

alr can't use grpbuild from the Ubuntu. Could you execute the following command to setup gnat & gprbuild from alr itself:

alr toolchain --select gprbuild^22 gnat_native^14

@mgrojo
Copy link

mgrojo commented Aug 27, 2024

alr can't use grpbuild from the Ubuntu. Could you execute the following command to setup gnat & gprbuild from alr itself:

alr toolchain --select gprbuild^22 gnat_native^14

As I said in my previous comment, the problem is reproducible without Alire. See this screenshot, just after creating the hello_world.gpr following the tutorial; it already marks the problem.

imagen

Nevertheless, I tried selecting the toolchain as indicated, but it didn't change the problem in Alire crates opened in vscode. In fact, Alire by itself didn't have any problem when called from the command line and even when called by the vscode extension to build the crate, so my impression this problem is not really related to Alire, but just a problem between the vscode extension and the gprbuild found in the path, which is /usr/bin/gprbuild regardless of the toolchain selection in Alire.

@reznikmm
Copy link
Member

ALS can't find Ubuntu/Debian GNAT if its version doesn't match GCC. (in your case gcc 11.2 and gnat 12.3). That is because Ubuntu/Debian maintainers rename gcc to gnatgcc and fix *.xml in gprconfig database. But ASL uses (unfixed) database embedded in libgpr2. This was reported in #1146 and it has not been fixed yet in libgpr/libgpr2/knowledge_db.

@mgrojo
Copy link

mgrojo commented Aug 31, 2024

Thanks, @reznikmm. After aligning versions of Ubuntu's packages for gcc and gnat for version 11 the problem is gone for both cases, working with Alire and plain gprbuild. I've checked also that the Alire version is still navigating to the toolchain selected in Alire. I think I can live with this workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants