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

Support invocation in subfolders of the workspace #139

Open
koenlek opened this issue Dec 19, 2018 · 20 comments
Open

Support invocation in subfolders of the workspace #139

koenlek opened this issue Dec 19, 2018 · 20 comments
Labels
enhancement New feature or request

Comments

@koenlek
Copy link

koenlek commented Dec 19, 2018

If I run colcon build in ~/ros2_ws/src it will create the output folders in the ~/ros2_ws/src folder, i.e.:

  • ~/ros2_ws/src/build
  • ~/ros2_ws/src/log
  • ~/ros2_ws/src/install

Instead, you would expect them to end up in the top level directory, like catkin_tools does (so in ~/ros2_ws instead of ~/ros2_ws/src). Catkin tools marks the top level directory using the .catkin_tools folder (like git does it by "going up" until it finds a .git folder). I see that colcon doesn't have such a folder yet, so it doesn't have a way to determine the workspace top-level. Sooner or later I guess such a folder (e.g. ~/ros2_ws/.colcon) should be added anyway, to store things like profiles/configs (like catkin tools does).

Maybe a good feature to add?

@dirk-thomas
Copy link
Member

colcon is intended to be invoked in the root of the workspace. It currently doesn't support being invoked in the src directory. While that would be possible it is currently not planned to be worked on.

@dirk-thomas dirk-thomas added the enhancement New feature or request label Dec 19, 2018
@dirk-thomas dirk-thomas changed the title Output directories should log/install/build should by default go in the top-level directory of the colcon workspace Support invocation in subfolders of the workspace Dec 26, 2018
@rotu
Copy link
Contributor

rotu commented Jul 15, 2019

I would appreciate this too.

I often accidentally run colcon in a subfolder or sometimes in a superfolder of my workspace. I think it would be a fair change of behavior if colcon build took an optional positional argument. If provided, it would create a workspace there and build it. If absent, it would recursively crawl parent folders until it found a workspace (identified by its install/.colcon_install_layout file) and build there. Not finding one would show an error message and exit.

@dirk-thomas
Copy link
Member

I think it would be a fair change of behavior if colcon build took an optional positional argument. If provided, it would create a workspace there and build it.

The logic is a little bit more complicated since this will affect other arguments which are currently specified as paths relative to the current directory. E.g. if you specify a custom --install-base base it is relative to the cwd. But the default value install would need to be relative to the proposed optional positional argument.

If absent, it would recursively crawl parent folders until it found a workspace (identified by its install/.colcon_install_layout file) and build there.

The same complexity for interpreting default values / relative paths exists here.

@deitry

This comment has been minimized.

@dirk-thomas

This comment has been minimized.

@jacobperron
Copy link
Contributor

An alternative is to have a version of colcon that is workspace-aware.
E.g. a tool colcon_ws that wraps common colcon commands, but behaves more similarly to catkin_tools. I do miss the ROS 1 workflow of quickly changing to a package, making a small edit, and invoking catkin bt.

@dirk-thomas
Copy link
Member

Please see my previous comment about the complexity around command line arguments representing relative paths. So just cd into the root and running the same command isn't sufficient.

@rhaschke
Copy link

It would be great to have such a feature, because the need to cd to the top-level folder significantly interrupts the development workflow.
As far as I understand, colcon doesn't use any config cache, e.g. build parameters, package selection, etc. as catkin tools has done (which is a pity as well). Thus, it doesn't have a notion of the top-level build folder, does it? @dirk-thomas, what is your suggestion to implement such a feature?
Is the configuration mechanism a suitable starting point?

@dirk-thomas
Copy link
Member

Is the configuration mechanism a suitable starting point?

I don't see how the configuration mechanisms are related to this?

what is your suggestion to implement such a feature?

Obviously the root of the workspace needs to be marked somehow on the first invocation. That part should be trivial.

Then subsequent invocations have to check if they are called from a recursive subdirectory of any marked workspace root. And if that is the case the execution should happen as if the command was called in the workspace root - except that any explicitly provided arguments from the CLI which contain relative path must be updated accordingly if e.g. the cwd is changed to achieve the behavior to run from the root.

The challenge here will be to know what arguments are coming from the CLI and which ones are coming from configuration files and/or default values since they need to be treated differently.

@rhaschke
Copy link

I think adding a configuration mechanism that relies on cached information stored in the workspace root (á la catkin tools) would be a nice addition to colcon. Don't you agree?

@dirk-thomas
Copy link
Member

I do agree that profiles would be a nice feature. But they are orthogonal to the feature described in this ticket and tracked in a separate one: see #168.

@rhaschke
Copy link

Agreed. For me, the features are (loosely) related, as the profiles would mark the workspace root.

@dirk-thomas
Copy link
Member

the features are (loosely) related, as the profiles would mark the workspace root.

It depends on the implementation choice for profiles. Maybe they are stored in a user config directory instead.

@andrejpan
Copy link

After 6 years this is still impossible/low level priority ticket?

@rhaschke
Copy link

There are several plugins provided by the community to address this issue, for example:
https://github.com/rhaschke/colcon-top-level-workspace

@andrejpan
Copy link

Tnx a lot @rhaschke. I guess we can also close this ticket.

@Flova
Copy link

Flova commented Jan 23, 2024

There are several plugins provided by the community to address this issue, for example: https://github.com/rhaschke/colcon-top-level-workspace

I think this is based on the official one:
https://github.com/colcon/colcon-top-level-workspace

But the official one seems pretty wip.

@rhaschke
Copy link

There are several plugins provided by the community to address this issue, for example: https://github.com/rhaschke/colcon-top-level-workspace

I think this is based on the official one: https://github.com/colcon/colcon-top-level-workspace

But the official one seems pretty wip.

Yes, my version was inspired by the "official" one. However it is a full rewrite.
There is an open PR, namely colcon/colcon-top-level-workspace#2, but @cottsay didn't have time to look into that yet.

@rhaschke
Copy link

I would like to keep this issue open until the official package has merged my PR.

@agyoungs
Copy link

agyoungs commented Aug 8, 2024

Is there any movement on this issue? This looks to be pretty useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
9 participants