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

Update/Add Ninja #741

Closed
3 of 5 tasks
compnerd opened this issue Apr 19, 2020 · 26 comments
Closed
3 of 5 tasks

Update/Add Ninja #741

compnerd opened this issue Apr 19, 2020 · 26 comments

Comments

@compnerd
Copy link

compnerd commented Apr 19, 2020

Tool information

  • Tool name: Ninja
  • Add or update? Add
  • Desired version: latest
  • Approximate size:
  • If this is an add request:

Area for Triage:
Packages

Question, Bug, or Feature?:
Feature

Virtual environments affected

  • macOS 10.15
  • Ubuntu 16.04 LTS
  • Ubuntu 18.04 LTS
  • Windows Server 2016 R2
  • Windows Server 2019

Can this tool be installed during the build?
Yes, the install is bound by download time (usually ~1m)

Are you willing to submit a PR?
Yes

@compnerd
Copy link
Author

The ninja tool is already included in the Windows hosts via Visual Studio. It would be nice to include it on the macOS and Ubuntu VMs. For Ubuntu, apt-get install -y ninja-build is sufficient.

@miketimofeev
Copy link
Contributor

Hi @compnerd! As I know ninja is installed along with vcpkg, here is the vcpkg installation log:

    azure-arm: Downloading ninja...
==> azure-arm:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
==> azure-arm:                                  Dload  Upload   Total   Spent    Left  Speed
==> azure-arm: 100   624  100   624    0     0   2034      0 --:--:-- --:--:-- --:--:--  2039
==> azure-arm: 100 99857  100 99857    0     0  99025      0  0:00:01  0:00:01 --:--:--  322k
    azure-arm: Downloading ninja... done.
    azure-arm: Extracting ninja...
    azure-arm: Extracting ninja... done.

I wonder if it could be used for your purposes?

@compnerd
Copy link
Author

@miketimofeev interesting, ninja is definitely not found on the Linux builders (on Azure). I thought that the Azure and GitHub actions were merged into a single repository.

CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
See also "/home/vsts/work/1/b/.../CMakeFiles/CMakeOutput.log".

compnerd added a commit to compnerd/virtual-environments that referenced this issue Apr 19, 2020
Add ninja-build to the Linux images.  It is already present on the
Windows builders and is very often used with CMake.

Issue: actions#741
@miketimofeev
Copy link
Contributor

@compnerd Unfortunately, I'm not so familiar with CMake builds, but is it possible to use vcpkg for them?
https://github.com/microsoft/vcpkg/blob/master/docs/maintainers/vcpkg_configure_cmake.md

@compnerd
Copy link
Author

compnerd commented Apr 19, 2020

@miketimofeev no, it is not possible to use vcpkg for building for my purposes. I need to be able to use ninja directly through CMake as that is the only way that you can build Swift packages with CMake. The projects only support CMake, and supporting vcpkg is not viable as adding yet another build system to projects is not likely to be accepted.

@compnerd
Copy link
Author

@miketimofeev actually, thinking more about this - isn't this actually better? Adding ninja to the base image allows CMake to use it and vcpkg could use the host provided ninja builder as well.

@miketimofeev
Copy link
Contributor

Oh, I see. Can that ninja from vcpkg be used directly from /usr/local/share/vcpkg/downloads/tools/ninja-1.10.0-linux/ninja?
We try to avoid tools duplicating, that's why I'm trying to find any possible ways.

@compnerd
Copy link
Author

compnerd commented Apr 19, 2020

Hardcoding random paths doesn't work very well for the azure pipelines if you are using different builders. Can you not use ninja from /usr/bin/ninja instead of /usr/local/share/vcpkg/downloads/tools/ninja-1.10.0-linux/ninja?

Alternatively, you could symlink the path from /usr/bin/ninja.

@miketimofeev
Copy link
Contributor

If this path works /usr/local/share/vcpkg/downloads/tools/ninja-1.10.0-linux/ninja then we can simply add a symlink

@compnerd
Copy link
Author

Where the tool resides is not a big deal, if ninja can be added to the path for all the builders, that is perfectly acceptable (though beyond my ability to help with).

@miketimofeev
Copy link
Contributor

Can you confirm that
sudo ln -s /usr/local/share/vcpkg/downloads/tools/ninja-1.10.0-linux/ninja /usr/local/bin/ninja solves your task?
If yes – we'll consider making the symlink during the vcpkg installation

@compnerd
Copy link
Author

@miketimofeev nope, that still fails. I can verify that sudo apt-get install ninja-build does fix it though.

@compnerd
Copy link
Author

@miketimofeev also can verify that sudo ln -s /usr/local/share/vcpkg/downloads/tools/ninja-1.10.0-linux/ninja /usr/bin/ninja fails. Its not a PATH issue AFAICT.

@Darleev
Copy link
Contributor

Darleev commented Apr 20, 2020

