Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful failure when envoking catkin_make from wrong directory #328

Closed
hauptmech opened this issue Jan 22, 2013 · 4 comments
Closed

Graceful failure when envoking catkin_make from wrong directory #328

hauptmech opened this issue Jan 22, 2013 · 4 comments
Assignees

Comments

@hauptmech
Copy link
Contributor

I followed the catkin tutorials and lost a bit of time trying to understand why nothing was working when executing the following sequence.

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin_make
cd src
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
cd beginner_tutorials
#...add src/*.cpp and modify CMakeFiles.txt
catkin_make

catkin_make happily created a new workspace in place which to me, a newb, looked plausible. Of course no amount of catkin_make/cmake/make was useful from ~/catkin_ws/src/beginner_tutorials/

It would be great if catkin_make would either have an explicit command to create a new workspace or check whether it's located in a workspace and give the user a hint...

@tkruse
Copy link
Member

tkruse commented Jan 22, 2013

rosmake-like global invocation of catkin_make is not currently possible, not even part of the current catkin design. See #304. I believe there already once was a request to prevent catkin_make from running when the current folder did not contain a src folder, or contained a package.xml.

Generally these heuristics are not perfect however, it would be better if catkin_make checked that the source space it uses has a valid catkin CMakeLists.txt, whatever that means.

@hauptmech
Copy link
Contributor Author

If the catkin workspace root always lacks a CMakeFiles.txt, most of the subdirectories the novice user will be in will have CMakeFiles.txt. The following patch works if this is the case:

--- /home/teh/tmp/catkin_make   2013-01-22 17:00:20.632605653 +0100
+++ /opt/ros/groovy/bin/catkin_make 2013-01-22 17:11:30.939046371 +0100
@@ -26,6 +26,12 @@
         return 'The specified base path "%s" does not exist' % base_path
     print('Base path: %s' % base_path)

+    # test if we are in subdirectory of workspace
+    if os.path.exists(os.path.join(base_path,'CMakeLists.txt')):
+        retstr = 'You appear to be in a package directory\n'
+        retstr += 'Run catkin_make from your catkin workspace root directory!'
+        return retstr
+    
     # determine source space
     source_path = os.path.join(base_path, 'src')
     if args.source:

@hauptmech
Copy link
Contributor Author

My problem was that global invocation of catkin_make IS possible (ie it's in the os execution path) but the fact that it behaves correctly only when invoked from a specific location was not well enough documented.

I suspect that even when it is well documented it will still be a trap for new users.

@tkruse
Copy link
Member

tkruse commented Jan 22, 2013

Sure, what I meant was "global invocation of catkin that does something useful". That's not possible, but could be possible with e.g. an advertised build space in the development environment.

@ghost ghost assigned dirk-thomas Jan 24, 2013
cwecht pushed a commit to cwecht/catkin that referenced this issue Mar 20, 2018
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

No branches or pull requests

3 participants