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

Meson is unable to find ninja (ERROR: Could not detect Ninja) #10987

Open
anjalirai-intel opened this issue Nov 3, 2022 · 13 comments
Open

Meson is unable to find ninja (ERROR: Could not detect Ninja) #10987

anjalirai-intel opened this issue Nov 3, 2022 · 13 comments

Comments

@anjalirai-intel
Copy link

ERROR: Could not detect Ninja
I am trying to setup Ubuntu 22.04 for our project.

These are the versions I have in baremetal and it seems to be working fine

Found ninja-1.10.1 at /usr/bin/ninja
$ meson --version
0.63.3
$ ninja --version
1.10.1
$ cat /etc/os-release | grep VERSION
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy

But when i try to replicate the same on Docker environment, I get build errors from meson

ERROR: Could not detect Ninja v1.8.2 or newer

$ meson --version
0.63.3
$ ninja --version
1.10.1

I searched about this error and it has been suggested to try installing ninja with pip3 and it should work. But i tried that and still got the same error

ERROR: Could not detect Ninja v1.8.2 or newer

$ meson --version
0.63.3
$ ninja --version
1.10.2.git.kitware.jobserver-1

So, I installed meson version 0.56.2 and ninja version 1.10.1, but when you run meson command, it ends up in error ERROR: Could not detect Ninja v1.7 or newer

To Reproduce
meson.build

  1. Create a docker image using this dockerfile Dockerfile
  2. Start the docker container, you should be in gramine directory
  3. Run this command meson setup build/ --werror --buildtype=release -Dskeleton=enabled -Ddirect=enabled -Dsgx=disabled -Dtests=enabled

Expected behavior
Build should be successful and in the end we should get Found ninja-1.10.1 at /usr/bin/ninja

system parameters
It is a plain native build
Python Version: 3.10.6
OS: Ubuntu 22.04
Meson Version: 0.56.2
Ninja Version: 1.10.1

@anjalirai-intel
Copy link
Author

I have put debugger inside mesonbuild/environment.py. It is able to find ninja, but it throws Permissin error, even though i have set all the permissions and i am able to execute the command from terminal

/usr/local/lib/python3.10/dist-packages/mesonbuild/environment.py(186)detect_ninja_command_and_version()
-> env_ninja = os.environ.get('NINJA', None)
(Pdb) n
> /usr/local/lib/python3.10/dist-packages/mesonbuild/environment.py(187)detect_ninja_command_and_version()
-> for n in [env_ninja] if env_ninja else ['ninja', 'ninja-build', 'samu']:
(Pdb) n
> /usr/local/lib/python3.10/dist-packages/mesonbuild/environment.py(188)detect_ninja_command_and_version()
-> prog = ExternalProgram(n, silent=True)
(Pdb) n
> /usr/local/lib/python3.10/dist-packages/mesonbuild/environment.py(189)detect_ninja_command_and_version()
-> if not prog.found():
(Pdb) n
> /usr/local/lib/python3.10/dist-packages/mesonbuild/environment.py(191)detect_ninja_command_and_version()
-> try:
(Pdb) n
> /usr/local/lib/python3.10/dist-packages/mesonbuild/environment.py(192)detect_ninja_command_and_version()
-> p, found = Popen_safe(prog.command + ['--version'])[0:2]
(Pdb) prog.command
['/usr/bin/ninja']
(Pdb) n
PermissionError: [Errno 1] Operation not permitted: '/usr/bin/ninja'
> /usr/local/lib/python3.10/dist-packages/mesonbuild/environment.py(192)detect_ninja_command_and_version()
-> p, found = Popen_safe(prog.command + ['--version'])[0:2]
(Pdb) c

ERROR: Could not detect Ninja v1.7 or newer

intel@109b68536923:/home/intel/anjali/gramine$ /usr/bin/ninja --version
1.10.1

ls -al /usr/bin/ninja
-rwxrwxrwx 1 root root 248056 Aug 30  2020 /usr/bin/ninja

@tristan957
Copy link
Contributor

Might be useful to make sure the ninja Meson detects is what you think it is.

@lazka
Copy link
Contributor

lazka commented Nov 5, 2022

See scikit-build/ninja-python-distributions#157, which seems related

@henryiii
Copy link
Contributor

henryiii commented Nov 5, 2022

This is only an issue with the latest release a few hours ago, older ones were fine.

@eli-schwartz
Copy link
Member

This also seems to be happening in a docker container that is supposed to pick up a Ubuntu-packaged version of upstream unpatched ninja, not the scikit-build patchset. So yeah, that other issue is certainly unrelated.

@eli-schwartz
Copy link
Member

I have put debugger inside mesonbuild/environment.py. It is able to find ninja, but it throws Permissin error, even though i have set all the permissions and i am able to execute the command from terminal

So the only thing that meson is doing differently basically seems to be "run it from python", very confusing...

If you start up a python console in the affected machine, does this work?

>>> import subprocess
>>> subprocess.run(['ninja', '--version'], capture_output=True)

And:

>>> from mesonbuild.mesonlib import Popen_safe
>>> Popen_safe(['ninja', '--version'])

@henryiii
Copy link
Contributor

henryiii commented Nov 6, 2022

I think I'll have a patch out for the 1.11.1 issue soon. Looks like ninja 1.11.1 isn't compatible with manylinux1. Though why is it passing tests? Anyway, manylinux2010 builds don't suffer the same problem, and I can upload 2010 builds to the same release. ;)

@henryiii
Copy link
Contributor

henryiii commented Nov 6, 2022

This is fixed, I believe. (edit: our problem was fixed, not this one!) manylinux2010 images are working elsewhere. The manylinux1 images might get removed at some point, but they actually do work on manylinux1 I believe (since cibuildwheel's tests passed). I've also been able to reproduce the failure and the fix in CI tests. The 1.11.1 releases is okay now.

@eli-schwartz
Copy link
Member

eli-schwartz commented Nov 6, 2022

Nah, still not fixed, because the original reporter wasn't using a pip installed ninja, but was using the Ubuntu packaged version without the kitware.jobserver-1 patch. ;)

It was then erroneously diagnosed as "this scikit-build/ninja-python-distributions issue looks related".

@henryiii
Copy link
Contributor

henryiii commented Nov 6, 2022

Oops, sorry, was replying to all the issues, forget this one wasn't our problem. :D

@CJJLUX
Copy link

CJJLUX commented Jun 1, 2023

I had the same problem,Because of the “.git.kitware.jobserver-1” suffix

problem:
[root@d6b309491377 data]# /usr/bin/ninja --version
1.10.2

[root@d6b309491377 data]# ninja --version
1.11.1.git.kitware.jobserver-1

[root@d6b309491377 data]# which ninja
/usr/local/bin/ninja

solve:
cp /usr/bin/ninja /usr/local/bin/ninja

[root@d6b309491377 data]# ninja --version
1.10.2

@xclaesse
Copy link
Member

xclaesse commented Jun 1, 2023

What docker image can be used to reproduce?

@xhy2008
Copy link

xhy2008 commented Jan 23, 2024

On termux,it produces the same problem.

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

No branches or pull requests

8 participants