When wrapping a put(x, y, use_sudo=True) call within a with cd(): block, the hidden sudo(mv) call inside put (which moves the file from its temp location to the final destination) is honoring the cd prefix. The mv call uses a relative path in its first argument (I assume because we didn't want to specify an absolute remote temporary location?) and is thus in the wrong directory when it actually runs.
put(x, y, use_sudo=True)
The obvious solution is to use an absolute path for the use_sudo=True temporary location. So either assume the remote system has a /tmp, or (probably better) determine the remote user's home directory as an absolute path, and then use that explicitly instead of implicitly.
Submitted by irc user dsx4ever / Egor M.
Originally submitted by Jeff Forcier (bitprophet) on 2011-04-25 at 09:06pm EDT
Having same problem ;(
This also effects, by proxy, upload_template when used in the same situation (inside cd, and using use_sudo=True.) Confirmed report from IRC user easylancer.
Don't apply cd() to put()'s internals.