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

VS code extension can't find some project files when included with Alire #1180

Open dalybrown opened 5 months ago

dalybrown commented 5 months ago

Projects that seem to have their own actions for building / installing in non-standard places seem to be problematic for Alire and it results in all code being non-navigable.

For example, trying to include the Ada Web Server in a project (i.e., alr with aws) exposes this problem because AWS has actions to build/install itself when deployed. It seems like within the Alire environment the GPR_PROJECT_PATH is set correctly to the installed path of AWS, but VS code still complains. All code is then non-navigable. It is built properly though (as in alr build picks up the right environment).

It's easy to reproduce: just create a new project, with aws, and try to navigate the code. The issue seems to be present using shared and non-shared dependencies in Alire.

dalybrown commented 5 months ago

What's weird is even if I install the ada web server outside of alire into a standard place in my GPR_PROJECT_PATH using gprinstall ... VS Code still becomes problematic and I lose all navigation to all code. It seems to be something particular with that project because I've installed other projects to the shared location and VS code worked fine.

I noticed that occasionally it will actually find the projects if I just reload the window a few times in a row. There is a bug somewhere here.

AnthonyLeonardoGracio commented 5 months ago

Hello @dalybrown,

We'll try to reproduce on our side. Thanks for the report. We might come back to ask you more questions.

Regards,

dalybrown commented 5 months ago

Thanks. Yeah I don't know how else to precisely explain the problem. I can reproduce it in my environment easy enough though. I wonder if there is a race condition between indexing / finding all the projects and their sources and the VS code extension declaring there is a problem with the environment and giving up.

AnthonyLeonardoGracio commented 4 months ago

Are you using the VS Code remote mode?

dalybrown commented 4 months ago

Yeah... we develop in a docker container, so we are always using the remote development extensions. (Specifically, we use dev containers and so we use the builtin support of the remove development extensions for those.)

AnthonyLeonardoGracio commented 4 months ago

Ok I see, thanks for the quick answer.

As you may know, VS Code's environment management with the Remote mode requires to specify the environment per workspace, as described in our documentation here.

Have you already followed these instructions?

dalybrown commented 4 months ago

I did not see those instructions.

To be clear: this setup works without that most of the time. It is only the odd time (e.g., with the scenario I described above) where we see these issues. I set the GPR_PROJECT_PATH to the paths to projects that I use that are not managed by Alire (which, in this case, is AWS because the extension wasn't working when installing AWS with Alire).

I don't quite understand what the MAIN_NUMBER is though.

AnthonyLeonardoGracio commented 4 months ago

MAIN_NUMBER is just an environment variable's example, in that case to control a project's scenario value.

We'll have a look to the scenario you described. Keeping you posted.

Regards,

reznikmm commented 1 week ago

Could you try 24.0.6 version this too?

dalybrown commented 1 week ago

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

XLCOLDJ commented 1 week ago

Could you try 24.0.6 version this too?

On my aarch64 Mac I was having similar issues until this new release (the .workspace paths not updating, so no navigatin worked). It seems OK now, but it doesn't actually update the .workspace file until the project is closed and re-loaded (project-reload command doesn't work).