Closed 1ma closed 1 year ago
A nasty side effect of this error I didn't notice before: it breaks code navigation for all sources (Ctrl+Clicking symbols).
Edit: In the meantime, using the full relative path to the third party GPR files instead of just with "crate.gpr";
seems to fix the issue. Of course, each time a dependency is updated the path needs to change, too.
Hello @1ma This issue duplicates #503, I guess.
How should ALS find that the project uses alire
?
Sorry, I saw it but I thought it was more of a philosophical discussion and didn't want to hijack it with an issue.
Regarding your question, maybe ALS could check if the current project contains any alire.toml
file, and do something from there.
Alire has a alr edit
command that can start you favorite editor in the context of the crate.
The default is to use GNATstudio, but you can configure it to start VScode. If that helps.
I've been using alr config --set editor.cmd "code ."
pretty successfully, since it sets the environment prior to startup, including GPR_PROJECT_PATH
. The big issue I run into is that the GPR project file for the extension is per-workspace, so I have to change the GPR when I work on different projects, but it works well when it is set.
@Fabien-Chouteau is it possible to set up a way to feed the project-specific GPR from Alire to the extension? I'd like to make a "Modern Ada with Alire" tutorial, but hand-modifying the project GPR on a per-project basis is a bit rough of a stumbling block for new programmers, and an irritant to more seasoned programmers.
IMHO, it would still be better to make ALS Alire-aware. The reason are polyglot IDEs and editors. Launching such programs with a language-specific command seems a bit awkward, given one can switch to an entirely different kind of project inside running a instance. Also, many people launch IDEs and editors with GUI launchers and such workaround forces these people to alter the launchers or to create command aliases. @1ma's suggestion to detect alire.toml
seems the right way to do it. At least this is how rust-analyzer does it with Cargo.toml
, AFAIK.
Please try VS Code Ada extension 23.0.15. It should work now.
Scenario
A project bootstrapped by Alire can depend on "crates" from the Alire registry through the usual
with "crate.gpr";
statements in your GPR file. Then, if instead of building your project withgprbuild
you usealr build
, Alire takes care of downloading any dependencies into the project root directory (underalire/
) and silently sets the appropriateGPR_PROJECT_PATH
forgprbuild
so that your GPR file can see and build these sources as if they were in any well-known location of your system.However, the Ada extension can't see this third party code that lives inside the project's working directory.
Real Example
https://github.com/1ma/radatracer
The repository is organized in 2 project files, one for library code and another for executable programs. The latter depends on the library GPR file and "aunit.gpr", managed by Alire. If we clone the repository and run
alr build
Alire will download AUnit 21.0.0 underalire/cache/dependencies/aunit_21.0.0_d6561681
and build the executables successfully, includingaunit_harness
. But if we open VSCode the plugin will show this error, and navigation for AUnit types and functions will not work:(Note: the
ada.projectFile
setting is enforced toexecutables.gpr
in.vscode/settings.json
)