Sync failed
Opened this issue · 5 comments
I'm new to vim (actually MacVim). Got an error while trying to sync local to remote server :
:!$HOME/.vim/bundle/vim-syncr/sync_loc_rem_file /Volumes/Macintosh HD/Users/username/Sites/localweb/wp-content/themes/themename/.syncrconf /var/www/sitename/public_html/wp-con
tent/themes/themename/.syncrconf sshusername xxx.xxx.xxx.xxx true
/bin/bash: /Volumes/Macintosh: No such file or directory
shell returned 127
Is it because my local file location containing space? If so, are there any workaround?
Thanks.
Hi @aldidas,
The space is the problem I think, but for the moment I'm not using a setup where I can test a fix. If you can, try changing line 70 in plugin/syncr.vim from:
let conf['localpath'] = expand('%:p')
to
let conf['localpath'] = '\"' . expand('%:p') . '\"'
in your copy of the package. If that works, let me know and I can make the change or can take a pull request. If it doesn't work, then I will try to get to setting up a test environment and look for a solution.
Thanks.
Hi @jacob-ogre,
Thanks for your response. This is my latest code in syncr.vim :
if strlen(l:foundconfig) > 0
let options = readfile(l:foundconfig)
for i in options
let vname = substitute(i[0:stridx(i, ' ')],
\'^\s*\(.\{-}\)\s*$', '\1', '')
let vvalue = substitute(i[stridx(i, ' '):],
\'^\s*\(.\{-}\)\s*$', '\1', '')
let conf[vname] = vvalue
endfor
let conf['local'] = fnamemodify(l:foundconfig, ':h:p') . '/'
"let conf['localpath'] = expand('%:p')
let conf['localpath'] = '\"' . expand('%:p') . '\"'
let conf['remotepath'] = conf['remote'] .
\conf['localpath'][strlen(conf['local']):]
endif
Unfortunately sync process still didn't work as intended. Here are the output :
:!$HOME/.vim/bundle/vim-syncr/sync_loc_rem_file \"/Volumes/Macintosh HD/Users/username/Sites/localweb/wp-content/themes/themename/file.php\" /var/www/sitename/public_html/wp-content/themes/themename/s/file.php\" belalaiemas xxx.xxx.xxx.xxx true
/bin/bash: /Volumes/Macintosh: No such file or directory
shell returned 127
Please notice there is a "/s" between "themename" and "/file.php" in remote file path.
Hi @aldidas,
Interesting...I thought the double-quote would need to be escaped, but evidently not. Plus the re-use of conf['localpath'] in conf['remotepath'] is doing bad things. Try changing:
let conf['localpath'] = '\"' . expand('%:p') . '\"'
let conf['remotepath'] = conf['remote'] .
\conf['localpath'][strlen(conf['local']):]
to
let conf['localpath'] = '"' . expand('%:p') . '"'
let conf['remotepath'] = conf['remote'] .
\expand('%:p')[strlen(conf['local']):]
If that doesn't work, send the output again and we'll see if we can get it figured out. Sorry I don't have the environment to test and fix the bug...
Still failed. Here is my code :
if strlen(l:foundconfig) > 0
let options = readfile(l:foundconfig)
for i in options
let vname = substitute(i[0:stridx(i, ' ')],
\'^\s*\(.\{-}\)\s*$', '\1', '')
let vvalue = substitute(i[stridx(i, ' '):],
\'^\s*\(.\{-}\)\s*$', '\1', '')
let conf[vname] = vvalue
endfor
let conf['local'] = fnamemodify(l:foundconfig, ':h:p') . '/'
let conf['localpath'] = '"' . expand('%:p') . '"'
let conf['remotepath'] = conf['remote'] .
\expand('%:p')[strlen(conf['local']):]
endif
And here is the output :
:!$HOME/.vim/bundle/vim-syncr/sync_loc_rem_file "/Volumes/Macintosh HD/Users/username/Sites/localweb/wp-content/themes/themename/file.
php" /var/www/sitename/public_html/wp-content/themes/themename/file.php sshusername xxx.xxx.xxx.xxx true
/bin/bash: /Volumes/Macintosh: No such file or directory
shell returned 127
It seems the local path is correctly surrounded by quote, but somewhere in the code the space causing another trouble. I think this link is related to this issue. Or maybe this link for the space issue with rsync.
Well that's unfortunate. Per the scp
link you might next try putting quotes around the $1
at line 24 in the file 'sync_loc_rem_file'. Another option would be to have the vimscript escape any spaces in the file path, but I'm rusty enough on my vimscript that I don't know how to do that off the top of my head. Let me know if that works...