mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
A tool image missing from the share, or one the VM couldn't mount or link, used to be skipped with a line on stderr, and mise's auto_install then downloaded the same version into the VM on first use. Now the launch stops with a message naming the VM and the tools. - assets/guest/tools.sh: tries every listed image, removes a failed one's empty mount point, says why on stderr, lists the failed files in /run/devvm/tools-unmounted (removed at the start of each run) and exits 1. Link failures (Docker's unpacked folders) count too. - assets/guest/sync.sh: its devvm-tools call failing fails the setup. - assets/container/services.sh: a devvm-tools failure doesn't stop a smolvm or Docker start; the launch's setup reports it. - internal/vm/sync.go: after a failed setup, syncer.unmounted reads the VM's report with its own Exec (capped at 16 KiB, unmountedMax), and reported keeps only whole lines that are one of the VM's own tool files from its state, so the message carries devvm's values, never the VM's text. The setup's output still goes straight to the run log (a pipe would wait on processes the setup leaves running). - internal/tools: label is exported as Label; VMs.Update builds the VM's tool images that the share lacks even when they're the newest, so devvm update repairs a missing image. - Message tools_unmounted (tools, vm), linked to using/troubleshooting#a-shared-tool-doesnt-mount. - Docs: troubleshooting "A shared tool doesn't mount"; images.md's shared tools and devvm update; internals/images.md "The share" has the mechanism; design.md says why. - Tests: TestReported (internal/vm), TestUpdate rebuilds a missing newest image, guest.txtar runs tools.sh with stubbed mount commands, sync.txtar checks tools_unmounted and that other report lines don't count (limactl stub: $STUB_DIR/sync-fails-with), e2e's tools section moves node's image out of the share and back. Co-Authored-By: Claude Opus 5.5 <[email protected]>
144 lines
6.2 KiB
Plaintext
144 lines
6.2 KiB
Plaintext
# A VM's setup on every launch: the host's settings, its agents' config
|
|
# (never their history), their folders mounted read-only, and tokens: as
|
|
# they are without network policy, placeholders with it.
|
|
env DEVVM_MESSAGES=names
|
|
env DATA=$XDG_DATA_HOME/devvm
|
|
env TZ=Europe/Paris
|
|
env LANG=en_US.UTF-8
|
|
exec git config --global user.name 'Test User'
|
|
exec git config --global user.email [email protected]
|
|
|
|
# The host's agent config, and their history.
|
|
mkdir $HOME/.claude/skills $HOME/.claude/projects/p $HOME/.codex/prompts
|
|
cp $WORK/settings.json $HOME/.claude/settings.json
|
|
cp $WORK/claude.json $HOME/.claude.json
|
|
cp $WORK/codex.json $HOME/.codex/auth.json
|
|
cp $WORK/config.toml $HOME/.codex/config.toml
|
|
cp $WORK/history.jsonl $HOME/.claude/projects/p/history.jsonl
|
|
cp $WORK/history.jsonl $HOME/.codex/history.jsonl
|
|
|
|
# Without network policy: the agents' folders mounted read-only, their
|
|
# files and tokens copied as they are, with a warning naming the MCP
|
|
# servers whose secrets go too.
|
|
mkdir $WORK/plain
|
|
cd $WORK/plain
|
|
env CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-testfake
|
|
exec devvm --no-network-policy --no-git-protect claude+codex
|
|
stderr '^devvm: claude_mcp_secrets_copied servers=srv vm=devvm-plain-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^limactl clone --tty=false \S+ devvm-plain-[0-9a-f]{14} --mount-none --set \.mounts = \[\{"location":"\S*/plain","writable":true\},\{"location":"\S*/home/\.claude/skills","writable":false\},\{"location":"\S*/home/\.codex/prompts","writable":false\},\{"location":"\S*/data/devvm/tools","mountPoint":"/mnt/devvm-tools","writable":false\}\]'
|
|
exec tar -tf $STUB_DIR/sync.tar
|
|
stdout '^home/\.claude/settings\.json$'
|
|
stdout '^home/\.codex/auth\.json$'
|
|
stdout '^home/\.codex/config\.toml$'
|
|
stdout '^claude\.json$'
|
|
! stdout 'history|projects|^ca/'
|
|
exec tar -xOf $STUB_DIR/sync.tar home/.claude/settings.json
|
|
stdout testfake-settings
|
|
exec tar -xOf $STUB_DIR/sync.tar claude.json
|
|
stdout testfake-mcp
|
|
exec tar -xOf $STUB_DIR/sync.tar links
|
|
stdout '^\.claude/skills\n\.claude/agents\n\.claude/commands\n\.claude/output-styles\n\.claude/plugins\n\.codex/prompts\n\.codex/skills\n\z'
|
|
exec tar -xOf $STUB_DIR/sync.tar host_home
|
|
stdout '/home$'
|
|
exec tar -xOf $STUB_DIR/sync.tar vm
|
|
cmp stdout $WORK/vm-plain
|
|
exec tar -xOf $STUB_DIR/sync.tar env
|
|
stdout '^export LANG=''en_US\.UTF-8''\nexport CLAUDE_CODE_OAUTH_TOKEN=''sk-ant-oat01-testfake''\n\z'
|
|
|
|
# A Claude token that isn't a setup-token token isn't sent; no token at
|
|
# all is named too.
|
|
mkdir $WORK/badtoken
|
|
cd $WORK/badtoken
|
|
env CLAUDE_CODE_OAUTH_TOKEN=not-a-setup-token
|
|
exec devvm --no-network-policy --no-git-protect claude
|
|
stderr '^devvm: claude_token_invalid$'
|
|
exec tar -xOf $STUB_DIR/sync.tar env
|
|
! stdout CLAUDE_CODE_OAUTH_TOKEN
|
|
mkdir $WORK/notoken
|
|
cd $WORK/notoken
|
|
env CLAUDE_CODE_OAUTH_TOKEN=
|
|
exec devvm --no-network-policy --no-git-protect claude
|
|
stderr '^devvm: no_claude_token vm=devvm-notoken-[0-9a-f]{14}$'
|
|
|
|
# With network policy: devvm's CA, the VM's own placeholders, the logins'
|
|
# copies with placeholders (the host's files unchanged), and the
|
|
# settings files with their keys taken out; one devvm can't read that way
|
|
# isn't sent.
|
|
mkdir $WORK/net
|
|
cd $WORK/net
|
|
env CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-testfake
|
|
exec devvm --network-policy --no-git-protect claude+codex
|
|
stderr '^config_redacted file=\S*/home/\.claude/settings\.json keys=env\.ANTHROPIC_API_KEY vm=devvm-net-[0-9a-f]{14}$'
|
|
stderr '^devvm: config_not_copied file=\S*/home/\.codex/config\.toml vm=devvm-net-[0-9a-f]{14}$'
|
|
! stderr claude_mcp_secrets_copied
|
|
exec tar -tf $STUB_DIR/sync.tar
|
|
! stdout '^home/\.codex/config\.toml$'
|
|
exec tar -xOf $STUB_DIR/sync.tar ca/devvm-proxy.crt
|
|
cmp stdout $DATA/ca/ca.pem
|
|
exec sh -c 'tar -xOf "$STUB_DIR/sync.tar" home/.claude/settings.json home/.codex/auth.json claude.json env'
|
|
! stdout testfake
|
|
stdout devvm-redacted
|
|
stdout '"OPENAI_API_KEY": *"sk-devvm-proxy-managed'
|
|
! stdout projects
|
|
exec sh -c 'salt=$(sed -n "s/^proxy_salt=//p" "$DATA"/vms/devvm-net-*); tar -xOf "$STUB_DIR/sync.tar" env | grep -Fx "export CLAUDE_CODE_OAUTH_TOKEN=''sk-ant-oat01-devvm-proxy-managed-$salt''"'
|
|
exec sh -c 'key=$(sed -n "s/^proxy_key=//p" "$DATA"/vms/devvm-net-*); tar -xOf "$STUB_DIR/sync.tar" vm | grep -E "^DEVVM_PROXY=''http://devvm:$key@[0-9.]+:[0-9]+''$"'
|
|
cmp $HOME/.codex/auth.json $WORK/codex.json
|
|
cmp $HOME/.claude.json $WORK/claude.json
|
|
|
|
# A setup that fails says so, and leaves nothing of what it was sent.
|
|
mkdir $WORK/tmp $WORK/fails
|
|
cd $WORK/fails
|
|
env TMPDIR=$WORK/tmp
|
|
exec sh -c ': > "$STUB_DIR/shell-fails"'
|
|
! exec devvm --no-network-policy --no-git-protect claude
|
|
stderr '^devvm: sync_failed vm=devvm-fails-[0-9a-f]{14}$'
|
|
exec sh -c 'ls -A "$TMPDIR"'
|
|
! stdout .
|
|
rm $STUB_DIR/shell-fails
|
|
|
|
# A shared tool the VM couldn't mount stops the launch, named by the VM's
|
|
# own tool list: a line naming any other file doesn't count, and with
|
|
# none left it's the setup that failed.
|
|
exec bash $WORK/unmounted.sh '' ../../etc/passwd
|
|
! exec devvm --no-network-policy --no-git-protect
|
|
stderr '^devvm: tools_unmounted tools=claude [0-9][0-9.]* vm=devvm-fails-[0-9a-f]{14}$'
|
|
exec bash $WORK/unmounted.sh claude-9.9.9-000000000000.erofs
|
|
! exec devvm --no-network-policy --no-git-protect
|
|
stderr '^devvm: sync_failed vm=devvm-fails-[0-9a-f]{14}$'
|
|
rm $STUB_DIR/sync-fails-with
|
|
exec devvm --no-network-policy --no-git-protect
|
|
! stderr 'tools_unmounted|sync_failed'
|
|
|
|
-- unmounted.sh --
|
|
# The report tools.sh writes when it fails, listing each file named ('' for
|
|
# the VM's first tool image) after lines of its own, and with a last line
|
|
# cut short.
|
|
first=$(sed -n 's/^tools=//p' "$DATA"/vms/devvm-fails-*)
|
|
{
|
|
echo "devvm-tools: can't mount something"
|
|
printf '%s\n' "${first%% *} and more"
|
|
for f in "$@"; do echo "${f:-${first%% *}}"; done
|
|
printf '%s' "${first%% *}"
|
|
} > "$STUB_DIR/sync-fails-with"
|
|
|
|
-- settings.json --
|
|
{"env":{"ANTHROPIC_API_KEY":"testfake-settings"},"theme":"dark"}
|
|
-- claude.json --
|
|
{"theme":"dark","mcpServers":{"srv":{"command":"x","env":{"API_KEY":"testfake-mcp"}}},"projects":{"/p":{"history":["testfake-history"]}}}
|
|
-- codex.json --
|
|
{"OPENAI_API_KEY":"sk-testfake-codex","last_refresh":null}
|
|
-- config.toml --
|
|
note = """
|
|
testfake-multiline
|
|
"""
|
|
-- history.jsonl --
|
|
{"prompt":"testfake-history"}
|
|
-- vm-plain --
|
|
DEVVM_HOSTNAME='plain'
|
|
DEVVM_TZ='Europe/Paris'
|
|
DEVVM_LANG='en_US.UTF-8'
|
|
DEVVM_GIT_NAME='Test User'
|
|
DEVVM_GIT_EMAIL='[email protected]'
|
|
DEVVM_PROXY=''
|