Fabric’s cd context manager does not work

Each Answer to this Q is separated by one/two green lines.

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"):

Here are the results after running fab xxx:

[localhost] local: pwd

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

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

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .