Skip to content

Fix linux-portable mode: install codex/claude in VM guest via cloud-init and switch CI to Blacksmith#1

Merged
mjenkinsx9 merged 4 commits intomainfrom
copilot/help-with-issue
Mar 23, 2026
Merged

Fix linux-portable mode: install codex/claude in VM guest via cloud-init and switch CI to Blacksmith#1
mjenkinsx9 merged 4 commits intomainfrom
copilot/help-with-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

pcoder run <tool> --mode linux-portable has never worked end-to-end because the VM guest never had codex or claude installed, and the run script didn't wait for cloud-init to finish before executing the tool.

Changes

  • start-vm.ps1Write-CloudInitSeed: Add packages: [nodejs, npm] and runcmd: npm install -g @openai/codex @anthropic-ai/claude-code to the generated user-data. Tools are now provisioned automatically on first VM boot.

  • pcoder.cjsbuildRemoteRunScript: Prepend a bounded cloud-init wait to the remote script so the launcher blocks until first-boot provisioning completes before executing the CLI. The wait is capped at 900 seconds by default (configurable via PCODER_CLOUD_INIT_TIMEOUT). If the wait times out or cloud-init exits with an error, a clear diagnostic message is printed to stderr and the script exits with a non-zero code. No-op on systems without cloud-init.

    # injected at top of every remote run script
    if command -v cloud-init >/dev/null 2>&1; then
      _ci_to=${PCODER_CLOUD_INIT_TIMEOUT:-900}
      if ! timeout "$_ci_to" cloud-init status --wait 2>/dev/null; then
        _ci_rc=$?
        if [ "$_ci_rc" -eq 124 ]; then
          echo "pcoder: cloud-init wait exceeded ${_ci_to}s; provisioning may be incomplete" >&2
        else
          echo "pcoder: cloud-init finished with errors (exit ${_ci_rc}); provisioning may have failed" >&2
        fi
        exit 1
      fi
    fi
  • runtime/linux/cloud-init/user-data: Replaced non-representative placeholder with content that matches what Write-CloudInitSeed actually generates (SSH key field left as a placeholder string).

  • docs/RUNBOOKS.md: Document the first-boot provisioning step and note that initial runs can take 5–15 minutes while cloud-init installs packages.

  • .github/workflows/ci.yml and .github/workflows/claude-pr-runner.yml: Switched runner from depot-ubuntu-24.04 to blacksmith-2vcpu-ubuntu-2404. The Depot runner was not provisioned for this repository, causing all CI runs to queue indefinitely without starting.

  • README.md: Updated runner label references from Depot to Blacksmith.

Original prompt

I've never been able to get this working and could use some assistance


⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

@mjenkinsx9
Copy link
Collaborator

mjenkinsx9 commented Mar 23, 2026

@copilot Goal is to create a portable app I can throw on a flash drive or copy to any windows computer and run Claude code on it with local filesystem access like a traveling Claude code app

@mjenkinsx9 mjenkinsx9 requested a review from Copilot March 23, 2026 08:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mjenkinsx9 mjenkinsx9 marked this pull request as ready for review March 23, 2026 08:49
@mjenkinsx9 mjenkinsx9 requested a review from Copilot March 23, 2026 08:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Copilot AI changed the title [WIP] Assist with troubleshooting existing functionality Fix linux-portable mode: install codex/claude in VM guest via cloud-init Mar 23, 2026
Copilot AI requested a review from mjenkinsx9 March 23, 2026 08:51
@mjenkinsx9
Copy link
Collaborator

@copilot Can you see if you can get the blacksmith CI working

Copy link
Contributor Author

Copilot AI commented Mar 23, 2026

@copilot Can you see if you can get the blacksmith CI working

The CI was stuck in queued because the depot-ubuntu-24.04 runner isn't provisioned for this repository. Switched both workflows (ci.yml and claude-pr-runner.yml) to blacksmith-2vcpu-ubuntu-2404 in commit f43f50a. The runs should now start immediately.

@copilot Goal is to create a portable app I can throw on a flash drive or copy to any windows computer and run Claude code on it with local filesystem access like a traveling Claude code app

That's exactly what this PR is building toward. The previous commit (ff63103) fixes the end-to-end path: on first boot the VM automatically installs Node.js + the claude CLI via cloud-init, and pcoder run waits for that provisioning to finish before executing. Once the VM is running, pcoder run claude --mode linux-portable --project <path> will copy your project directory into the VM, run Claude Code there, and sync changes back — all from a self-contained folder you can put on a flash drive.

Copilot AI changed the title Fix linux-portable mode: install codex/claude in VM guest via cloud-init Fix linux-portable mode: install codex/claude in VM guest via cloud-init and switch CI to Blacksmith Mar 23, 2026
Copilot AI requested a review from mjenkinsx9 March 23, 2026 08:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


const lines = [
'set -e',
'if command -v cloud-init >/dev/null 2>&1; then cloud-init status --wait 2>/dev/null || true; fi',
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloud-init status --wait can block indefinitely if cloud-init is stuck (e.g., network/DNS issues during apt/npm installs). Since this runs at the top of every remote invocation, a single provisioning failure can cause pcoder run to hang forever. Consider adding a bounded wait (e.g., wrap with timeout or implement a loop with a max duration configurable via env) and emit a clear error when the wait times out or cloud-init ends in an error state.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 5ab835a. The unbounded cloud-init status --wait is now wrapped with timeout (default 900 s, overridable via PCODER_CLOUD_INIT_TIMEOUT). If the wait exceeds the limit the script prints a clear message to stderr and exits 1. The same exit-1 path is taken if cloud-init itself reports an error state.

Copilot AI requested a review from mjenkinsx9 March 23, 2026 09:15
@mjenkinsx9 mjenkinsx9 merged commit 278c6a9 into main Mar 23, 2026
2 checks passed
@mjenkinsx9 mjenkinsx9 deleted the copilot/help-with-issue branch March 23, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants