Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

When I use rsync in winows system, there is an unsolvable error #68

Open
sfyr111 opened this issue Apr 29, 2020 · 4 comments
Open

When I use rsync in winows system, there is an unsolvable error #68

sfyr111 opened this issue Apr 29, 2020 · 4 comments

Comments

@sfyr111
Copy link

sfyr111 commented Apr 29, 2020

env:
process.platform: win32
node version: v10.x.x

my code

const workDir = path.resolve('.')


console.log(chalk.red(`This platform is ${process.platform}\n`))

const stdoutHandler = function(data) {
	console.log(chalk.green('stdoutHandler: '))
	console.log(data.toString())
	console.log(chalk.green('================\n'))
}
const stderrHandler = function() {
	console.log(chalk.red('stderrHandler: '))
	console.log(data.toString())
	console.log(chalk.red('================\n'))
}

module.exports = async (txt) => {
	
	const outFile = path.resolve(workDir, `testSync.txt`)
	await fse.outputFile(outFile, txt)
	
	const cmd = new Rsync()
		.flags('avz')
		.shell('ssh')
		.source(outFile)
		.destination('name@server:/home/appadmin/cli');
	
	cmd.execute(function(error, code, cmd) {
		console.log('code: ', code)
		if (error) {
			console.error(error)
			console.log('error: ', cmd)
			process.exit(1)
		}
		console.log('All done executing: ', cmd);
	}, stdoutHandler, stderrHandler);
}

cmd output content:

$ retailo2o-cli test 000
This platform is win32

stdoutHandler:
'rsync' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���

================

code:  1
Error: rsync exited with code 1
    at Rsync.<anonymous> (D:\nvm\v10.15.1\node_global\node_modules\retailo2o-cli\node_modules\rsync\rsync.js:525:21)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
error:  rsync -avz --rsh=ssh /workspace/coupon/testSync.txt name@server:/home/appadmin/cli
@ruinuola
Copy link

ruinuola commented Oct 9, 2020

I have the same problem

@iron66
Copy link

iron66 commented Apr 12, 2021

Same problem here. It seems like OS should support rsync, am I right @mattijs ?

@aiden3c
Copy link

aiden3c commented Apr 5, 2022

Same issue here

@zczcyc0201
Copy link

no rsync in your windows, you have to download 'cwrsync' , then put the 'cwrsync' in your src, then init Rsyhnc instance use executable params

let rsyncPath = path.resolve('libs/cwrsync/bin/rsync.exe')
let rsyncConfig={
executable:rsyncPath
}
var rsync = new Rsync(rsyncConfig)

notice:
When you setup 'source' and 'destination' of Rsync,you have to turn windows path into cgwin path,

example:
your source is "C:\sourceFolder" , you need turn into "/cygdrive/C/sourceFolder"

The follow code maybe can help you:

function transPathToCygwin(winPath) {
if (process.platform == "win32") {
if (winPath[1] == ":") {
let diskSign = winPath[0]
winPath = winPath.substr(2)
winPath = winPath.split(path.sep).join(path.posix.sep);
let posixPath = "/cygdrive/" + diskSign + winPath
return posixPath
}
} else {
return winPath
}
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants