lima-vm / lima-vm/lima

shell --sync: Allow excluding files/folders from rsync

Open
#4,887 13 comments 0 reactions 0 assignees View on GitHub
area/cli enhancement
Dominant language
Go
Stars
21.9k
Forks
957
Avg merge
2d 6h
Merged PRs (30d)
53

Description

### Description

## Description

When running `limactl shell --sync` currently the whole working directory is synced to the guest system, and then also synced back. For projects with large genereated/dependency directories (eg. node_modules, vendor, build) this can make the initial sync slower, and make the sync-back noisier then necessary.

Especially in the AI agent use-case, we might also want to exclude certain folders being synced to the guest (eg. .git to exclude metadata).

## Proposal

To allow the user to exclude a path a `--sync-exclude` flag could be introduced, which is then passed as `--exclude` to rsync. Making this flag repeatable would provide a lot of flexibility, while keeping the implementation simple as rsync also accepts multiple `--exclude` flags.

```
$ limactl shell --sync . --sync-exclude=node_modules --sync-exclude=.git default
```

Another option would be to introduce a `.limasyncignore` file, simlar to `.dockerignore` or `.gitignore`. This would need to reside in the root directory beeing synced, and could be passed to rsync as `--exclude-from`. The format would be the same as the rsync exclude file with one pattern per line.

eg.
```
node_modules
.git
vendor
build
dist
*.o
```

## Implementation

The excludes could be appended to the `additionalArgs` when running the `shell --sync` command, and would also need to be apllied when running `getRsyncStats` as well as `rsyncBack`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.