Skip to content

feat: dynamic path resolution for lima config during vm init#1768

Open
ayush-panta wants to merge 2 commits into
mainfrom
runtime-path-resolution
Open

feat: dynamic path resolution for lima config during vm init#1768
ayush-panta wants to merge 2 commits into
mainfrom
runtime-path-resolution

Conversation

@ayush-panta

@ayush-panta ayush-panta commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description of changes: At build time, absolute paths (e.g., /Applications/Finch/os/...) are baked into the Lima base YAML template. This means the binary only works when installed at that exact path.

This PR resolves paths at runtime during finch vm init. It reads the shipped template, detects the baked-in root, replaces it with the actual install location, and writes a resolved copy to lima/data/_config/base.yaml. Lima reads that instead of the original template. The shipped artifact is never modified.

This enables finch to run from any install location without a separate build.

Testing done: Added unit tests and verified rewrite behavior. Here is an example moving to userspace:

ayushkp@842f5776e312 finch % cp -R _output /tmp/finch-userspace
ayushkp@842f5776e312 finch % cd /tmp/finch-userspace
ayushkp@842f5776e312 finch-userspace % ls
bin		cred-helpers	finch-cred	lima		os
config.yaml	dependencies	finch-daemon	lima-template
ayushkp@842f5776e312 finch-userspace %    /tmp/finch-userspace/bin/finch vm remove -f 2>/dev/null
ayushkp@842f5776e312 finch-userspace %    /tmp/finch-userspace/bin/finch vm init
INFO[0000] binaries directory doesn't exist
INFO[0000] Requesting root access to finish network dependency configuration
INFO[0002] sudoers file not found: open /etc/sudoers.d/finch-lima: no such file or directory
INFO[0005] Initializing and starting Finch virtual machine...
INFO[0035] Finch virtual machine started successfully
INFO[0035] Credential daemon started                     pid=9853
ayushkp@842f5776e312 finch-userspace %    grep "finch-userspace" /tmp/finch-userspace/os/base.yaml | head -3
  - location: "/private/tmp/finch-userspace/os/finch-al2023-os-image-arm64-26589989136.qcow2"
      sudo cp /private/tmp/finch-userspace/finch-daemon/finch-daemon /usr/local/bin/finch-daemon
      sudo cp /private/tmp/finch-userspace/finch-daemon/docker-credential-finch /usr/bin/docker-credential-finch
ayushkp@842f5776e312 finch-userspace %    /tmp/finch-userspace/bin/finch run --rm alpine echo "hello from moved location"
bash: line 1: cd: /tmp/finch-userspace: No such file or directory
docker.io/library/alpine:latest:                                                  resolved       |++++++++++++++++++++++++++++++++++++++|
index-sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b:    done           |++++++++++++++++++++++++++++++++++++++|
manifest-sha256:e7a1a92a5bfeee40966aea60f0796b0e7917cc35591542701834f03a68fa3d18: done           |++++++++++++++++++++++++++++++++++++++|
config-sha256:1991bd789d7184290c3cce84fd6af068b8b745e9bddf178661ce7f5ecf68135c:   done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:5de55e5ef9c033997441461efe7ba23a986db059c0bb78b38f84ee0d72b99167:    done           |++++++++++++++++++++++++++++++++++++++|
elapsed: 2.4 s                                                                    total:  4.0 Mi (1.7 MiB/s)
hello from moved location
  • I've reviewed the guidance in CONTRIBUTING.md

License Acceptance

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Signed-off-by: ayush-panta <ayushkp@amazon.com>
@ayush-panta ayush-panta marked this pull request as draft June 25, 2026 20:55
At vm init time, detect the baked-in install root from the base YAML
template and replace it with the actual install location. The resolved
copy is written to os/base.yaml, leaving the shipped template unchanged.
This allows the same binary to work from any install path.

Signed-off-by: ayush-panta <ayushkp@amazon.com>
@ayush-panta ayush-panta marked this pull request as ready for review June 25, 2026 23:26
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.

1 participant