Describe the bug
After upgrading to pyinfra 1.0.3 server.script operation when running on macOS target host (tested on Catalina 10.15.6). This works correctly on pyinfra 1.0.2. I have tested with version 1.0.4 and it fails there as well.
The operation I run is:
server.script(
name = 'Init .zshrc'
,src = 'scripts/create_zsh_profile.sh'
,shell_executable = host.data.zsh
)
It is never executed as it seems copying the script to a temporary location is failing, as per the "/tmp exists and is not a directory" error.
I am guessing perhaps it might have to do with the tmp directory in macOS (in Catalina, at least) is a symlink:

Output
--> Preparing operations...
Loading: virtual_machine.py
[pyinfra\api\operation] Adding operation, {'Init .zshrc'}, called @ virtual_machine.py:10, opLines=(0, 10), opHash=3b2f90227d43a40a2288506c2a99bdc5e71f32b2
[pyinfra\api\facts] Getting fact: file (ensure_hosts: (mac-host,))
[pyinfra\api\connectors\ssh] Running command on mac-host: (pty=False) sh -c 'stat /tmp/pyinfra-920aba211406e528eae3a2dfba47ad37f97d005d 1> /dev/null 2> /dev/null && (stat -c '"'"'user=%U group=%G mode=%A atime=%X mtime=%Y ctime=%Z size=%s %N'"'"' /tmp/pyinfra-920aba211406e528eae3a2dfba47ad37f97d005d 2> /dev/null || stat -f '"'"'user=%Su group=%Sg mode=%Sp atime=%a
mtime=%m ctime=%c size=%z %N%SY'"'"' /tmp/pyinfra-920aba211406e528eae3a2dfba47ad37f97d005d) || true'
[mac-host] >>> sh -c 'stat /tmp/pyinfra-920aba211406e528eae3a2dfba47ad37f97d005d 1> /dev/null 2> /dev/null && (stat -c '"'"'user=%U group=%G mode=%A atime=%X mtime=%Y ctime=%Z size=%s %N'"'"' /tmp/pyinfra-920aba211406e528eae3a2dfba47ad37f97d005d 2> /dev/null || stat -f '"'"'user=%Su group=%Sg mode=%Sp atime=%a mtime=%m ctime=%c size=%z %N%SY'"'"' /tmp/pyinfra-920aba211406e528eae3a2dfba47ad37f97d005d) || true'
[pyinfra\api\connectors\ssh] Waiting for exit status...37f97d005d - {mac-host}
[pyinfra\api\connectors\ssh] Command exit status: 0
Loaded fact file: ('/tmp/pyinfra-920aba211406e528eae3a2dfba47ad37f97d005d',)
[pyinfra\api\facts] Getting fact: directory (ensure_hosts: (mac-host,))
[pyinfra\api\connectors\ssh] Running command on mac-host: (pty=False) sh -c 'stat /tmp 1> /dev/null 2> /dev/null && (stat -c '"'"'user=%U group=%G mode=%A atime=%X mtime=%Y ctime=%Z
size=%s %N'"'"' /tmp 2> /dev/null || stat -f '"'"'user=%Su group=%Sg mode=%Sp atime=%a mtime=%m ctime=%c size=%z %N%SY'"'"' /tmp) || true'
[mac-host] >>> sh -c 'stat /tmp 1> /dev/null 2> /dev/null && (stat -c '"'"'user=%U group=%G mode=%A atime=%X mtime=%Y ctime=%Z size=%s %N'"'"' /tmp 2> /dev/null || stat -f '"'"'user=%Su
group=%Sg mode=%Sp atime=%a mtime=%m ctime=%c size=%z %N%SY'"'"' /tmp) || true'
[mac-host] user=root group=admin mode=lrwxr-xr-x atime=1594663936 mtime=1594663936 ctime=1594663981 size=11 /tmp -> private/tmp
[pyinfra\api\connectors\ssh] Waiting for exit status...
[pyinfra\api\connectors\ssh] Command exit status: 0
Loaded fact directory: ('/tmp',)
/tmp exists and is not a directory
--> 鈫怺0m[鈫怺1mmac-host鈫怺0m] 鈫怺31m鈫怺1mpyinfra error鈫怺0m (operation=Init .zshrc):
This is a true mystery! Looking at the diff I can't see anything that would affect this. In fact running similar locally on MacOS fails on both 1.0.2 + 1.0.4!
pyinfra @local server.script ~/Downloads/test.sh
--> Loading config...
--> Loading inventory...
--> Connecting to hosts...
[@local] Connected
--> Preparing operation...
--> pyinfra error: /tmp exists and is not a directory
Mystery aside I know where this is coming from - the check to ensure the target directory should tolerate a link and continue as normal, which I'll fix.
Interesting that it happens for you on 1.0.2 馃槷
1.0.2 runs very smooth for me.
If there's anything I can do to help or test, please let me know.
I've fixed this in https://github.com/Fizzadar/pyinfra/commit/4451f63be479c5f06d182127b534e05994837371, pending the 1.1. release. Also need to add a test case!
Test added accidentally in https://github.com/Fizzadar/pyinfra/commit/e30512eac9a6b202f8f2a32ab41f61bcbea8bde3#diff-6f794b2b1be89a4622446c573290d942 馃槵!
Fantastic, thanks!
I will look for the 1.1 release and test locally as well once out.
Tested with v1.1 all green :)