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

catkin_make and friends fail to correctly resolve paths when invoked inside symlinked folders #638

Closed
tkruse opened this issue May 25, 2014 · 3 comments
Labels

Comments

@tkruse
Copy link
Member

tkruse commented May 25, 2014

To reproduce

# in basefolder, e.g. /tmp
mkdir origin
mkdir hydro-ws
cd hydro-ws/
ln -s ../origin/ src
cd src
catkin_make -C ..

Result:
The specified source space "/src" does not exist

Should be:
Building in basefolder/hydro-ws

The issue was originally discovered by @dirk-thomas in #603 and used as a reason to reject new features. Not sure why it was not ticketed and/or fixed since then, maybe keeping this bug can help reject more undesired pull requests in the future.
A function used to fix the buggy behavior was also originally given in PR #603, and would be merged in catkin by now if the maintainers had cared.

@dirk-thomas
Copy link
Member

Thank you for filling the ticket.

The problem is that Python is not aware that it is invoked in /tmp/hydro-ws/src as far as I can see. If you run the following command in that folder:

python -c "import os; print(os.getcwd())"

it outputs /tmp/origin as the already resolved symlinked location. I am not aware of any method how Python could get the information that it was actually in /tmp/hydro-ws/src. But I think this piece of information would be necessary to resolve the scenario you describe.

If you do know a way how Python can get the required information please share it and I will be happy to resolve the the described bug in the catkin_make and catkin_make_isolated tools.

@tkruse
Copy link
Member Author

tkruse commented May 25, 2014

As I have said before, I had already solved this in #603 using

python -c "import os; print(os.getenv('PWD'))"

https://github.com/tkruse/catkin/commit/de98d064b32eea82b023a2056f25dba4a70edb3a

In catkin/python/catkin/workspace.py

def get_cwd_rel_path(rel_or_abspath):
    '''returns the path if absolute, cwd if None, else cwd joined with the given relative path'''
    if rel_or_abspath and os.path.isabs(rel_or_abspath):
        return rel_or_abspath
    # Many, but not all shells, support this var that contains the path preserving symbolic link structures
    pwdpath = os.getenv('PWD')
    if pwdpath is None:
        # this function normalizes the path, does not follow symbolic links
        pwdpath = os.getcwd()
    if rel_or_abspath is not None:
        pwdpath = os.path.join(pwdpath, rel_or_abspath)
    return pwdpath

This then has to be invoked in the repsective places in catkin_make and catkin_make_isolated, as I had done in my pull request, until you kept on dismissing my PR due to this catkin bug.

@dirk-thomas
Copy link
Member

Since you removed the code from your pull request at some time that information was not publically available anymore.

With that snippet I was able to create a pull request which should address this bug. Please try #639 and verify that it works for you, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants