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

Ada Extension cannot find compiler chain in WSL2 (22.04 Ubuntu) #1146

Open
moverby44 opened this issue May 16, 2023 · 10 comments
Open

Ada Extension cannot find compiler chain in WSL2 (22.04 Ubuntu) #1146

moverby44 opened this issue May 16, 2023 · 10 comments

Comments

@moverby44
Copy link

Environment is WSL2 on Windows 11 2H22. Distro is Ubuntu Jammy.
I did a sudo apt install gnat gprbuild
Both completed with success.
I have the ALS installed with version 23.0.17.

I can manually compile with gprbuild the hello_world example from the ALS tutorial.
However, I'm getting no language server behavior and it is complaining that it cannot find a toolchain. If I open a terminal from VS Code and do gnatls, I see the expected output. I can also do a gprbuild for the .gpr file from the hello_world example and it compiles correctly and the program runs normally. However, the language server insists that there is no tool chain.

Suggestions? Or is this a bug?

@moverby44
Copy link
Author

moverby44 commented May 16, 2023

I eventually get this message as well:
The project was loaded, but no Ada runtime found. Please check the installation of the Ada compiler.

I should reinforce, from a VS code terminal window, I can gprbuild the file as well as execute the resulting binary.

@reznikmm
Copy link
Contributor

@moverby44
Copy link
Author

Yes I have. VS Code works properly for other language servers (C++ as an example).
I even just tested this on a fresh laptop with a new WSL2 install of ada. I walked through the steps in the linked page.

I also, walked through the steps here:
https://github.com/AdaCore/ada_language_server/wiki/Getting-Started

After several minutes it complains about no ada toolchain.
A gprbuild from the command line succeeds (from a VS code terminal even).

Screen shots attached.

Screenshot 2023-05-17 003935 Screenshot 2023-05-17 004241

@moverby44
Copy link
Author

Just to make sure this wasn't a specific WSL2 problem. I also spun up an x86_64 EC2 instance clean and installed everything and did a remote SSH connection through code to the EC2 instance and I'm getting basically the same error (although it happens much faster).

Screenshot 2023-05-17 010609

@brownts
Copy link

brownts commented May 17, 2023

This is likely due to a version mismatch between the GNAT and GCC versions you have installed. I had pretty much the same problem recently on Ubuntu. By default, sudo apt install gnat will install gnat-10. GCC defaults to gcc-11 on Ubuntu 22.04. ALS can't find the run-time when you have a mismatched GNAT/GCC installation like this. Try installing gnat-11, or whatever version matches your GCC installation (i.e., gcc --version).

@reznikmm
Copy link
Contributor

Could you try to install gnat_native and gprbuild with Alire and try with them?

@moverby44
Copy link
Author

I will try both suggestions. I'm not sure about the gcc version, I thought on my clean install gnat forced a load of a matching gcc, but I'll check.

I'll also try Alire, but unfortunately on WSL2 anyway when I tried Alire before I gave up as the performance was horrible. A hello world app took 4 minutes to build. The same code with gprbuild took a second. But I will try the combination as well.

@moverby44
Copy link
Author

Bingo. I think we have a winner. @brownts nailed it. apt removed everything and did gcc with gnat-11 and it works on ec2. I'll try WSL2 next.

@moverby44
Copy link
Author

moverby44 commented May 17, 2023

Also verified that it fixes WSL2.

Should this get added to the Ada language server front page?

@reznikmm
Copy link
Contributor

reznikmm commented Jun 5, 2023

We have added more diagnostic messages in the extension 23.0.18. While we seek to better support Debian/Ubuntu Ada toolchains, I think, it worth to mention this bug on Ada language server front page, indeed.

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

3 participants