0
$\begingroup$

Rosanswers logo

colcon build --packages-select -build my package with this instruction.

trying to run a publisher node

ros2 run [package_name] talker

ERROR: package not found


Originally posted by rd112 on ROS Answers with karma: 41 on 2020-04-01

Post score: 4


Original comments

Comment by marguedas on 2020-04-01:
This is very limited information. How is composed your package? Is it a python or cmake package? Does it install an executable named talker ? if yes to what location ?

Please consider profiding more information and relevant bits of code like your CMakeLists or setup.py/cfg

Comment by jacobperron on 2020-04-01:
Did you source the setup file generated by the colcon build command? e.g. install/setup.bash

Comment by sabin on 2021-02-02:
Getting the same error, followed the tutorial step by step, using Python package on Windows. When I run ros2 run my_package my_node I get Package 'my_package' not found

Comment by sabin on 2021-02-02:
The issue was that I called install/local_setup.bat (as indicated in the tutorial). Calling '.\install\setup.ps1' fixies the issue.

Comment by fabbro on 2022-03-08:
Everytime you build a package, always remember to do (from your ROS2 workspace): source install/setup.bash and source /opt/ros/foxy/setup.bash

Comment by misty on 2022-04-04:
@fabbro, why do I need to source two setup.bash files? i.e., source install/setup.bash and source /opt/ros/foxy/setup.bash

$\endgroup$

3 Answers 3

0
$\begingroup$

Rosanswers logo

In my case I was running colcon build form inside the src directory in my workspace.
Like this:

~/ros2_ws/src$ colcon build 

Running colcon build in the workspace root solved the issue:

cd ~/ros2_ws
colcon build
source install/setup.bash

and finally

ros2 run [package_name] [executable_name] 

Originally posted by Roberto Z. with karma: 500 on 2022-07-05

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Carter12s on 2022-11-30:
This worked for me! Thank you for your answer.

Comment by Ricky23 on 2022-12-10:
I tried using this but it didnt work for me

$\endgroup$
1
$\begingroup$

We had a couple of instances where the package was not found despite properly sourcing the workspace, etc. Ultimately the reason was that the following lines were missing from the package.xml:

  <export>
    <build_type>ament_cmake</build_type>
  </export>

(for a pure python package you'd use ament_python of course). As with many things ROS2, the reasons elude common understanding...

$\endgroup$
0
$\begingroup$

Rosanswers logo

If you have your ros2 configuration sourced from your shell's rc file (example: source /opt/ros/<your version>/setup.bash in the .bashrc file when using bash), then you need to source the appropriate install script for your application:

When you open a new shell/terminal, source install/setup.bash for bash, etc.

If you do not have the line mentioned above in your rc file (for example, you prefer to control this manually), then you need to source both files.

(I find answers easier to digest than comments. All of this info is in the comments.)


Originally posted by randy with karma: 11 on 2022-06-30

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Micha Sende on 2023-03-03:
Opening a new terminal did the trick for me!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.