ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# Moving packages to different directory

Hi all,

I was working on a package in a folder (~/workspace/Mypackage) the package was originally at this place when i came. I work on it and now that is ready I want to move it to (~/svn/stacks/Mypackage) this in order to update the svn repository with my modifications.

I copy the entire folder, delete the CMakeCache.txt ("find -name CMakeCache.txt -delete") in this folder. Update the address of myPackage at .bashrc, then i do rosmake and it didn't complain. I run my package and it works fine. But this happen while mi original package is also in the original place, i mean, while i have the 2 copies of my package (one in svn folder and the other in workspace folder) all work fine, i can run it without problems (if i do "roscd myPackage" it gets me to the package at svn folder and if i do "env | grep ROS" it returns

ROS_ROOT=/opt/ros/diamondback/ros
ROS_PACKAGE_PATH=/home/jose/svn/stacks:/opt/ros/diamondback/stacks
ROS_MASTER_URI=http://localhost:11311


So ROS only know the package at svn folder...

When i delete the original package (the one at workspace) and then re-run my package it fails. If i rebuild it, it say that it dind't find some files (at the build folder in workspace location)

How i should do the transition between my packages? and why it complain for some files (the folders are exactly the same) how i should rebuild in order to generate all the files needed in the new location?

UPDATE: The error that return the package when i move it to a different location is that it doesn't find the files included "No such file or directory" Thanks

edit retag close merge delete

Under {{{myPackage/}}}, where are your header files? Do you have an {{{include_directories()}}} in CMakeLists.txt?
( 2011-09-27 02:15:07 -0600 )edit

Sort by » oldest newest most voted

Try

$rm -rf CMakeCache.txt CMakeFiles cmake_install.cmake msg_gen srv_gen src/myPackage$ cmake .
\$ rosmake


That has worked for me a bunch of times when doing exactly what you are trying to do. Basically, try to remove all auto-generated files and then build again.

more

I also do that and it usually worked... but this time it don't... I remove the auto-generated files, did a cmake . and then a rosmake and is the same. If i do it with the original package in his place all work fine, if i delete or change the name of the original package it return compilation error
( 2011-09-27 02:29:39 -0600 )edit
The errors are basically that it didn't file included files... And if i compile my package with the original in his place (when all work fine) and then rename/delete the original and try to run the new one it fails. I really don't know what is happening...
( 2011-09-27 02:32:27 -0600 )edit

I know this is an old post but I just had this issue myself, and this was the first response that came up on Google, so for anyone else who has this issue the easy solution is as follows.

Just delete the build folder in the package in question and run make again (this worked for me in Hydro).

more

I solved the problem the hard way.. I copy the package to it's new place, overwrite all the files that had the previous address in some place and then remove the autogenerated files like Thomas said (thanks). I did:

grep -rlZ 'originaladdress' . | xargs -r0 perl -pi -e 's/originaladdress/newaddress/g'


All files that had the previous address in some place was modified to use the same files but in the new location, and then i deleted the autogenerated files:

rm -rf CMakeCache.txt CMakeFiles cmake_install.cmake msg_gen srv_gen src/myPackage
cmake .
rosmake


At the end i deleted the original package and run without a problem from the new location in svn folder, it's seems a lot of work just for moving a package but it was the only way that i make it work.

more