Skip to content

Use get_package_share_path just as python#112

Merged
ahcorde merged 6 commits intoament:rollingfrom
nobleo:get_package_share_path
Feb 25, 2026
Merged

Use get_package_share_path just as python#112
ahcorde merged 6 commits intoament:rollingfrom
nobleo:get_package_share_path

Conversation

@Timple
Copy link
Copy Markdown
Contributor

@Timple Timple commented Feb 19, 2026

cpp and python were going out of sync.

Besides

  auto dbc = ament_index_cpp::get_package_share_path("can_dbc_pkg") / "test" / "motohawk.dbc";

Looks much better than

  std::filesystem::path package_path;
  ament_index_cpp::get_package_share_directory("can_dbc_pkg", package_path);
  auto dbc = package_path / "test" / "motohawk.dbc";

Due to the short-livedness of the get_package_share_directory(..., std::filesystem::path) syntax, I didn't deprecated it.

I can finish this PR including the tests etc if that's appreciated. For now I wanted feedback first. 🙂

Signed-off-by: Tim Clephas <tim.clephas@nobleo.nl>
Signed-off-by: Tim Clephas <tim.clephas@nobleo.nl>
Signed-off-by: Tim Clephas <tim.clephas@nobleo.nl>
@Timple Timple force-pushed the get_package_share_path branch from 9781967 to a3b1568 Compare February 20, 2026 08:23
@jmachowinski
Copy link
Copy Markdown

I like the change. It's way cleaner than the previous version.

*/
AMENT_INDEX_CPP_PUBLIC
void
get_package_share_directory(const std::string & package_name, std::filesystem::path & path);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to update downstream packages

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How? Or to what?
Or do we (shortly) keep this function around for depreciation?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the API in question was added after kilted and therefore we can directly remove/replace it before the next release.
Removing this API will break all the tests etc that were already moved to the new API and need to be fixed.
E.g. if you check out the full rolling stack and remove the old API fix all compile failures resulting from this and do PRs for it.

Copy link
Copy Markdown
Contributor Author

@Timple Timple Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then merge simultaneously?

Then we would need someone with merge access to all these repos I guess?

Edit: or we can let everyone merge at their own pace I guess

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have permission to merge PRs across all the ROS 2 core.

We should deprecate the method instead of removing it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deprecated the previous implementation. So this can be merged and the other repositories will get a deprecation warning.

Signed-off-by: Tim Clephas <tim.clephas@nobleo.nl>
@ahcorde
Copy link
Copy Markdown
Contributor

ahcorde commented Feb 24, 2026

Pulls: #112, ros2/rmw_zenoh#913, ros2/rviz#1671, ros/resource_retriever#119, ros/ros_tutorials#193, ros-perception/image_common#391
Gist: https://gist.githubusercontent.com/ahcorde/4443a34cc7425a61b630b0ea7761d778/raw/ee918bf6abee19d2c84b4f3502bc35f27436183a/ros2.repos
BUILD args: --packages-above-and-dependencies ament_index_cpp
TEST args: --packages-above ament_index_cpp
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18300

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Copy link
Copy Markdown
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows is not compiling

  utest.cpp

utest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::filesystem::path __cdecl ament_index_cpp::get_package_share_path(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?get_package_share_path@ament_index_cpp@@YA?AVpath@filesystem@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@@Z) referenced in function "private: virtual void __cdecl AmentIndexCpp_get_package_share_path_Test::TestBody(void)" (?TestBody@AmentIndexCpp_get_package_share_path_Test@@EEAAXXZ) [C:\ci\ws\build\ament_index_cpp\ament_index_cpp_utest.vcxproj]

C:\ci\ws\build\ament_index_cpp\Release\ament_index_cpp_utest.exe : fatal error LNK1120: 1 unresolved externals [C:\ci\ws\build\ament_index_cpp\ament_index_cpp_utest.vcxproj]

Timple and others added 2 commits February 24, 2026 13:51
Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Signed-off-by: Tim Clephas <tim.clephas@nobleo.nl>
Signed-off-by: Tim Clephas <tim.clephas@nobleo.nl>
@Timple
Copy link
Copy Markdown
Contributor Author

Timple commented Feb 24, 2026

Windows is not compiling

  utest.cpp

utest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::filesystem::path __cdecl ament_index_cpp::get_package_share_path(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?get_package_share_path@ament_index_cpp@@YA?AVpath@filesystem@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@@Z) referenced in function "private: virtual void __cdecl AmentIndexCpp_get_package_share_path_Test::TestBody(void)" (?TestBody@AmentIndexCpp_get_package_share_path_Test@@EEAAXXZ) [C:\ci\ws\build\ament_index_cpp\ament_index_cpp_utest.vcxproj]

C:\ci\ws\build\ament_index_cpp\Release\ament_index_cpp_utest.exe : fatal error LNK1120: 1 unresolved externals [C:\ci\ws\build\ament_index_cpp\ament_index_cpp_utest.vcxproj]

Found a wrong include, I hope windows works now?

@ahcorde
Copy link
Copy Markdown
Contributor

ahcorde commented Feb 24, 2026

Pulls: #112, ros2/rmw_zenoh#913, ros2/rviz#1671, ros/resource_retriever#119, ros/ros_tutorials#193, ros-perception/image_common#391
Gist: https://gist.githubusercontent.com/ahcorde/fbb27b2127b62cdf0c2dea03ea0b3fec/raw/ee918bf6abee19d2c84b4f3502bc35f27436183a/ros2.repos
BUILD args: --packages-above-and-dependencies ament_index_cpp
TEST args: --packages-above ament_index_cpp
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18301

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@ahcorde ahcorde merged commit acfcac6 into ament:rolling Feb 25, 2026
3 checks passed
@nbbrooks
Copy link
Copy Markdown

nbbrooks commented Mar 15, 2026

Is there a source of truth somewhere for deprecations and deletions and their associated PRs? A docs.ros.org page? A ROS discourse post? When moveit2 rolling starts failing CI jobs around deprecations, it takes me a frustrating amount of time for me to find the particular GH organization and repo associated with that breakage to understand and fix it, whether that is something in rclcpp, ament, tf, etc.

I imagine if this existed/was more widely known, more package maintainers would mention the deprecation/deletion PR in their issue, which would make it easier for other package maintainers to do their migration.

nbbrooks added a commit to nbbrooks/moveit2 that referenced this pull request Mar 15, 2026
…and ament_index_cpp::get_package_share_directory(*, *) to ament_index_cpp::get_package_share_path(package_name) addressing ament/ament_index#112

Revert QT support changes which will be addressed in a separate PR

Temporarily add '-Wno-error=deprecated-declarations' to suppress other upstream deprecatios from short circuiting CI
@Timple
Copy link
Copy Markdown
Contributor Author

Timple commented Mar 15, 2026

Can this be backported to active distro's? Minus the deprecation message of course.

To prevent these kind of constructions for packages that use a single branch for all active distros: https://github.com/moveit/moveit2/pull/3705/changes#diff-c5eab2d24cfc0cc52d9d0fadc0596533f00ca45e3f8ea45a31bcd8c72b34fafaR40

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants