Skip to content

colcon builds fail when symlinked files were deleted #692

@b-adkins

Description

@b-adkins

User story

I work at an early-stage robotics startup using ROS 2. Because we are early-stage, there is not a lot of filename stability. I often find myself developing a feature off a new copy of dev, then switching to an older branch, then back again. In between those two branches, files have been deleted or renamed, often in unrelated packages.

This causes the build to fail. When it could be automatically resolved in an instant. Which it is, for C++ files.

Expected behavior

The build Just Works. In my symlink install workspace, after some symlinked files are deleted from a package, e.g. (robot_name)_behavior_trees, the build system deletes the symbolic link from the install folder.

Aka it works like C++ files do with CMake - removed files don't matter, it Just Builds.

Actual behavior

The build fails. With an error like

Installed /home/b-adkins/ros2_ws/build/my_robot_description
running symlink_data
error: can't copy '/home/boone/ros2_ws/build/my_robot_description/rviz/my_robot.rviz': doesn't exist or not a regular file
--- stderr: my_robot_description
error: can't copy '/home/boone/ros2_ws/build/my_robot_description/rviz/my_robot.rviz': doesn't exist or not a regular file
---
Failed   <<< my_robot_description [0.91s, exited with code 1]

Suggested workaround

Clean up the broken symlinks and rebuild. The commands to do so are pretty involved, so I recommend a custom script.

One of the two:

  1. Clean the whole package. The clean and build commands run in an eyeblink for config-only or Python-only packages. There has been a refusal to add an official colcon clean verb. This addition works, but the command is verbose and annoying enough that I have aliased a clean of the quick-to-build problem packages, with a command like
     colcon clean packages --packages-select my_robot_launch my_robot_behavior_trees my_robot_moveit_config
    
  2. Surgically delete the bad symlinks. This saves rebuilding a huge C++ library just to delete one config file. I have found it fastest to delete the whole config directory
    rm -r install/my_package/share/my_package/(config_dir)
    

Also, use --continue-on-error in your standard colcon build command, so at least the huge C++ library compiles while you're getting coffee.

Suggested fix

If a symlink in the install/(package)/share directory has no corresponding file in the package, delete it. Or, clean all symlinks in the install/(package)share directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions