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

[Bug]: ./scripts/build_als.sh fails on Mac Sequoia #1236

Open
rogermc2 opened this issue Jan 31, 2025 · 25 comments
Open

[Bug]: ./scripts/build_als.sh fails on Mac Sequoia #1236

rogermc2 opened this issue Jan 31, 2025 · 25 comments
Labels

Comments

@rogermc2
Copy link

Environment

  • OS and Version: Mac OSX 15.3
  • IDE Version: None. Running from Terminal
  • Ada & SPARK Extension Version: gcc-14.2.0-3-aarch64

Bug Summary and Reproducer

Bug Summary: ./scripts/build_als.sh failed after Successfully installed Langkit-0.1.0:

  • python manage.py make --no-mypy --generate-auto-dll-dirs --library-types=relocatable --gargs '-m -v -cargs:ada -gnateb'
    Traceback (most recent call last):
    File "/System/Volumes/Data/Ada_Source/ada_language_server/subprojects/langkit_support/manage.py", line 14, in
    from langkit.packaging import NativeLibPackager
    File "/System/Volumes/Data/Ada_Source/ada_language_server/subprojects/langkit_support/langkit/packaging.py", line 12, in
    from langkit.utils import LibraryType
    File "/System/Volumes/Data/Ada_Source/ada_language_server/subprojects/langkit_support/langkit/utils/init.py", line 341, in
    from langkit.utils.text import *
    File "/System/Volumes/Data/Ada_Source/ada_language_server/subprojects/langkit_support/langkit/utils/text.py", line 50, in
    class Language(enum.StrEnum):
    AttributeError: module 'enum' has no attribute 'StrEnum'
    error: Command ["bash", "-x", "./scripts/build_als.sh", "build_langkit_raw"] exited with code 1

Steps to reproduce:In ada_language_server run ./scripts/build_als.s

Expected behavior:./scripts/build_als.sh runs to completion without errors

Configuration and Logs

cat $HOME/.als/gpr_ls_traces.cfg
>gpr_ls_log.$T.log:buffer_size=0:buffer_size=0
ALS.MAIN=yes
ALS.IN=no
ALS.OUT=no

Other VS Code Extensions

No response

Additional context

No response

@rogermc2 rogermc2 added the bug label Jan 31, 2025
@eliericha
Copy link
Contributor

Hello there,

This looks like a mismatch in the version of Python. Which Python version does your system have? You need Python 3.11 or newer to build langkit which is a dependency of ALS.

@rogermc2
Copy link
Author

This computer did have some old versions of Python which I have now deleted. However I still get:
`PS1='(.venv) '
++ export PS1
++ VIRTUAL_ENV_PROMPT='(.venv) '
++ export VIRTUAL_ENV_PROMPT
++ '[' -n /opt/homebrew/bin/bash -o -n '' ']'
++ hash -r

  • case $STEP in
  • build_langkit_raw
  • cd subprojects/langkit_support
  • echo GPR_PROJECT_PATH=`
................   Long printout of GPR_PROJECT_PATH  .............
sed -i.bak -e s/GPR_BUILD/GPR_LIBRARY_TYPE/ ./langkit/libmanage.py
+ pip install .
./scripts/build_als.sh: line 162: /System/Volumes/Data/Ada_Source/ada_language_server/.venv/bin/pip: cannot execute: required file not found
error: Command ["bash", "-x", "./scripts/build_als.sh", "build_langkit_raw"] exited with code 127`
```
Python now seems OK:
```
 python
Python 3.13.1 (main, Dec  3 2024, 17:59:52) [Clang 16.0.0 (clang-1600.0.26.4)] on darwin
```
`pip --version
pip 24.3.1 from /opt/homebrew/lib/python3.13/site-packages/pip (python 3.13)`

@eliericha
Copy link
Contributor

It's likely that the lingering virtual env ada_language_server/.venv is still referencing the now deleted old Python version.

So it must be deleted, and then build_als.sh will recreate it.

@rogermc2
Copy link
Author

./scripts/build_als.sh doesn't seem to recreate ada_language_server/.venv:
` OS_LIB_EXT=.dylib

  • activate_venv
  • '[' -d /System/Volumes/Data/Ada_Source/ada_language_server/.venv ']'
  • python -m venv /System/Volumes/Data/Ada_Source/ada_language_server/.venv
    ./scripts/build_als.sh: line 79: python: command not found`

