Skip to content

Conversation

@catsout
Copy link
Contributor

@catsout catsout commented Dec 20, 2025

No description provided.

@catsout catsout requested a review from a team as a code owner December 20, 2025 02:20
@github-actions github-actions bot added the node label Dec 20, 2025
@catsout catsout mentioned this pull request Dec 20, 2025
1 task
@catsout catsout force-pushed the yarn-berry branch 2 times, most recently from 0b79c40 to 2ad4303 Compare December 20, 2025 03:05
@github-actions github-actions bot added the CI label Dec 20, 2025
@catsout
Copy link
Contributor Author

catsout commented Dec 20, 2025

YARN_GLOBAL_FOLDER changed from /run/build/fiddle/<app>/yarn-mirror/global to /run/build/fiddle/<app>/yarn-berry

@bb010g
Copy link

bb010g commented Dec 20, 2025

Should this also generate a corepack install-compatible ${COREPACK_HOME:-${XDG_CACHE_HOME:-${HOME}/.config}/node/corepack}/v1 directory (used by corepackUtils.installVersion() which is invoked by Engine.prototype.ensurePackageManager())? It unfortunately looks like setting ${COREPACK_NPM_REGISTRY} to a file: URL will fail due to a check for http at the start of the tarball's address, at least without a local HTTP server inside the build environment, but installing package.json's specified .packageManager into Corepack's install cache (including setting up ${COREPACK_HOME}/v1/${corepack_package_manager_name}/${corepack_package_manager_reference}/.corepack) should work.

For example, for "packageManager": "yarn@4.12.0",, that'd be something like generated sources of (manually constructed for testing purposes):

[
    {
        "type": "file",
        "url": "https://repo.yarnpkg.com/4.12.0/packages/yarnpkg-cli/bin/yarn.js",
        "sha512": "f45ab632439a67f8bc759bf32ead036a1f413287b9042726b7cc4818b7b49e14e9423ba49b18f9e06ea4941c1ad062385b1d8760a8d5091a1a31e5f6219afca8",
        "dest-filename": "yarn.js",
        "dest": "flatpak-node/corepack-home/v1/yarn/4.12.0"
    },
    {
        "type": "inline",
        "contents": "{\"locator\":{\"name\":\"yarn\",\"reference\":\"4.12.0\"},\"bin\":[\"yarn\",\"yarnpkg\"],\"hash\":\"sha512.f45ab632439a67f8bc759bf32ead036a1f413287b9042726b7cc4818b7b49e14e9423ba49b18f9e06ea4941c1ad062385b1d8760a8d5091a1a31e5f6219afca8\"}",
        "dest-filename": ".corepack",
        "dest": "flatpak-node/corepack-home/v1/yarn/4.12.0"
    },
    {
        "type": "shell",
        "commands": [
            "mkdir -- \"flatpak-node/corepack-shims\"",
            "ln -sT -- \"$(command -v corepack)\" \"flatpak-node/corepack-shims/corepack\"",
            "printf 'Running: %s\\n' \"flatpak-node/corepack-shims/corepack --version\"; COREPACK_HOME=\"${PWD:?}/flatpak-node/corepack-home\" COREPACK_ENABLE_NETWORK=\"0\" PATH=\"${PWD:?}/flatpak-node/corepack-shims${PATH:+:${PATH:?}}\" corepack --version",
            "printf 'Running: %s\\n' \"flatpak-node/corepack-shims/corepack enable\"; COREPACK_HOME=\"${PWD:?}/flatpak-node/corepack-home\" COREPACK_ENABLE_NETWORK=\"0\" PATH=\"${PWD:?}/flatpak-node/corepack-shims${PATH:+:${PATH:?}}\" corepack enable"
        ]
    },
    {
        "type": "script",
        "commands": [
            "set -eu",
            "printf 'Running(flatpak-node): %s\\n' \"flatpak-node/corepack-shims/corepack install\"; COREPACK_HOME=\"${PWD:?}/flatpak-node/corepack-home\" COREPACK_ENABLE_NETWORK=\"0\" PATH=\"${PWD:?}/flatpak-node/corepack-shims${PATH:+:${PATH:?}}\" corepack install",
            "printf 'Running(flatpak-node): %s\\n' \"yarn --version\"; yarn --version",
            "printf 'Running(flatpak-node): %s\\n' \"yarn config set enableNetwork false\"; yarn config set enableNetwork false",
            "printf 'Running(flatpak-node): %s\\n' \"yarn config set enableOfflineMode true\"; yarn config set enableOfflineMode true",
            "printf 'Running(flatpak-node): %s\\n' \"yarn config set globalFolder -- '${FLATPAK_BUILDER_BUILDDIR:?}/flatpak-node/yarn-berry'\"; yarn config set globalFolder -- \"${FLATPAK_BUILDER_BUILDDIR:?}/flatpak-node/yarn-berry\"",
            "printf 'Running(flatpak-node): %s\\n' \"yarn plugin import -- '${FLATPAK_BUILDER_BUILDDIR:?}/flatpak-node/flatpak-yarn.js'\"; yarn plugin import \"${FLATPAK_BUILDER_BUILDDIR:?}/flatpak-node/flatpak-yarn.js\"",
            "printf 'Running(flatpak-node): %s\\n' \"yarn convertToZip\"; yarn convertToZip \"${FLATPAK_BUILDER_BUILDDIR:?}/flatpak-node/corepack-home/v1/yarn/4.12.0/yarn.js\""
        ],
        "dest": "flatpak-node"
    }
]

The consuming package can then include a source like:

- type: script
  commands:
  - "set -eu"
  - "printf 'Running: %s\\n' \"./flatpak-node/autogen.sh\"; ./flatpak-node/autogen.sh"

And, if using the simple build system, an initial command NOCONFIGURE=1 ./autogen.sh, to allow yarn to successfully work with ${FLATPAK_BUILDER_BUILDDIR}/flatpak-node/corepack-shims on $PATH.


I don't think yarn convertToZip should require a yarnPath argument when it's not handling Yarn1. My sample convertToZip invocation passes a Yarn2 yarnPath instead to get around this.

@catsout
Copy link
Contributor Author

catsout commented Dec 21, 2025

Maybe another pr, as it's not only for yarn berry.

@barthalion barthalion merged commit 89d7654 into flatpak:master Dec 30, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants