Akihiro Suda 1e6e2b38c5 copytool: make copy -r into an existing directory consistent across backends
For a recursive copy whose destination is an existing directory, the rsync
backend copied the *contents* of the source directory, while the scp backend
copied the directory itself, like `cp -r` and `scp -r` do. Since `--backend=auto`
prefers rsync and only falls back to scp when the guest has no rsync, the
outcome of the very same command depended on the guest image.

The rsync backend appended a trailing slash to every path of a recursive copy,
and a trailing slash on the source is what tells rsync to copy the contents.
Derive the form to pass to rsync from the destination instead, so that a
trailing slash spelled by the user is no longer significant:

- the destination is an existing directory: `SRC DST`, copying SRC into DST;
- the destination does not exist yet: `SRC/ DST`, making DST a copy of SRC.

A destination that can neither be confirmed nor ruled out to be a directory
fails the copy, instead of being assumed to be missing, which would put the
files in the wrong place again.

This also fixes two related defects of the previous code: `copy -r` of a
non-directory into a destination that does not exist made rsync fail on the
appended slash, and multiple sources were merged into the destination instead
of being copied by name.

Add the missing case to copy.bats (both backends, both directions), which only
covered a plain `SRC DST` copy into a destination that does not exist yet, plus
unit tests for the path rewriting, which needs no VM.

`limactl shell --sync` does want the form that copies the contents, so let it
spell its own paths with a trailing slash and stop setting Options.Recursive,
which for rsync only added a `-r` that `-a` already implies.

Fixes #5500

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-09-16 15:46:24 +09:00
2026-02-20 20:45:52 -08:00
2022-03-10 16:59:23 +09:00
2021-05-14 16:28:44 +09:00

[🌎Web site] [📖Documentation] [👤Slack (#lima)]

Shows a stylized 'Lima' text in bold, modern font

Lima: Linux Machines

Ask DeepWiki OpenSSF Best Practices OpenSSF Scorecard

Lima launches Linux virtual machines with automatic file sharing and port forwarding (similar to WSL2).

The original goal of Lima was to promote containerd including nerdctl (contaiNERD ctl) to Mac users, but Lima can be used for non-container applications as well.

Lima also supports other container engines (Docker, Podman, Kubernetes, etc.) and non-macOS hosts (Linux, NetBSD, etc.).

Getting started

Set up (Homebrew):

brew install lima
limactl start

To run Linux commands:

lima uname -a

To run containers with containerd:

lima nerdctl run --rm hello-world

To run containers with Docker:

limactl start template:docker
export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')
docker run --rm hello-world

To run containers with Kubernetes:

limactl start template:k8s
export KUBECONFIG=$(limactl list k8s --format 'unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml')
kubectl apply -f ...

See https://lima-vm.io/docs/ for the further information.

Contributing

We welcome contributions! Please see our Contributing Guide for details on:

  • Developer Certificate of Origin (DCO): All commits must be signed off with git commit -s
  • Code licensing and pull request guidelines
  • Testing requirements

Community

Adopters

Container environments:

  • Rancher Desktop: Kubernetes and container management to the desktop
  • Colima: Docker (and Kubernetes) on macOS with minimal setup
  • Finch: Finch is a command line client for local container development
  • Podman Desktop: Podman Desktop GUI has a plug-in for Lima virtual machines

GUI:

Communication channels

Social media accounts

Follow us for project updates, release announcements, and community news:

Code of Conduct

Lima follows the CNCF Code of Conduct.


We are a Cloud Native Computing Foundation incubating project.

The Linux Foundation® (TLF) has registered trademarks and uses trademarks. For a list of TLF trademarks, see Trademark Usage.

Languages
Go 79.1%
Shell 18.5%
Makefile 1.5%
HTML 0.4%
PowerShell 0.4%