I got Substitution failure error

I’m trying to launch the launch.py file.
I completely build the package but I got the message of substitution failure while launching the file.

user:~/ros2_ws$ ros2 launch logs_test logger_example_launch_file.launch.py
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2022-02-09-08-56-54-711452-3_xterm-9647
[INFO] [launch]: Default logging verbosity is set to INFO
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:271> exception=SubstitutionFailure("package 'logs_test' found at '/home/user/ros2_ws/install/logs_test', but libexec directory '/home/user/ros2_ws/install/logs_test/lib/logs_test' does not exist")>
Traceback (most recent call last):
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 273, in _process_one_event
    await self.__process_event(next_event)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 293, in __process_event
    visit_all_entities_and_collect_futures(entity, self.__context))
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  [Previous line repeated 1 more time]
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
    sub_entities = entity.visit(context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/action.py", line 108, in visit
    return self.execute(context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/actions/node.py", line 442, in execute
    ret = super().execute(context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/execute_process.py", line 775, in execute
    self.__expand_substitutions(context)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/execute_process.py", line 635, in __expand_substitutions
    cmd = [perform_substitutions(context, x) for x in self.__cmd]
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/execute_process.py", line 635, in <listcomp>
    cmd = [perform_substitutions(context, x) for x in self.__cmd]
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in perform_substitutions
    return ''.join([context.perform_substitution(sub) for sub in subs])
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in <listcomp>
    return ''.join([context.perform_substitution(sub) for sub in subs])
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_context.py", line 184, in perform_substitution
    return substitution.perform(self)
  File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/substitutions/executable_in_package.py", line 79, in perform
    raise SubstitutionFailure(
launch.substitutions.substitution_failure.SubstitutionFailure: package 'logs_test' found at '/home/user/ros2_ws/install/logs_test', but libexec directory '/home/user/ros2_ws/install/logs_test/lib/logs_test' does not exist

Hi @rlawlgnsdlae, welcome to the community!

I need more information in order to be able to help you. What course/unit/exercise are you working on?
Have you completed all of the necessary steps in order to compile the package your launch file is in?

Yes, I’m taking the ROS2 Basics in 5 days (python) / Unit 6 : ROS2 Debugging Tools / Exercise 6.1

I follow the following steps to compile the package and launching the file.

  • Create a new package named logs_test. When creating the package, add rclpy as dependencies.
  • Inside the src folder of the package, create a new file named logger_example.py. Inside this file, copy the contents of logger_example.py
  • Create a launch file for launching this code.
  • Do the necessary modifications to your setup.py file, and compile the package.
  • Execute the launch file to run your executable.

But, I got a problem after colcon build command the logs_test directory is not created in the /install/logs_test/lib.

Does the compilation generate errors?

If so, you can remove the /build and /devel folders and try compiling again:

cd ~/ros2_ws
rm -rf /build /install
colcon build

One thing you can do to identify if it’s the .launch.py file is running the node with ros2 run instead of ros2 launch. If it turns out it can run as a node, then you probably did not make all the modifications to your package.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.