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

no code navigation in the VS Code extension when using Alire projects #1192

Open dalybrown opened 2 months ago

dalybrown commented 2 months ago

We lost the ability to navigate code sometime a couple months ago (rough estimate) using the VS Code extension. We exclusively use Alire to manage our projects and dependencies. We develop in a remote container using dev containers and the VS code extension.

It might have something to do with the version of Alire we are using (2.0.1) or the version of the extension (v24.0.5).

We have tried adjusting where the dependencies are cached using:

alr settings --global --set dependencies.shared false

and this still does not fix it. The VS Code extension complains it can't find any of the project files we depend on. These dependencies are managed by Alire.

Somewhere a regression has been introduced. Our environment used to work with SPARK/Ada and Alire, and still works for every other language we develop with.

We see this behaviour on both amd64 and arm64 platforms and with different Alire projects.

dalybrown commented 2 months ago

Here is a reproducer ... just open this folder in VS code and, using the dev container extension, it will build the the dev container automatically and install the Ada VS code extension. You'll notice you can't navigate code but building with alire works fine.

reproducer.tar.gz

reznikmm commented 2 months ago

Hello @dalybrown

Thank you for self-contained reproducer! I'm able to reproduce. Probably, the reason is that ALS launches two instances of alr simultaneously (alr show and alr printenv) and this doesn't work with alr 2.0 any more.

To unblock you I propose to rename alr to alr2 and create a shell wrapper for alr:

#!/bin/bash

LOCK=/tmp/alr.lock

if [[ "$1/$2" =~ --non-interactive/(show|printenv) ]] ; then
  while ! { set -C; 2>/dev/null >$LOCK; } ; do sleep 0.5 ; done
  trap "rm -f $LOCK" EXIT
fi

${0}2 "$@"

I guess you also may need to add alr -n build after alr -n update to let Alire run pre/post build actions. Or you can run alr build in the terminal and then launch "Ada: Reload project" from vscode command palette.

Please let us know if this works for you.

dalybrown commented 2 months ago

Thanks for the reply.

Before we start implementing workarounds (this affects more than just me), is this something that is planned to be fixed soon (ish)? We can live without code navigation for a bit longer...

Let me know! Thanks!

reznikmm commented 2 months ago

I'm going to change ALS code to launch alr sequentially, but it has not been decided when we will release v24.0.6 yet.

dalybrown commented 2 months ago

Thanks for the response! I'll try out your proposal this week (and monitor for the updated extension). Cheers!

dalybrown commented 1 month ago

I also see this error quite a bit in the console (not sure it's related):

alr_env.gpr[Ln 1, Col 1]: Project file has errors and can't be loaded.
[Ln 2, Col 2]: project file "/path/to/project/alire/alr_env.gpr" not found

I didn't get a chance to try the workaround - I haven't been able to do much development the past couple of weeks :(. I'll try to get around to it today or next week.

reznikmm commented 1 week ago

Could you try 24.0.6 version?

dalybrown commented 1 week ago

I will try this next week when I (hopefully) get back to coding. Thanks!