Tilde paths are treated as relative paths instead of absolute by cd() #898

Closed
drcraig opened this Issue May 10, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@drcraig

drcraig commented May 10, 2013

Running:

with cd('~/somewhere'):
    with cd('~/somewhere'):
        run('pwd')

will cause an error because of:

Executed: /bin/bash -l -c "cd /somewhere//somewhere && pwd"

but running:

with cd('/home/someuser/somewhere'):
    with cd('/home/someuser/somewhere'):
        run('pwd')

will work fine and return "/home/someuser/somewhere". I don't know how it works under the hood, but on the surface it seems like tilde path expressions should be treated as absolute paths instead of relative paths.

The example is somewhat silly, but came up when there are utility functions that are called by other functions, all of which need to cd into the same directory, like so:

def utility():
    with cd('~/somewhere'):
        run('some cmd')

def bigger_function():
    with cd('~/somewhere'):
        run('some other cmd')
        utility()
@bitprophet

This comment has been minimized.

Show comment
Hide comment
@bitprophet

bitprophet Jul 6, 2013

Member

I haven't poked at it in a while but IIRC the way 'cd' works is to build up a list/stack of paths and joins them together for a single 'cd' call prior to execution; which is what you see in the debug output.

If there is a solution to this it's probably to either turn it into a series of 'cd' expressions (cd a && cd b && pwd) or to massage the file join logic so it attempts expansion prior to joining (see e.g. the 'echo' solution used in #860).

Member

bitprophet commented Jul 6, 2013

I haven't poked at it in a while but IIRC the way 'cd' works is to build up a list/stack of paths and joins them together for a single 'cd' call prior to execution; which is what you see in the debug output.

If there is a solution to this it's probably to either turn it into a series of 'cd' expressions (cd a && cd b && pwd) or to massage the file join logic so it attempts expansion prior to joining (see e.g. the 'echo' solution used in #860).

@asmeurer

This comment has been minimized.

Show comment
Hide comment
@asmeurer

asmeurer Jul 6, 2013

IMHO, paths with ~ should just be considered absolute. It does the right thing for normal absolute paths.

asmeurer commented Jul 6, 2013

IMHO, paths with ~ should just be considered absolute. It does the right thing for normal absolute paths.

xarg added a commit to xarg/fabric that referenced this issue Apr 16, 2014

koobs added a commit to freebsd/freebsd-ports that referenced this issue Jun 13, 2014

devel/py-fabric: Update to 1.8.4, fix w/ paramiko > 1.13
- Update to 1.8.4 (containing fix for paramiko > 1.13)
- Tweak RUN_DEPENDS on paramiko to match version string in setup.py

Changes:

    * Enhance setup.py to allow Paramiko 1.13+ under Python 2.6+. [1]
    * Treat paths that begin with tilde "~" as absolute lute paths instead of
      relative. [2]

[1] fabric/fabric#1105
[2] fabric/fabric#898

PR:		190856
Reported by:	blackmore at pichove dot org

knu pushed a commit to idaemons/freebsd-ports that referenced this issue Jun 15, 2014

koobs
devel/py-fabric: Update to 1.8.4, fix w/ paramiko > 1.13
- Update to 1.8.4 (containing fix for paramiko > 1.13)
- Tweak RUN_DEPENDS on paramiko to match version string in setup.py

Changes:

    * Enhance setup.py to allow Paramiko 1.13+ under Python 2.6+. [1]
    * Treat paths that begin with tilde "~" as absolute lute paths instead of
      relative. [2]

[1] fabric/fabric#1105
[2] fabric/fabric#898

PR:		190856
Reported by:	blackmore at pichove dot org


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@357658 35697150-7ecd-e111-bb59-0022644237b5

knu pushed a commit to idaemons/freebsd-ports that referenced this issue Jun 15, 2014

koobs
devel/py-fabric: Update to 1.8.4, fix w/ paramiko > 1.13
- Update to 1.8.4 (containing fix for paramiko > 1.13)
- Tweak RUN_DEPENDS on paramiko to match version string in setup.py

Changes:

    * Enhance setup.py to allow Paramiko 1.13+ under Python 2.6+. [1]
    * Treat paths that begin with tilde "~" as absolute lute paths instead of
      relative. [2]

[1] fabric/fabric#1105
[2] fabric/fabric#898

PR:		190856
Reported by:	blackmore at pichove dot org


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@357658 35697150-7ecd-e111-bb59-0022644237b5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment