ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Unable to install because of missing ninja

asked 2016-09-21 21:44:03 -0600

Cerin gravatar image

updated 2016-09-21 22:23:55 -0600

I'm trying to install the diagnostics module from source into my existing Kinetic source installation.

To do this, I'm running:

cd /home/pi/ros_catkin_ws;
rosinstall_generator diagnostics --rosdistro kinetic --deps | wstool merge -t src -
wstool update -t src -j2 --delete-changed-uris
rosdep install --from-paths src --ignore-src --rosdistro kinetic -y -r --os=debian:jessie
./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic -j1

It's failing when trying to install the dependency Opencv3, with the error:

-- Build files have been written to: /home/pi/ros_catkin_ws/build_isolated/opencv3/install
==> ninja -j1 in '/home/pi/ros_catkin_ws/build_isolated/opencv3/install'
/opt/ros/kinetic/env.sh: 16: exec: ninja: not found
<== Failed to process package 'opencv3': 
  Command '['/opt/ros/kinetic/env.sh', 'ninja', '-j1']' returned non-zero exit status 127

Reproduce this error by running:
==> cd /home/pi/ros_catkin_ws/build_isolated/opencv3 && /opt/ros/kinetic/env.sh ninja -j1

Command failed, exiting.

What "ninja" program is it referring to, and why wasn't this auto-installed by rosdep? There appears to be both an apt package and pip package called "ninja", which do very different things, so it's unclear which one it's expecting.

Edit: I'm assuming it's referring to the ninja build system? I tried installing the ninja-build package, and re-running the build process, but that reports a different but similar ninja error:

==> Processing plain cmake package: 'opencv3'
==> Building with env: '/opt/ros/kinetic/env.sh'
Makefile exists, skipping explicit cmake invocation...
==> make cmake_check_build_system in '/home/pi/ros_catkin_ws/build_isolated/opencv3/install'
==> ninja -j1 in '/home/pi/ros_catkin_ws/build_isolated/opencv3/install'
ninja: error: loading 'build.ninja': No such file or directory
<== Failed to process package 'opencv3': 
  Command '['/opt/ros/kinetic/env.sh', 'ninja', '-j1']' returned non-zero exit status 1

Reproduce this error by running:
==> cd /home/pi/ros_catkin_ws/build_isolated/opencv3 && /opt/ros/kinetic/env.sh ninja -j1

How do I fix this?

edit retag flag offensive close merge delete

Comments

Somehow CMake is generating build files for ninja (the build tool, not the python library), which is definitely not standard.

As opencv3 is a "plain cmake" package, it might be doing some strange things. Perhaps OpenCV3's build files are hard-coding a generator?

gvdhoorn gravatar image gvdhoorn  ( 2016-09-22 02:15:46 -0600 )edit

CMake should also output the generator it is using for your build scripts. Can you find that anywhere in the output?

gvdhoorn gravatar image gvdhoorn  ( 2016-09-22 03:18:21 -0600 )edit

@gvdhoorn, What is the generator called? What am I looking for?

Cerin gravatar image Cerin  ( 2016-09-22 11:13:21 -0600 )edit

The generator is called ninja. See cmake-generators(7) and What is a CMake generator? for some discussion on generators.

gvdhoorn gravatar image gvdhoorn  ( 2016-09-22 12:23:41 -0600 )edit

But more interesting would be to understand why CMake chose the ninja generator in the first place: did this ever happen before? Can you successfully use rosinstall_generator to build other pkgs?

gvdhoorn gravatar image gvdhoorn  ( 2016-09-22 12:24:39 -0600 )edit

I still don't understand. Like I said in my question, it's outputting ninja, so I'm not sure why you're telling me to look for it. The problem is the ninja build script isn't being generated, so ninja is throwing an error. And yes, the first command I ran was rosinstall_generator.

Cerin gravatar image Cerin  ( 2016-09-22 13:15:17 -0600 )edit
1

Nowhere in ROS is the CMake generator being configured. Afaik, all catkin driven CMake activity uses the GNU Makefile generator. Something in your setup is forcing CMake to use the ninja generator. That is something to figure out. Who or what is making CMake use the ninja generator.

gvdhoorn gravatar image gvdhoorn  ( 2016-09-22 13:30:49 -0600 )edit
1

As to the output I'm asking for: CMake uses its generators at configuration time, not build time. I'm asking whether you see any output during initial configuration that states that CMake is using its ninja generator. Lines regarding that should appear before the lines you've copy/pasted.

gvdhoorn gravatar image gvdhoorn  ( 2016-09-22 13:32:17 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-09-24 22:32:55 -0600

jb gravatar image

In src/catkin/python/catkin/builder.py line 532, make the following change:

@@ -527,11 +527,11 @@
         run_command_colorized(
             make_check_cmake_cmd, build_dir, quiet
         )

     # Run make
-    if not use_ninja:
+    if use_ninja:
         make_executable = 'ninja'
     elif use_nmake:
         make_executable = 'nmake'
     else:
         make_executable = 'make'
edit flag offensive delete link more

Comments

@Cerin: this could indeed be the cause of Catkin using the ninja generator. What I haven't figured out yet is why it only tries to do that with OpenCV3, but it's a bug in any case.

gvdhoorn gravatar image gvdhoorn  ( 2016-09-25 05:03:43 -0600 )edit
1

The bug only affected plain CMake packages. This is being addressed by https://github.com/ros/catkin/pull/827

Dirk Thomas gravatar image Dirk Thomas  ( 2016-09-25 09:59:08 -0600 )edit

Thx @dirk-thomas !

Vincent Rabaud gravatar image Vincent Rabaud  ( 2016-09-25 13:56:31 -0600 )edit

Great find. Thank you.

Cerin gravatar image Cerin  ( 2016-09-25 20:27:21 -0600 )edit
0

answered 2021-11-17 16:42:17 -0600

davidf gravatar image

This also affected me, but I already had VS2019 installed with the tools, so that wasn't a solution for me. I probably have something else installed that screwed up cmake..

FWIW, My version of builder.py (in C:\opt\ros\noetic\x64\Lib\site-packages\catkin\builder.py) also had some switches, and I was able to successfully run catkin with the flag --with-nmake to get it to use NMake instead.. The relevant bit was at builder.py:954 but didn't get exposed as an error for me since it was just erroneously using Ninja..

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-09-21 21:44:03 -0600

Seen: 3,360 times

Last updated: Sep 24 '16