Skip to content

Issue with caching #29

@phillc

Description

@phillc

My Github workflow:

name: xxx

on: workflow_dispatch
      
jobs:
  release-desktop:
    name: xxxx
    permissions:
      contents: write
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v5

      # Install moon via proto
      - uses: moonrepo/setup-toolchain@v0
        with:
          auto-install: true

      - run: moon setup

      - working-directory: ./desktop
        run: pnpm install

I believe I must pnpm install there because I chain another github action that isn't moon aware behind this one.

my .protocols

moon = "1.39.4"

my .moon/toolchain.yml

# https://moonrepo.dev/docs/config/toolchain
$schema: './cache/schemas/toolchain.json'

node:
  version: 'latest'
  packageManager: 'pnpm'
  pnpm:
    version: 'latest'
  addEnginesConstraint: true
  dedupeOnLockfileChange: true
  inferTasksFromScripts: false

typescript: {}

rust:
  version: 'stable'
  bins: []
  components: []
  syncToolchainConfig: false
  targets: []

Probably can reproduce without the rust definition but leaving it there for completeness.

my .moon/workspace.yml

# https://moonrepo.dev/docs/config/workspace
$schema: './cache/schemas/workspace.json'

projects:
  - 'desktop'

desktop/moon.yml

layer: 'application'

toolchain:
  node: {}
  typescript: {}
  rust: {}

When I run this once, it works just fine. The setup-toolchain succeeds and reports moon installed as specified in .protocols.

This is the moon setup output:

Run moon setup
▪▪▪▪ installing proto 0.51.4
▪▪▪▪ installing node latest
▪▪▪▪ installing pnpm latest
▪▪▪▪ installing rust stable

Tasks: 0 tasks ran
 Time: 8s 876ms ❯❯❯❯ to the moon


│ SUCCESS
│ Setup 3 toolchain(s) successfully!

Strange... it installed another version of proto. Either way, the next step, pnpm install, works just fine.

But if I immediately run it again...

setup-toolchain reports Toolchain cache restored using key... and then reports install moon

run moon setup reports:

Run moon setup
  
▪▪▪▪ installing proto 0.51.4
Tasks: 0 tasks ran
 Time: 2s 828ms ❯❯❯❯ to the moon
│ SUCCESS
│ Setup 1 toolchain(s) successfully!

Strange, what happened to node, pnpm, and rust?

Next step:

Run pnpm install
Error: proto::detect::failed
  × Failed to detect an applicable version to run pnpm with. Try pinning a
  │ version with proto pin or explicitly passing the version as an argument or
  │ environment variable.
  help: Has the tool been installed?
Error: Process completed with exit code 1.

gh cache delete --all and then running again fixes it (and running again without clearing cache fails again).

Metadata

Metadata

Assignees

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