Skip to content

copy: step is not applied on a target: vm deploy (mkdir/write/command from the same candy are) #460

Closed
opencharly/sdk
#188

Description

@atrawog

Symptom

On a target: vm deploy, a candy's copy: step does not deliver its file. The
destination directory is created, and every other verb in the SAME candy on the SAME
deploy applies normally — only copy: is missing.

Measured

Candy punktfunk (opencharly/layer-punktfunk), applied to an Arch cloud-image VM via
add_candy: on a disposable bed, charly built from v2026.241.1535+1.

The candy's plan contains, in order:

- run: create the user's local bin directory
  mkdir: "${HOME}/.local/bin"
  run_as: "${USER}"
- run: install the punktfunk-host launcher wrapper for the container venue
  copy: punktfunk-host-wrapper          # sits beside charly.yml in the candy dir
  to: "${HOME}/.local/bin/punktfunk-host-wrapper"
  mode: "0755"
  run_as: "${USER}"
- run: write the host.env policy file ...
  write: "${HOME}/.config/punktfunk/host.env"
- run: enable systemd user lingering ...
  command: |
    ...

In the guest afterwards:

$ ls -la ~/.local/bin/
total 0
drwxr-xr-x 1 arch arch 0 Aug 29 20:13 .      <- mkdir: applied
drwxr-xr-x 1 arch arch 6 Aug 29 20:13 ..
                                              <- copy: did NOT deliver

$ ls -l ~/.config/punktfunk/host.env
-rw-r--r-- 1 arch arch 1018 Aug 29 20:13      <- write: applied

$ loginctl show-user arch -p Linger
Linger=yes                                    <- command: applied

So mkdir:, write: and command: from that candy all applied; copy: did not.

The step is absent from the deploy plan entirely, not failing:

$ grep -c 'punktfunk-host-wrapper' .check/check-punktfunk-vm/<calver>/deploy-add.log
0

deploy-add reported PASS, so nothing surfaced as an error.

Not a source-resolution problem

The same candy, same file, same copy: step delivers correctly on the image build
path — the wrapper is present and executable in the built container image, and a
container bed asserts it:

PASS  the container-venue launcher wrapper is installed and executable  [punktfunk-wrapper-installed]

So the file resolves against the candy dir fine; the divergence is build vs deploy.

Why it matters beyond this candy

copy: is documented as a first-class install verb and is classified deploy-capable —
OpStep.Venue() returns VenueHostNative and RequiresGate() lists
mkdir/copy/write/link/download/setcap together as structured verbs. Other candies rely
on it for host/VM deploys: pod-sway delivers both sway-wrapper and its config via
copy:, so a target: vm deploy of the sway stack would land a compositor with no
launcher.

I have not root-caused which stage drops it (compile vs. lowering to PutFile), so this is
a report of a reproducible measurement rather than a diagnosis.

Reproducer

  1. Candy with a file beside charly.yml and a copy: step targeting ${HOME}/....
  2. Apply it to a kind: vm deploy via add_candy: with
    install_opts: {allow_repo_changes: true, allow_root_tasks: true}.
  3. charly check run <bed> → deploy passes; the copied file is absent in the guest while
    sibling mkdir:/write:/command: effects are present.

