Skip to content

fix: support walking up parent directories to find Earthfile#638

Open
janishorsts wants to merge 1 commit into
mainfrom
632-earth-ls-and-earth-target-fail-from-a-subdirectory-must-cd-to-project-root
Open

fix: support walking up parent directories to find Earthfile#638
janishorsts wants to merge 1 commit into
mainfrom
632-earth-ls-and-earth-target-fail-from-a-subdirectory-must-cd-to-project-root

Conversation

@janishorsts

@janishorsts janishorsts commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Executing earth inside the internal directory, the targets are prefixed with a relative path to Earthfile.

✗ next +lint
 Init 🚀
————————————————————————————————————————————————————————————————————————————————

           buildkitd | Found buildkit daemon as podman container (earthly-buildkitd)
           buildkitd | Using a non-EarthBuild version of Buildkit is not supported.
           buildkitd |   Supported: github.com/EarthBuild/buildkit
           buildkitd |   Detected:  github.com/earthly/buildkit

 Build 🔧
————————————————————————————————————————————————————————————————————————————————

      registry-proxy | Registry proxy not supported on Podman. Falling back to tar-based outputs.
             ..+lint | --> FROM +base
             ..+lint | --> FROM +go
               ..+go | --> FROM +base
golang:1.26.4-alpine3.24 | --> Load metadata golang:1.26.4-alpine3.24 linux/arm64
             ..+code | --> FROM +base
             ..+code | --> FROM +deps
             ..+deps | --> FROM +base
             ..+deps | --> FROM +go
               ..+go | --> FROM golang:1.26.4-alpine3.24
               ..+go | [----------] 100% FROM golang:1.26.4-alpine3.24
               ..+go | *cached* --> RUN apk add --no-cache git
               ..+go | *cached* --> WORKDIR /earthly
             ..+deps | *cached* --> COPY go.mod go.sum ./
             ..+deps | *cached* --> RUN go mod download
             ..+code | *cached* --> mkdir /run
             ..+code | *cached* --> IF [ "$BUILDKIT_PROJECT" != "" ]
             ..+code | *cached* --> COPY --dir autocomplete buildcontext builder cleanup cmd config conslogging debugger docker2earth dockertar domain earthfile2llb features internal logbus logstream regproxy states slog util variables ./
             ..+code | *cached* --> COPY --dir buildkitd/buildkitd.go buildkitd/settings.go buildkitd/certificates.go buildkitd/
             ..+code | *cached* --> COPY --dir inputgraph/*.go inputgraph/testdata inputgraph/
             ..+lint | *cached* --> RUN apk add --no-cache curl
             ..+lint | *cached* --> RUN curl -sSfL --retry 7 --retry-all-errors -o /tmp/golangci-install.sh https://raw.githubusercontent.com/golangci/golangci-lint/main/install.sh && sh /tmp/golangci-install.sh -b $(go env GOPATH)/bin v$golangci_lint_version && rm /tmp/golangci-install.sh
             ..+lint | *cached* --> COPY ./.golangci.yaml .
             ..+lint | *cached* --> COPY --dir ..+code/earthly /
             ..+lint | *cached* --> mkdir /run/buildargs
             ..+lint | *cached* --> FOR $(find . -name go.mod -print0 | xargs -0 dirname)
             ..+lint | *cached* --> mkdir /run/buildargs
             ..+lint | *cached* --> expandargs cd $mod_path && go list -m -f '{{.Path}}'
             ..+lint | *cached* --> RUN echo "🧹 lint go module \"$mod_name\"" && cd $mod_path && golangci-lint run --config=/earthly/.golangci.yaml
              output | --> exporting outputs

 Push Summary ⏫ (disabled)
————————————————————————————————————————————————————————————————————————————————

To enable pushing use earthly --push

 Local Output Summary 🎁
————————————————————————————————————————————————————————————————————————————————



=========================== 🌍 Earth Build  ✅ SUCCESS ===========================

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

➖ Are we earthbuild yet?

No change in "earthly" occurrences

📈 Overall Progress

Branch Total Count
main 5342
This PR 5342
Difference +0

Keep up the great work migrating from Earthly to Earthbuild! 🚀

💡 Tips for finding more occurrences

Run locally to see detailed breakdown:

./.github/scripts/count-earthly.sh

Note that the goal is not to reach 0.
There is anticipated to be at least some occurences of earthly in the source code due to backwards compatibility with config files and language constructs.

@janishorsts janishorsts force-pushed the 632-earth-ls-and-earth-target-fail-from-a-subdirectory-must-cd-to-project-root branch from 0f06669 to 96f01e0 Compare July 2, 2026 12:55

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a mechanism to automatically resolve and rewrite Earthfile references for the root of a project by walking up the directory tree to find the nearest ancestor containing an Earthfile. It also adds comprehensive unit tests for this new behavior. The review feedback highlights a potential test flakiness issue in environments where GOTMPDIR is located within a repository containing an Earthfile at its root, and suggests a robust way to verify the resolved path.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread buildcontext/resolver_test.go Outdated
@janishorsts janishorsts force-pushed the 632-earth-ls-and-earth-target-fail-from-a-subdirectory-must-cd-to-project-root branch 2 times, most recently from f9a261e to 9ebf4bb Compare July 2, 2026 13:00
@janishorsts janishorsts force-pushed the 632-earth-ls-and-earth-target-fail-from-a-subdirectory-must-cd-to-project-root branch from 9ebf4bb to 3e1f81f Compare July 2, 2026 13:02
@janishorsts janishorsts added the ai-assisted Authored with AI assistance label Jul 3, 2026
@janishorsts janishorsts marked this pull request as ready for review July 3, 2026 08:16
@janishorsts janishorsts requested a review from a team as a code owner July 3, 2026 08:16
@janishorsts janishorsts requested review from kmannislands and removed request for a team July 3, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Authored with AI assistance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

earth ls (and earth +target) fail from a subdirectory — must cd to project root

1 participant