AdaCore / ada_language_server

Server implementing the Microsoft Language Protocol for Ada and SPARK
GNU General Public License v3.0
228 stars 54 forks source link

alr get fails due to changing LIBRARY_TYPE #1026

Closed stephe-ada-guru closed 1 year ago

stephe-ada-guru commented 2 years ago

I'm running alire on Debian testing, with Debian gnat GNAT 11.3.0.

$ alr get ada_language_server ⓘ Deploying ada_language_server=22.0.0... -=#=- # # #
error: Trying to set an already defined environment variable: error: LIBRARY_TYPE is already defined as 'static' but new value is 'relocatable'

stephe-ada-guru commented 2 years ago

running 'ali -v get ada_language_server' gives more detail:

detail: Env: ada_language_server (gpr ext) sets 'static' to 'LIBRARY_TYPE' detail: Env: langkit_support (gpr ext) sets 'relocatable' to 'LIBRARY_TYPE'

So I deleted LIBRARY_TYPE from ada_language_server_22.0.0_ef4bdf41/alire.toml, but that didn't help. Where else is it specified?

Is there a way to override this setting?

reznikmm commented 2 years ago

May be you have LIBRARY_TYPE in the env? Try to

unset LIBRARY_TYPE
alr get ada_language_server

Try to update alr index --update-all.

stephe-ada-guru commented 2 years ago

LIBRARY_TYPE in environment; nope. index --update-all; already up to date.

I'm guessing that alr is getting the setting for LIBRARY_TYPE from the crate *.toml file, not the edited one on my disk. So unless there is some way to override that from the command line, this can only be fixed by publishing a new crate?

I tried setting LIBRARY_TYPE; that gives a more immediate error: $ export LIBRARY_TYPE=static $ alr get ada_language_server error: Trying to set an already defined environment variable: error: LIBRARY_TYPE is already defined as 'static' but new value is 'relocatable'

stephe-ada-guru commented 2 years ago

Why do the ada_language_server and langkit_support crates specify LIBARARY_TYPE in alire.toml [gpr_external]? there's a default setting in the .gpr, and both defaults are "relocatable", and both have package-specific override environment vars.

reznikmm commented 2 years ago

I see now, why I can't reproduce this issue with Alire compiler. Langkit sets LIBRARY_TYPE only for system compiler for unknown (to me) reason.

[gpr-set-externals."case(toolchain)".system]
LIBRARY_TYPE = "relocatable"

When I set LIBRARY_TYPE as static in ada_language_server my intention was to help user get statically linked ALS. Now I see that this idea is bad. I'll remove this clause from als .toml. Meantime you may want to try more fresh version of ALS using my own alire index.

stephe-ada-guru commented 2 years ago

After editing the local copy of alire.toml to comment out setting LIBARY_TYPE, 'alr build' succeeds.

So I have a workaround, but there is a packaging bug in the released crate.

stephe-ada-guru commented 2 years ago

I did not see your reply about 'drop setting LIBRARY_TYPE'. Just FYI, when I used 'alr build', I chose gnat_native=12.1.2, not the system compiler. That gave the same error.

And langkit_support sets LIBRARY_TYPE in alire.toml as well. I suspect it should never be set in any crate.

Thanks for fixing this.

stephe-ada-guru commented 1 year ago

ada_language_server 23 builds without error