Hi @compnerd . We had very similar request for ninja tool. Unfortunately, we can't add it at the moment. I would like to suggest you to install ninja tool in runtime using the following steps:

# macOS
brew install ninja

# Ubuntu
sudo apt-get install ninja-build

So, currently, it's easy to install ninja in runtime on demand, since installation takes about 10 seconds and there are no issues with it.
If additional assistance or information is required, please do not hesitate to contact us.

@abique
Copy link

abique commented Dec 28, 2021

Hi @compnerd . We had very similar request for ninja tool. Unfortunately, we can't add it at the moment. I would like to suggest you to install ninja tool in runtime using the following steps:

# macOS
brew install ninja

# Ubuntu
sudo apt-get install ninja-build

So, currently, it's easy to install ninja in runtime on demand, since installation takes about 10 seconds and there are no issues with it. If additional assistance or information is required, please do not hesitate to contact us.

it is on windows that it is difficult to install ninja

@al-cheb
Copy link
Contributor

al-cheb commented Dec 28, 2021

it is on windows that it is difficult to install ninja

@abique , You can use choco to install ninja tool on Windows.

- run: |
        choco install ninja
        ninja.exe --version

E.g.:
image

dlam added a commit to dlam/androidx that referenced this issue Jan 27, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 27, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 27, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 27, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 27, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 27, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 27, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 27, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 27, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 27, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 28, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 28, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 28, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 28, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
dlam added a commit to dlam/androidx that referenced this issue Jan 28, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

Fixes: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5
copybara-service bot pushed a commit to androidx/androidx that referenced this issue Jan 28, 2022
It is required to install ninja manually due to it not being included in
the virtual env provided by Github Actions runner.

See actions/runner-images#741

In order for Ninja to be visible to CMake during NDK builds, it must be
installed in the same subdirectory, so for now it is symlinked on Linux
builds. See b/206099937

This doesn't fully fix work-inspection due to missing the dexter/slicer import.

Bug: 216535050
Test: Github CI
Change-Id: I1a741b1765822f0004adc3985b7babc8022046a5

This is an imported pull request from #315.

Resolves #315
Github-Pr-Head-Sha: 26c4156
GitOrigin-RevId: 63fff83
Change-Id: Id4b017d8748ce797beef76e5068211f6c31a492c
@jpr42
Copy link

jpr42 commented Mar 2, 2023

FWIW to CMake/Ninja users get-cmake has been amazing at work for grabbing the exact version of CMake/Ninja you want. It also implements GitHub caching 👍🏽 so you don't have to worry about sporadic network failures.

@marc-hb
Copy link

marc-hb commented Sep 22, 2023

The ninja tool is already included in the Windows hosts via Visual Studio.

it is on windows that it is difficult to install ninja

I'm confused: is it available by default on Windows Server or not?

ninja just started randomly disappearing on Windows:

@marc-hb
Copy link

marc-hb commented Sep 22, 2023

Looks like ninja was dropped from Windows image 20230918.1.

Either dropped or it's not in the PATH anymore.

@jhasse
Copy link

jhasse commented Oct 6, 2023

You can get it back on the path by adding https://github.com/marketplace/actions/enable-developer-command-prompt before calling CMake.

@marc-hb
Copy link

marc-hb commented Oct 6, 2023

This enable-developer-command-prompt action looks great but unfortunately we use shell: msys2 {0} so I'm not optimistic enough to try it :-(

@marc-hb
Copy link

marc-hb commented Oct 25, 2023

Gosh this really annoying:

  • 20230910.1 ninja found
  • 20230918.1 not found
  • 20231016.1.0 ninja found
  • 20231023.1.0 not found

To confuse users even more, the same run gets a mix of versions with some builds passing and others not. Who's having fun with this back and forth?

You can use choco to install ninja tool on Windows.

BTW this worked for us, thanks! Now we just need to use it on all our branches.

@marc-hb
Copy link

marc-hb commented Jan 29, 2024

We had very similar request #514 for ninja tool. Unfortunately, we can't add it at the moment.

I just pleaded for #514 to be re-opened and reconsidered:

@dofuuz
Copy link

dofuuz commented Dec 19, 2024

For now, using seanmiddleditch/gha-setup-ninja is fast and easy cross-platform way to use ninja.

    - uses: seanmiddleditch/gha-setup-ninja@v5

It takes ~1sec to setup ninja.

@marc-hb
Copy link

marc-hb commented Dec 19, 2024

This looks great but security-conscious projects should not have to all perform duplicate audits of some 3rd party action for a build tool as fundamental as ninja.

@marc-hb
Copy link

marc-hb commented Dec 22, 2024

thanks for your suggestion but considering that it' easy to add Ninja to workflows on demand,...

I just asked runtime installation to be officially documented, please upvote:

Ever growing list of duplicates gathered at:

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

No branches or pull requests

9 participants