Skip to content

provision.file escapes file contents (tabs become \t) #4268

@josharian

Description

@josharian

Description

When using provision.mode: data with the file: field, tab characters are escaped to \t inside the VM. The copied file no longer matches the original.

Discovered when a formatter changed tabs to spaces and our copied-in scripts stopped working.

Reproduction script:

#!/usr/bin/env bash
set -euo pipefail

cat > lima.yaml <<'YAML'
images:
  - location: "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-arm64.img"
    arch: "aarch64"

provision:
  - mode: data
    path: /tmp/file_with_tab.txt
    file: ./file_with_tab.txt
YAML

printf 'a\tb\n' > file_with_tab.txt
echo "ORIGINAL FILE CONTENT:"
cat file_with_tab.txt
od -c file_with_tab.txt
shasum -a 256 file_with_tab.txt

limactl --version
limactl create -y --name tabtest lima.yaml
limactl start tabtest
echo "FILE CONTENT INSIDE LIMA INSTANCE:"
limactl shell tabtest sudo cat /tmp/file_with_tab.txt
limactl shell tabtest sudo od -c /tmp/file_with_tab.txt
limactl shell tabtest sudo shasum -a 256 /tmp/file_with_tab.txt
limactl delete -f tabtest
rm lima.yaml file_with_tab.txt

On my machine, this prints:

$ ./lima_tab_escape_test.sh
ORIGINAL FILE CONTENT:
a       b
0000000    a  \t   b  \n
0000004
5dd1197866f479824d9b483e1b7ae9ad3e518f3b4fd447c6b92d127dda6178c5  file_with_tab.txt
limactl version 1.2.1
INFO[0000] Terminal is not available, proceeding without opening an editor
INFO[0000] Attempting to download the image              arch=aarch64 digest= location="https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-arm64.img"
INFO[0000] Using cache "/Users/josh/Library/Caches/lima/download/by-url-sha256/7c8e4507222e57734b580a24bf30b7828afaae43c2f040f6e0977f45669ce961/data"
INFO[0002] Attempting to download the nerdctl archive    arch=aarch64 digest="sha256:544fa1e518155fcc01a117ea49819d12d96b4dacfb2b62922f9f7956dc9f6dc8" location="https://github.com/containerd/nerdctl/releases/download/v2.1.3/nerdctl-full-2.1.3-linux-arm64.tar.gz"
INFO[0002] Using cache "/Users/josh/Library/Caches/lima/download/by-url-sha256/46d9ee12c9f3f484518470db8093719f2b3ddca7daa6f1741c71e0aeb198db2a/data"
INFO[0002] Run `limactl start tabtest` to start the instance.
INFO[0000] Using the existing instance "tabtest"
INFO[0000] Starting the instance "tabtest" with VM driver "vz"
INFO[0000] [hostagent] hostagent socket created at /Users/josh/.lima/tabtest/ha.sock
INFO[0000] [hostagent] Starting VZ (hint: to watch the boot progress, see "/Users/josh/.lima/tabtest/serial*.log")
INFO[0001] SSH Local Port: 51709
INFO[0000] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[0000] [hostagent] [VZ] - vm state change: running
INFO[0010] [hostagent] Waiting for the essential requirement 1 of 2: "ssh"
INFO[0011] [hostagent] The essential requirement 1 of 2 is satisfied
INFO[0011] [hostagent] Waiting for the essential requirement 2 of 2: "user session is ready for ssh"
INFO[0011] [hostagent] The essential requirement 2 of 2 is satisfied
INFO[0011] [hostagent] Waiting for the optional requirement 1 of 2: "systemd must be available"
INFO[0011] [hostagent] Guest agent is running
INFO[0011] [hostagent] Not forwarding TCP [::]:22
INFO[0011] [hostagent] The optional requirement 1 of 2 is satisfied
INFO[0011] [hostagent] Not forwarding UDP 127.0.0.54:53
INFO[0011] [hostagent] Not forwarding UDP 127.0.0.53:53
INFO[0011] [hostagent] Waiting for the optional requirement 2 of 2: "containerd binaries to be installed"
INFO[0011] [hostagent] Not forwarding UDP 192.168.5.15:68
INFO[0011] [hostagent] Not forwarding TCP 0.0.0.0:22
INFO[0011] [hostagent] Not forwarding TCP 127.0.0.54:53
INFO[0011] [hostagent] Not forwarding TCP 127.0.0.53:53
INFO[0026] [hostagent] Forwarding TCP from 127.0.0.1:39303 to 127.0.0.1:39303
INFO[0026] [hostagent] The optional requirement 2 of 2 is satisfied
INFO[0026] [hostagent] Waiting for the guest agent to be running
INFO[0026] [hostagent] Waiting for the final requirement 1 of 1: "boot scripts must have finished"
INFO[0035] [hostagent] The final requirement 1 of 1 is satisfied
INFO[0035] READY. Run `limactl shell tabtest` to open the shell.
FILE CONTENT INSIDE LIMA INSTANCE:
a\tb
0000000   a   \   t   b  \n
0000005
11b6ca2e51aac96230cefaba7840c12a9a1ae229d967b636c2700d7e06160353  /tmp/file_with_tab.txt
INFO[0000] Sending SIGKILL to the vz driver process 22490
INFO[0000] Sending SIGKILL to the host agent process 22490
INFO[0000] Removing *.pid *.sock *.tmp under "/Users/josh/.lima/tabtest"
INFO[0000] Removing "/Users/josh/.lima/tabtest/default_ep.sock"
INFO[0000] Removing "/Users/josh/.lima/tabtest/default_fd.sock"
INFO[0000] Removing "/Users/josh/.lima/tabtest/ha.pid"
INFO[0000] Removing "/Users/josh/.lima/tabtest/ha.sock"
INFO[0000] Removing "/Users/josh/.lima/tabtest/ssh.sock"
INFO[0000] Removing "/Users/josh/.lima/tabtest/vz.pid"
INFO[0000] Deleted "tabtest" ("/Users/josh/.lima/tabtest")

System info:

$ uname -a
Darwin jm3.local 25.0.0 Darwin Kernel Version 25.0.0: Wed Sep 17 21:38:50 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6031 arm64
$ limactl --version
limactl version 1.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions