question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ros2 pkg create: resource files not installed

See original GitHub issue

How have people been testing ros2 pkg create? I tried to run it but the templates aren’t installed so I get:

$ ros2 pkg create dummy_package --license asdf
going to create a new package
package name: dummy_package
destination directory: /tmp
package format: 2
version: 0.0.0
description: TODO: Package description
maintainer: ['dhood <dhood@users.noreply.github.com>']
licenses: ['asdf']
build type: ament_cmake
dependencies: []
creating folder ./dummy_package
Traceback (most recent call last):
  File "/home/dhood/ros2_ws/install_isolated/ros2cli/bin/ros2", line 11, in <module>
    load_entry_point('ros2cli==0.4.0', 'console_scripts', 'ros2')()
  File "/home/dhood/ros2_ws/install_isolated/ros2cli/lib/python3.5/site-packages/ros2cli/cli.py", line 69, in main
    rc = extension.main(parser=parser, args=args)
  File "/home/dhood/ros2_ws/install_isolated/ros2pkg/lib/python3.5/site-packages/ros2pkg/command/pkg.py", line 39, in main
    return extension.main(args=args)
  File "/home/dhood/ros2_ws/install_isolated/ros2pkg/lib/python3.5/site-packages/ros2pkg/verb/create.py", line 154, in main
    create_package_environment(package, args.destination_directory)
  File "/home/dhood/ros2_ws/install_isolated/ros2pkg/lib/python3.5/site-packages/ros2pkg/api/create.py", line 97, in create_package_environment
    package_xml_config)
  File "/home/dhood/ros2_ws/install_isolated/ros2pkg/lib/python3.5/site-packages/ros2pkg/api/create.py", line 71, in _create_template_file
    raise FileNotFoundError('template not found:', template_path)
FileNotFoundError: [Errno template not found:] /home/dhood/ros2_ws/install_isolated/ros2pkg/lib/python3.5/site-packages/ros2pkg/resource/package_environment/package.xml.em

Do I need to run it from a particular directory or anything? Or do we just need to install the resource files (I don’t see how they are being installed currently).

I am posing this as a question because it might be user error, given that I am the first one to run into it when it seems that others were testing it out in https://github.com/ros2/ros2cli/pull/42

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
dhoodcommented, Apr 3, 2018

I am happy to fix it, it shouldn’t be a big change, I just wanted to confirm that the fix was needed. I appreciate from the outside it seems like a strange question, but there are a number of setup.py tricks that I am still learning e.g. there are non-obvious installation commands like data_files that I may have overlooked, and in the past we’ve also added test commands that didn’t work unless you had particular python packages installed, so it was a genuine question that I had about if it was something I was missing.

I think that data_files is the appropriate approach for this so I will create a PR in that direction unless something else makes sense here.

0reactions
dhoodcommented, Apr 10, 2018

updating what resulted in https://github.com/ros2/ros2cli/pull/87 (including a new setup.py trick):

data_files will install to ~/ros2_ws/install_isolated/ros2pkg instead of, e.g., ~/ros2_ws/install_isolated/ros2pkg/lib/python3.5/site-packages/ros2pkg/, where the files were originally being looked for.

They can be installed to the site-packages path using the package_data setup.py option.

When they are installed that way, they can be accessed via pkg_resources.resource_filename('ros2pkg', 'resource/' + template_file_name) or similar. Something I learnt is that the input to that function is not a filestystem path, per say, and this page says: “Do not use os.path routines to manipulate resource paths, as they are not filesystem paths.” What will be returned by that function is a filesystem path, though it might be a path to a cache directory if the resources were installed in a compressed manner and so needed to be extracted first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a package — ROS 2 Documentation
1 Create a package · 2 Build a package · 3 Source the setup file · 4 Use the package · 5 Examine...
Read more >
Installing Packages — Industrial Training documentation
You may see an error (”ros2: command not found”). Remember that none of the ROS commands are visible until you've sourced the base...
Read more >
Create a ROS2 Python package - The Robotics Back-End
There is no hard rule about what to do, but some conventions make it easier for you. Let's see how to install launch...
Read more >
Tutorial : Installing gazebo_ros_pkgs (ROS 2) - Gazebo
You can install Gazebo either from source or from pre-build packages. ... setup file if you're having difficulty finding plugins and other resources....
Read more >
ros - ROS2 colcon build fails - can't copy: doesn't exist or not a ...
From the Python documentation: data_files specifies a sequence of (directory, files) pairs in the following way.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found