Surfaced while landing punktfunk streaming-host support
(opencharly/layer-punktfunk#2). That PR does not depend on the behaviour — its wrapper
check is venue-scoped on its own merits, because the wrapper is only the launch path
under a container init.

Activity

  1. atrawog commented on Aug 29, 2026

    @atrawog
    ContributorAuthor

    Root-caused — it is a missing token resolution, not a dropped step

    My original report guessed the step was dropped from the plan. It is not: the step
    compiles, reaches the venue, and the file is delivered — to the wrong path.

    charly fleet add --dry-run shows all three ops present:

    Plan: candy=copytest image=vm-adhoc distro=arch steps=3
      Op: 3
    

    And on the live guest the file exists, in a directory literally named {{.Home}}:

    $ sudo find / -xdev -name copied.txt
    /home/arch/{{.Home}}/copyprobe/copied.txt
    
    $ ls -la ~
    drwxr-xr-x  copyprobe          # mkdir: applied
    drwxr-xr-x  {{.Home}}          # created by the unresolved token
    $ ls ~/copyprobe
    written.txt                    # write: applied; copied.txt is not here
    

    Why

    A home-relative to: is deliberately tokenized at compile so each emit target can
    resolve it against the destination home (install_build.go: "Tokenize a home-relative
    to: so each EmitTarget resolves it against the real destination home at emit").

    The OCI target resolves it — OCITarget.emitPlan calls spec.ResolveHome(plan, t.Home),
    whose case *OpStep: arm does s.To = sub(s.To).

    The machine-venue walk had no equivalent: kit.walkOp passed step.To straight into
    PutFile.

    mkdir:, write: and command: are unaffected because those legs render shell that
    expands $HOME at runtime on the venue. Only the PutFile-staged verbs (copy:, and any
    home-relative download: to:) hit this.

    Scope

    pod-sway delivers both sway-wrapper and config via copy:, so a target: vm deploy
    of the sway stack lands a compositor whose launcher is in a junk directory. Any candy using
    copy: with a home-relative to: on a machine venue is affected.

    Fix

    opencharly/sdk#188 — WalkPlans resolves the token across the same field set
    spec.ResolveHome covers, before any step runs; the venue home is probed lazily and the
    probe is shared with the env.d finalizer. The regression test fails without it with exactly
    the symptom above (PutFile saw [{{.Home}}/probe/copied.txt]).

    Landing it end to end needs the sdk tag, then a plugin-deploy-vm repin.

    Minimal reproducer (~2 min on a disposable Arch cloud-image VM bed)

    plan:
      - run: create the target directory
        mkdir: "${HOME}/copyprobe"
        run_as: "${USER}"
      - run: copy a marker file from the candy dir
        copy: marker.txt                       # sits beside charly.yml
        to: "${HOME}/copyprobe/copied.txt"
        run_as: "${USER}"
      - run: write a marker file inline
        write: "${HOME}/copyprobe/written.txt"
        content: |
          WRITTEN-FILE-CONTENT
        run_as: "${USER}"

    Apply via add_candy: to a kind: vm deploy with
    install_opts: {allow_repo_changes: true, allow_root_tasks: true}; then in the guest
    ~/copyprobe holds only written.txt.

  2. added 5 commits that reference this issue on Aug 29, 2026
    446ef72
    bfd91ea
    169dd6b
    1692689
    d2035c6
  3. atrawog commented on Aug 29, 2026

    @atrawog
    ContributorAuthor

    Fixed and delivered

    Root cause: the deferred {{.Home}} token was never resolved on a machine venue. The
    OCI target resolves it (OCITarget.emitPlan → spec.ResolveHome, whose case *OpStep:
    arm does s.To = sub(s.To)); kit.WalkPlans had no equivalent, so walkOp handed the
    literal token to PutFile. mkdir:/write:/command: were unaffected because those legs
    render shell that expands $HOME on the venue — only the PutFile-staged verbs (copy:,
    and a home-relative download: to:) hit it.

    The fix — opencharly/sdk#188, in v0.2026241.2117: WalkPlans resolves the token
    across the same field set spec.ResolveHome covers, before any step runs; the venue home
    is probed lazily, and that probe is now one helper shared with the env.d finalizer. An
    unresolvable home is a no-op rather than an empty substitution.

    Delivered to every venue. A plugin is built against its own pinned sdk, so each
    plan-walking plugin had to repin — all four merged:

    plugin PR venue
    plugin-deploy-vm opencharly/plugin-deploy-vm#3 target: vm
    plugin-deploy-local opencharly/plugin-deploy-local#3 target: local
    plugin-deploy-pod opencharly/plugin-deploy-pod#5 pod overlays
    plugin-installstep opencharly/plugin-installstep#2 install-step execution

    Verified end to end on a disposable Arch cloud-image VM bed with the reproducer from
    this issue — before the bump the copy assertion fails and the file sits at
    /home/arch/{{.Home}}/copyprobe/copied.txt; after it, the full charly check run
    including the fresh-rebuild leg is green:

    3 steps: 3 passed, 0 failed, 0 skipped   EXIT=0
    PASS  the copied file landed alongside the written one  [copyrepro-copy-landed]  exit=0
    

    A regression test guards the seam (kit/walk_home_token_test.go); with the resolution call
    neutralised it fails with exactly the original symptom
    (PutFile saw [{{.Home}}/probe/copied.txt]).

    Note for anyone hitting this on an older toolchain: the fix only reaches a venue once that
    venue's deploy plugin is repinned, so a stale ~/.cache/charly/repos/... checkout can still
    reproduce the old behaviour until it refetches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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