mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
fix(workspaces): implement sudo support for rsync to resolve remote permission issues
This commit is contained in:
@@ -71,6 +71,7 @@ export interface ExecOptions {
|
|||||||
export interface SyncOptions {
|
export interface SyncOptions {
|
||||||
delete?: boolean;
|
delete?: boolean;
|
||||||
exclude?: string[];
|
exclude?: string[];
|
||||||
|
sudo?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WorkspaceStatus {
|
export interface WorkspaceStatus {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export class GceConnectionManager {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sync(localPath: string, remotePath: string, options: { delete?: boolean; exclude?: string[] } = {}): number {
|
sync(localPath: string, remotePath: string, options: { delete?: boolean; exclude?: string[]; sudo?: boolean } = {}): number {
|
||||||
const fullRemote = this.getMagicRemote();
|
const fullRemote = this.getMagicRemote();
|
||||||
// We use --no-t and --no-perms to avoid "Operation not permitted" errors
|
// We use --no-t and --no-perms to avoid "Operation not permitted" errors
|
||||||
// when syncing to volumes that might have UID mismatches with the container.
|
// when syncing to volumes that might have UID mismatches with the container.
|
||||||
@@ -62,6 +62,11 @@ export class GceConnectionManager {
|
|||||||
if (options.delete) rsyncArgs.push('--delete');
|
if (options.delete) rsyncArgs.push('--delete');
|
||||||
if (options.exclude) options.exclude.forEach(ex => rsyncArgs.push(`--exclude="${ex}"`));
|
if (options.exclude) options.exclude.forEach(ex => rsyncArgs.push(`--exclude="${ex}"`));
|
||||||
|
|
||||||
|
// Use sudo on the remote side if requested to bypass permission errors
|
||||||
|
if (options.sudo) {
|
||||||
|
rsyncArgs.push('--rsync-path="sudo rsync"');
|
||||||
|
}
|
||||||
|
|
||||||
const sshCmd = `ssh ${this.getCommonArgs().join(' ')}`;
|
const sshCmd = `ssh ${this.getCommonArgs().join(' ')}`;
|
||||||
const directRsync = `rsync ${rsyncArgs.join(' ')} -e ${this.quote(sshCmd)} ${localPath} ${fullRemote}:${remotePath}`;
|
const directRsync = `rsync ${rsyncArgs.join(' ')} -e ${this.quote(sshCmd)} ${localPath} ${fullRemote}:${remotePath}`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user