Fabric's cd context manager does not work

Serge Tarkovski picture Serge Tarkovski · Apr 8, 2011 · Viewed 10.8k times · Source

I have set up my development environment on a new PC and seems I am having strange error with Fabric. Its 'cd' context manager seems does not change the current directory, and thus a lot of my commands don't work. I have written the test and it showed me results I have not expected to get:

from __future__ import with_statement
from fabric.api import local, run, cd

def xxx():
    with cd("src"):
        local("pwd")

Here are the results after running fab xxx:

[localhost] local: pwd
/home/pioneer/workspace/myproject

But instead of /home/pioneer/workspace/myproject there should be /home/pioneer/workspace/myproject/src, I think.

Answer

Daniel Roseman picture Daniel Roseman · Apr 8, 2011

You're looking for lcd (l for local) rather than cd (which is remote).