这是indexloc提供的服务,不要输入任何密码
Skip to content

Add a 'dart pub cache path' command #4624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented Jul 18, 2025

Description

This adds a path subcommand to the dart pub cache command which simply prints the effective pub cache path.

This is useful for determining the cache directory in effect when building CI rules.

For instance a Github action could now be created that looks like this:

      - name: Get pub cache path
        id: pub-cache
        run: echo "dir=$(dart pub cache path)" >> $GITHUB_OUTPUT
      - name: Cache Pub dependencies
        uses: actions/cache@v4
        with:
          path: ${{ steps.pub-cache.outputs.dir }}
          key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
          restore-keys: ${{ runner.os }}-pub-

Otherwise, you have to know what the cache directory resolution scheme is on each platform, and the PUB_CACHE env var, and the path is platform specific.

It's also useful if an AI agent wants to know where the cache is.

Tests

  • Added a test.

@gspencergoog gspencergoog requested a review from natebosch July 18, 2025 18:49
@natebosch
Copy link
Member

I agree that this is worth landing. I'll let the pub team review.

@natebosch natebosch requested a review from jonasfj July 22, 2025 01:12
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.

2 participants