Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
drcraig opened this Issue · 2 comments

3 participants

@drcraig

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
Owner

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

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

@xarg xarg referenced this issue from a commit in xarg/fabric
@xarg xarg Treat paths that begin with tilde "~" as absolute paths instead of re…
…lative.

Fixes #898
5d828df
@koobs koobs referenced this issue from a commit in freebsd/freebsd-ports
@koobs 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
a23e155
@knu knu referenced this issue from a commit in idaemons/freebsd-ports
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
8a11921
@knu knu referenced this issue from a commit in idaemons/freebsd-ports
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
52e56a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.