@eliericha
Copy link
Contributor

Do you have a python executable on the PATH? What is the output of which python and which python3 ?

@rogermc2
Copy link
Author

In PATH:
/opt/homebrewl/Cellar/[email protected]/3.13.0_1

which python python: aliased to python3
which python3 /opt/homebrew/bin/python3
python3 --version Python 3.13.1

@github-openvsx-adacore
Copy link

python is defined as an alias. I suspect this is not enough to make the build script find it. I suggest creating a symbolic link to python3 in a location on PATH instead of the alias to see if that helps.

@rogermc2
Copy link
Author

rogermc2 commented Feb 1, 2025

I cleaned up python aliases quite a lot and created symbolic links python an python3 to python3.13 in /usr/local/bin
`Roger@Rogers-MacBook-Air-2 ada_language_server % which python
python: aliased to python3

Roger@Rogers-MacBook-Air-2 ada_language_server % which python3
/opt/homebrew/bin/python3
`
These show as aliases but they were created using ln -s.

./scripts/build_als.sh now fails with:
`activate_venv

  • '[' -d /System/Volumes/Data/Ada_Source/ada_language_server/.venv ']'
  • python -m venv /System/Volumes/Data/Ada_Source/ada_language_server/.venv
    ./scripts/build_als.sh: line 79: python: command not found`

@simonjwright
Copy link
Contributor

I don't understand some of the comments above.

Perhaps it would help if @rogermc2 could say what ada_language_server source version he's using?

I'm using the source archive from the 26.0.202412191 release, and in that archive scripts/build_als.sh doesn't setup or activate a virtual environment, nor is there any reference to OS_LIB_EXT.

@rogermc2
Copy link
Author

rogermc2 commented Feb 5, 2025

I don't know which version of ada_language_server. I cloned it on 31 January 2025. Maybe 26.0.202412190 which is stated i the Changelog. I'll try 26.0.202412191

@rogermc2
Copy link
Author

rogermc2 commented Feb 5, 2025

I tried source archive from the 26.0.202412191 release, but ./scripts/build_als.sh failed.
sudo ./scripts/build_als.sh
vss_gnat.gpr:11:17: no compiler for language "Ada", cannot compile "a-suvsau.adb" gprbuild: *** compilation phase failed Traceback (most recent call last): File "/System/Volumes/Data/Ada_Source/ada_language_server-26.0.202412191/subprojects/langkit_support/manage.py", line 443, in <module> args.func(args, unknown_args) ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ File "/System/Volumes/Data/Ada_Source/ada_language_server-26.0.202412191/subprojects/langkit_support/manage.py", line 135, in wrapper fn(args) ~~^^^^^^ File "/System/Volumes/Data/Ada_Source/ada_language_server-26.0.202412191/subprojects/langkit_support/manage.py", line 298, in make build_langkit_support(args) ~~~~~~~~~~~~~~~~~~~~~^^^^^^ File "/System/Volumes/Data/Ada_Source/ada_language_server-26.0.202412191/subprojects/langkit_support/manage.py", line 166, in build_langkit_support subprocess.check_call( ~~~~~~~~~~~~~~~~~~~~~^ base_argv ^^^^^^^^^ + ["-P", SUPPORT_GPR, f"-XLIBRARY_TYPE={library_type.value}"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + gargs ^^^^^^^ ) ^ File "/opt/homebrew/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/subprocess.py", line 419, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['gprbuild', '-p', '-j8', '-XBUILD_MODE=dev', '-P', '/System/Volumes/Data/Ada_Source/ada_language_server-26.0.202412191/subprojects/langkit_support/langkit/support/langkit_support.gpr', '-XLIBRARY_TYPE=relocatable', '-cargs', '-fPIC']' returned non-zero exit status 4. error: Command ["bash", "./scripts/build_als.sh", "build_so_raw"] exited with code 1

Can't find Ada compiler?
`which gnat

/opt/gcc-14.2.0-3-aarch64/bin/gnat
`

@simonjwright
Copy link
Contributor

Perhaps it’s because of using sudo? - you shouldn’t need to.

26.0.202412190 is the pre-release, 26.0.202412191 is the release.

The build script runs alr internally (I think it creates alire.toml on the fly). I used alr toolchain --select to choose the None option (use the compiler, gprbuild on the PATH) before invoking the script.

I’m using Homebrew’s python 3.11.

I’ve been scratching around trying to get a build with a private build of GCC 15.0.1 (for reasons) and I don’t remember why I stopped using the source release and built from the repo (as documented). There was (at least!) one problem that’d need to be fixed (I privately reverted that commit, it took some doing to find the actual parent!)

@rogermc2
Copy link
Author

rogermc2 commented Feb 5, 2025

I probably used sudo out of desperation! I decided to try on another computer but didn't get very far:
`bprojects/adasat.toml -> subprojects/adasat/alire.toml

  • alr --force --non-interactive pin adasat --use=/System/Volumes/Data/Ada_Source/ada_language_server-26.0.202412191/subprojects/adasat
    ⓘ Synchronizing workspace...
    error: Unexpected file in index: /System/Volumes/Data/Ada_Source/ada_language_server-26.0.202412191/index/.DS_Store`
    which seems ridiculous as when I look there is no .DS_Store there. Even if I rm it, I still get the error. This kept happening for a number of ada_language_server replacements including cloning!

@simonjwright
Copy link
Contributor

I hope this won’t be annoying, but ...

/System/Volumes/Data/ is part of Apple’s APFS filing system, normally you don’t see it, and it appears as /. So your /System/Volumes/Data/Ada_Source appears as /Ada_Source. This probably isn’t the problem, but you never know.

.DS_Store is a file that Finder puts into any directory it visits to store details of how the contents are presented. Finder doesn’t normally show dot-files (files whose name begins with a .). You can make it show them, and other hidden files, by shift-command-. (but even then it doesn’t show .DS_Store).

You could look for an alternative to Finder, but the simplest way is to only use Terminal (or Emacs :-) to examine source code.

You could get rid of all the .DS_Store files under a directory by e.g.

check that you’re looking at the right files

simon@ramoth Developer$ find alire -name .DS_Store
alire/.DS_Store
alire/testsuite/.DS_Store
alire/src/.DS_Store
alire/src/alr/.DS_Store

remove them

simon@ramoth Developer$ find alire -name .DS_Store | xargs rm

check they’re gone

simon@ramoth Developer$ find alire -name .DS_Store

Or we could write a tool (in Ada) to do just this job.

@rogermc2
Copy link
Author

rogermc2 commented Feb 5, 2025

Never annoying!
But I'm a bit baffled by your first comment.
I had thought /System/Volumes/Data/ is the directory in which all my personal work is and shows up as a disk icon on my desktop.
It certainly is never / which, as I understand it, is the root directory of the file system with desktop icon Macintosh HD.
HOWEVER, now that I check on both my Macs there is a desktop icon Data that is an alias for /System/Volumes/Macintosh HD.
I don't know what's going on!
I've just updated to Sequoia, maybe that's got something to do with it.
I've owned Macs since 1986. In my view things started going downhill with OSX 10. In the past few years things seem to have gotten worse and worse as if Apple is trying to drive people, particularlty developers, away from using Apple computers.
Sorry for such I tirade but I have been getting further and further disappointed by recent Mac OSX versions.
I don't think I'm a novice having been programming both professionally and, in retirement, as a hobbyist since 1969.
Your support for Ada development on Mac is greatly appreciated.

In conclusion, since I submitted this report, /System/Volumes/Data/ seems to have changed to /System/Volumes/Macintosh HD. At least in the Finder file directory systems of both my computers.

Further addendum
pwd
/System/Volumes/Data/Ada_Source/ada_language_server-26.0.202412191
but, according to Finder Info panel, its
System/Volumes/Macintosh HD/Ada_Source/ada_language_server-26.0.202412191

@rogermc2
Copy link
Author

rogermc2 commented Feb 5, 2025

I thought I'd have another go but ./scripts/build_als.sh
failed pretty quickly with:
case $STEP in

  • install_index
  • alr index --del=als
    error: Could not delete index directory
  • true
  • alr index --add=/System/Volumes/Data/Ada_Source/ada_language_server-26.0.202412191 --name=als
    error: Given name already in use by existing index

@eliericha
Copy link
Contributor

Hello folks,

I suspect that the error: Could not delete index directory you're seeing may be because you previously ran with sudo. The ALS build should not be run as sudo so make sure that your ALS checkout is in a User directory writable without elevated privileges. Anything under ~ or $HOME should do.

sudo is likely also the reason why the toolchain could no longer be found.

Then regarding indexes, up to about a month ago, the script was using a local Alire index to set up dependencies in a custom way. It no longer does that on master, so I would recommend switching to the master branch instead of 26.0.202412191. The master branch has a better version of the build script.

But you will have to remove previously registered indexes. You should be able to do that like this:

alr index # to list existing indexes
alr index --del=NAME  # for each index.
                      # You may need to use sudo if the index was registered with sudo before...
alr index --reset-community
alr index --update-all

Then to go back to the initial problem: the build script can't find python.

The fact that which python still mentioned an alias is suspicious. So I suggest running unalias python then which python to see python can be found straight from PATH and not through a shell alias.

Also I just realized that you used Homebrew to install Python.

Looking at the documentation of the Python package we see this:

❯ brew info python
==> [email protected]: stable 3.13.1 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
Installed
/opt/homebrew/Cellar/[email protected]/3.13.1 (3,343 files, 67.0MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-12-19 at 16:11:03
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/p/[email protected]
License: Python-2.0
==> Dependencies
Build: pkgconf ✘
Required: mpdecimal ✔, openssl@3 ✔, sqlite ✘, xz ✔
==> Caveats
Python is installed as
  /opt/homebrew/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, are installed into
  /opt/homebrew/opt/[email protected]/libexec/bin

See: https://docs.brew.sh/Homebrew-and-Python

The last part about Unversioned symlinks is the important one. You should add the given path to your PATH to obtain the unversioned python command that the build script needs.

@rogermc2
Copy link
Author

rogermc2 commented Feb 6, 2025

OK! Another attempt. As recommended, I cleaned up the alr indices then deleted the als directory, restarted the computer, cloned als from master, carefully followed the doc/build.md instructions.
Build failed as unable to find Ada compiler.
I suspect this due to me doing some embedded systems work using arm-eabi-gcc. Having both this and gcc-14.2.0-3-aarch64 in my Path maybe messing things up?
Running gprconfig seemed to fix the Ada compiler problem but:
`/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_wchar.h:215:18: note: 'FILE' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'

compilation of iconv_support.c failed

gprbuild: *** compilation phase failed
Build failed: error while running gprbuild -p -j8 -P/System/Volumes/Data/Ada_Source/ada_language_server/subprojects/langkit_support/lkt/./bootstrap/liblktlang.gpr -XBUILD_MODE=dev -XLIBRARY_TYPE=relocatable -XGPR_LIBRARY_TYPE=relocatable -XXMLADA_BUILD=relocatable -m -v -cargs:ada -gnateb:
Command '['gprbuild', '-p', '-j8', '-P/System/Volumes/Data/Ada_Source/ada_language_server/subprojects/langkit_support/lkt/./bootstrap/liblktlang.gpr', '-XBUILD_MODE=dev', '-XLIBRARY_TYPE=relocatable', '-XGPR_LIBRARY_TYPE=relocatable', '-XXMLADA_BUILD=relocatable', '-m', '-v', '-cargs:ada', '-gnateb']' returned non-zero exit status 4.
error: Command ["bash", "-x", "./scripts/build_als.sh", "build_langkit_raw"] exited with code 1
This preceded by many messages of the type:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_wchar.h:117:25: error: unknown type name 'FILE'
117 | wint_t ungetwc(wint_t, FILE *);
| ^~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_wchar.h:117:25: note: 'FILE' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'`!!!

@simonjwright
Copy link
Contributor

@rogermc2 - re: the C error messages - these happen because Xcode 16’s header files aren’t compatible with those expected by a compiler built against Xcode 15; see my note here.

You say you’re using my gcc-14.2.0-3-aarch64, which has a fix for this issue, so why the errors? I think you’ve probably set up alr toolchain to use gnat_native 14.2.1, which does not have this fix.

I’d recommend using alr toolchain --select to use option 2, None (also for gprbuild). This should pick up whatever compiler/gprbuild you have in your PATH.

@rogermc2
Copy link
Author

rogermc2 commented Feb 11, 2025

Yes, alr toolchain did show gnat_native 14.2.1 as default.
So I've done as you suggested.

alr settings --global --set (as advised by doc/build.md) now fails stating that --set requires two arguments so, with the help of alr help, I used alr settings --global False which caused a failure to find libgmp so then I tried True.

Then:

case $STEP in
+ build_langkit_raw
+ cd subprojects/langkit_support
+ echo GPR_PROJECT_PATH=........... (a huge list) followed by:
sed -i.bak -e s/GPR_BUILD/GPR_LIBRARY_TYPE/ ./langkit/libmanage.py
+ pip install .
./scripts/build_als.sh: line 162: /System/Volumes/Data/Ada_Source/ada_language_server/.venv/bin/pip: cannot execute: required file not found
error: Command ["bash", "-x", "./scripts/build_als.sh", "build_langkit_raw"] exited with code 127

I'm now on:
OSX 15.3.1
XCode 16.2 (16C5032a)

@simonjwright
Copy link
Contributor

I'm not sure this is really appropriate in @rogermc2's issue, but it doesn't seem right to open a new one just for this report.

Someone suggested running with the master branch, so I checked out e031e69. Building with GCC 14.2.0 I encountered the issue I raised over on langkit (I made a fix in build_als.sh by bracketing the manage.py call with set +e, set -e), but got a successful build. Running with both VS and ada-ts-mode, a formatting request results in

[ALS.MAIN] On_Server_Request
[ALS.MAIN] raised CONSTRAINT_ERROR : utils-command_lines.adb:699 access check failed
_ALS.MAIN_ Load address: 0x104E18000
_ALS.MAIN_ 0x109F0008C 0x109F00464 0x109F0003C 0x109F004E0 0x107A3DD40 0x107408024 0x107405F6C 0x107405D24 0x107530CB4 0x10585A134 0x10750B9C0 0x105846518 0x10580FBEC 0x105828840 0x1074C0E48 0x1074C1358 0x109EE9F60 0x18B8B1F90

The decode isn't helpful (no line numbers, I suspect because no -g in the build?)

Building with GCC 15.0.1 20250126 I got GCC PR 118731.

@eliericha
Copy link
Contributor

I think the issue with symbols is that build_als.sh builds in production mode. We would have to do some adaptation to support building in debug mode.

@eliericha
Copy link
Contributor

@rogermc2 I am sorry that we cannot be of more help. It seems that you are running into environment issues.

In my case, I am able to build locally on macOS 14.6.1, XCode 16.2 with a simplified version of build.md:

# Building Ada Language Server from sources

1. Install Alire, Python 3, NodeJS. Add them to `PATH`.

1. Clone repository

       git clone https://github.com/AdaCore/ada_language_server.git
       cd ada_language_server

1. If you know dependency commits numbers then create `deps.txt` file
   with lines `<repo_name>=commit`. Otherwise checkout `edge` branch.

1. Use `alr toolchain --select` to install the latest available versions of `gnat` and `gprbuild`.

1. Run `build_als.sh` script

       ./scripts/build_als.sh

(You can skip the third step about deps.txt since you're not doing a build with controlled dependencies)

@simonjwright
Copy link
Contributor

I think the issue with symbols is that build_als.sh builds in production mode. We would have to do some adaptation to support building in debug mode.

It was surprisingly easy.

  1. At Makefile:108, use alr build --profiles=%=development -- ...
  2. Then, before building, $ export RUNNER_OS=macOS - see strip_debug() in build_als.sh. RUNNER_OS will be defined in Github CI. Would it be better to check NODE_ARCH_PLATFORM for darwin?

Before I spotted the reason why my builds finished with references to objcopy (2 above), I was getting CONSTRAINT_ERROR : utils-command_lines.adb:680 access check failed errors when I tried to format a document. This has stopped (it could be the presence of the debug symbols? probably not)

@rogermc2
Copy link
Author

rogermc2 commented Feb 15, 2025

Thanks eliericha. I git pulled ada_language_server and otherwise followed your steps but still get error: Command ["bash", "-x", "./scripts/build_als.sh", "build_langkit_raw"] exited with code 127.
I also tried Simon's suggestion: added --profiles=%=development to Makefile:108 then before building, $ export RUNNER_OS=macOS, but same failure occurred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants