Skip to content

[feature] Skip toolchain installation when system already has the matching version #2443

@moltar

Description

@moltar

Is your feature request related to a problem? Please describe.

When running moon docker setup inside a Docker container that already has the exact Node.js version Moon is configured to use (e.g. using an official node:20 base image), Moon still downloads and installs Node.js through proto. This is redundant — it slows down Docker builds and adds ~200 MB of bloat to the image since Node.js ends up installed twice.

The current workaround is MOON_TOOLCHAIN_FORCE_GLOBALS=node, but this is all-or-nothing — it unconditionally skips installation with no fallback. If the system binary is missing or the wrong version, commands will fail at runtime.

Describe the solution you'd like

Before downloading/installing a toolchain, Moon should check if a matching version already exists on the system PATH. If the system binary satisfies the configured version requirement, skip the proto installation and use the system binary directly.

This could work as a new option, for example:

# .moon/toolchain.yml
node:
  version: "20.0.0"
  preferSystemBinary: true  # Use system node if it matches the version

Or it could be an additional mode for MOON_TOOLCHAIN_FORCE_GLOBALS, e.g. MOON_TOOLCHAIN_FORCE_GLOBALS=node:prefer meaning "use system if available and matching, otherwise install."

Describe alternatives you've considered

  • MOON_TOOLCHAIN_FORCE_GLOBALS=node — works but has no fallback if the system binary is missing or wrong version. It also doesn't verify the version matches.
  • Pre-installing the version in proto's cache before running moon docker setup — adds unnecessary complexity to the Dockerfile.

Additional context

This is especially relevant for Docker workflows where base images already bundle the correct runtime. Avoiding a redundant download would improve build times and reduce image layer size.

Metadata

Metadata

Assignees

No one assigned

    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