Skip to content

Use get_package_share_path just as python (backport #112) - #119

Closed
mergify[bot] wants to merge 1 commit into
humblefrom
mergify/bp/humble/pr-112
Closed

mergify[bot] wants to merge 1 commit into
humblefrom
mergify/bp/humble/pr-112

Conversation

@mergify

@mergify mergify Bot commented Apr 26, 2026

Copy link
Copy Markdown

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. 🙂


This is an automatic backport of pull request #112 done by Mergify.

Signed-off-by: Tim Clephas <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
(cherry picked from commit acfcac6)

# Conflicts:
#	ament_index_cpp/include/ament_index_cpp/get_package_share_directory.hpp
#	ament_index_cpp/src/get_package_share_directory.cpp
#	ament_index_cpp/test/utest.cpp
@mergify mergify Bot added the conflicts label Apr 26, 2026
@mergify

mergify Bot commented Apr 26, 2026

Copy link
Copy Markdown
Author

Cherry-pick of acfcac6 has failed:

On branch mergify/bp/humble/pr-112
Your branch is up to date with 'origin/humble'.

You are currently cherry-picking commit acfcac6.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   ament_index_cpp/CMakeLists.txt
	new file:   ament_index_cpp/include/ament_index_cpp/get_package_share_path.hpp
	new file:   ament_index_cpp/src/get_package_share_path.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   ament_index_cpp/include/ament_index_cpp/get_package_share_directory.hpp
	both modified:   ament_index_cpp/src/get_package_share_directory.cpp
	both modified:   ament_index_cpp/test/utest.cpp

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Comment on lines +31 to +34
<<<<<<< HEAD
=======
[[deprecated("Use get_package_share_path(...) instead")]]
>>>>>>> acfcac6 (Use get_package_share_path just as python (#112))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we shouldn't include this deprecation in this backport

Comment on lines +41 to +51
/// Return the share directory of the given package if found.
/**
* \param[in] package_name the name of the package to locate.
* \param[out] path share path of the package.
* \return
* \throws PackageNotFoundError when the given package is not found.
*/
[[deprecated("Use get_package_share_path(...) instead")]]
AMENT_INDEX_CPP_PUBLIC
void
get_package_share_directory(const std::string & package_name, std::filesystem::path & path);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess we should just remove this one

Comment on lines +34 to +38
void get_package_share_directory(
const std::string & package_name,
std::filesystem::path & path)
{
path = get_package_share_path(package_name);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove

@Timple

Timple commented May 13, 2026

Copy link
Copy Markdown
Contributor

Humble uses c++14 and thus no std::filesystem let's drop this PR.

@ahcorde ahcorde closed this May 13, 2026
@christophebedard

Copy link
Copy Markdown
Member

Makes sense.

@christophebedard
christophebedard deleted the mergify/bp/humble/pr-112 branch May 13, 2026 19:28
@mathias-luedtke

Copy link
Copy Markdown

@Timple, @christophebedard:

Humble targets c++17
(see https://docs.ros.org/en/humble/The-ROS2-Project/Contributing/Code-Style-Language-Versions.html#id2)
And since get_package_share_directory got now removed from rolling, I would really like to have this backported..

@Timple

Timple commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Appologies! I was mistaken.

Feel free to open a PR!

And since get_package_share_directory got now removed from rolling

That's a bummer. I prefer they only remove these things once all active distros are suppored. :/

@mathias-luedtke

Copy link
Copy Markdown

Feel free to open a PR!

It looks like #111 is needed first..

@christophebedard
christophebedard restored the mergify/bp/humble/pr-112 branch September 5, 2026 23:42
@mergify

mergify Bot commented Sep 5, 2026

Copy link
Copy Markdown
Author

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@christophebedard

christophebedard commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

so it seems like some of the core packages still default to C++14 (in Humble), including ament_index_cpp: #111 (comment)

At this point I think it might be too late to make the change even if we point to C++17 being the "minimum" in multiple places.

@Timple

Timple commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Perhaps we need to keep the previous syntax around in rolling until humble is deprecated?

@christophebedard

christophebedard commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

Alright, so I've looked into it and had a short discussion on Zulip. While we do declare that Humble targets C++17, that's unfortunately not completely true in practice. Some Humble core packages default to C++14, some default to C++17 (like rclcpp). They were all properly bumped to C++17 in Jazzy.

Given that we have rules regarding breaking changes for active distros, and since including <filesystem> might break downstream users that target C++14 (however improbable that might be), I don't think we should merge #119 / #111.

We could avoid using <filesystem> in headers and use std::string, but I don't think it's worth it. And I understand the multi-distro build use-case (which still wouldn't work if we used std::string in Humble), but unfortunately I don't think it's worth changing/reverting the removal in Rolling. Intentionally trying to keep multi-distro builds working increases the maintenance burden; we just have to keep moving forward,. And you should have everything you need to #ifdef based on the ROS distro or ament_index_cpp version.

Sorry this isn't quite ideal. And sorry for giving you hope and then crushing it 😅

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants