diff --git a/ros/src/foxglove_bridge/src/message_definition_cache.cpp b/ros/src/foxglove_bridge/src/message_definition_cache.cpp index 9c975f973..1869948ca 100644 --- a/ros/src/foxglove_bridge/src/message_definition_cache.cpp +++ b/ros/src/foxglove_bridge/src/message_definition_cache.cpp @@ -215,7 +215,12 @@ const MessageSpec& MessageDefinitionCache::load_message_spec( } // Get the package share directory, or throw a PackageNotFoundError - const std::string share_dir = ament_index_cpp::get_package_share_directory(package); + std::filesystem::path share_dir; + #if AMENT_INDEX_CPP_VERSION_GTE(1, 13, 0) + ament_index_cpp::get_package_share_directory(package, share_dir); + #else + share_dir = ament_index_cpp::get_package_share_directory(package); + #endif // Get the rosidl_interfaces index contents for this package std::string index_contents; @@ -234,7 +239,7 @@ const MessageSpec& MessageDefinitionCache::load_message_spec( } // Read the file - const std::string full_path = share_dir + std::filesystem::path::preferred_separator + *it; + const auto full_path = share_dir / *it; std::ifstream file{full_path}; if (!file.good()) { throw DefinitionNotFoundError(definition_identifier.package_resource_name);