Skip to content

[Bug]: Generated Android and iOS SPM plugin paths break with external virtual store #8621

Open

Description

@sandstrom

Capacitor Version

Installed Dependencies:

@capacitor/cli: 8.5.0
@capacitor/core: 8.5.0
@capacitor/android: 8.5.0
@capacitor/ios: 8.5.0

Other API Details

pnpm: 11.20.0
Node.js: 26.6.0
OS: macOS
@capacitor/cli: 8.5.0
@capacitor/android: 8.5.0
@capacitor/ios: 8.5.0
iOS package manager: Swift Package Manager

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

capacitor update generates native plugin paths that do not exist when dependencies use a virtual store outside the project.

One way to reproduce this is pnpm's global virtual store. With enableGlobalVirtualStore: true on pnpm 11.20, or virtualStoreType: global on newer pnpm versions, the physical dependency graph is stored outside the project.

Despite this, capacitor update android generates entries similar to:

project(':capacitor-app').projectDir = new File('../../../node_modules/.pnpm/@capacitor+app@.../node_modules/@capacitor/app/android')

Likewise, capacitor update ios with Swift Package Manager generates entries similar to:

.package(
    name: "CapacitorApp",
    path: "../../../../../node_modules/.pnpm/@capacitor+app@.../node_modules/@capacitor/app"
)

Under the global virtual-store layout, the project-local node_modules/.pnpm directory does not contain these packages. Consequently, Gradle and Swift Package Manager cannot resolve the generated plugin paths.

Switching back to pnpm's project-local virtual store, reinstalling dependencies, and rerunning capacitor update produces paths that exist and allows both native projects to resolve their dependencies.

The global virtual store is one concrete case where this breaks. More generally, generated paths appear to assume that a plugin's resolved package location can always be represented inside the project's local virtual store. Other symlinked or externally located dependency layouts may expose the same assumption.

Expected Behavior

Capacitor should generate Android Gradle and iOS SPM paths that resolve to the installed plugin directories, regardless of whether the package manager stores their physical contents inside or outside the project.

The generated files could reference stable project-level package symlinks or otherwise account for the physical package location. The exact representation is less important than ensuring every generated path exists.

Project Reproduction

https://see-below.example.com

Additional Information

Reproduction Steps

  1. Create a Capacitor application using pnpm.

  2. Add Android and iOS, configuring iOS to use Swift Package Manager.

  3. Install at least one Capacitor plugin, for example @capacitor/app.

  4. Enable pnpm's global virtual store:

    # pnpm-workspace.yaml, pnpm 11.20
    enableGlobalVirtualStore: true

    On newer pnpm versions, the equivalent setting is:

    virtualStoreType: global
  5. Remove node_modules and reinstall:

    rm -rf node_modules
    pnpm install
  6. Regenerate the native dependency configuration:

    pnpm exec cap update android
    pnpm exec cap update ios
  7. Inspect android/capacitor.settings.gradle and ios/App/CapApp-SPM/Package.swift.

  8. Observe that their generated node_modules/.pnpm/... paths do not exist.

  9. Attempt to resolve or build either native project.

Additional Information

Android path generation calculates relative paths from each plugin's rootPath when writing capacitor.settings.gradle.

iOS SPM path generation similarly uses plugin.rootPath when writing CapApp-SPM/Package.swift.

A related historical report is #7081, but it was closed because no reproduction was provided and does not specifically cover pnpm's global virtual store.

Activity

  1. added theissue type on Sep 23, 2026
  2. LeoGotardo commented on Nov 24, 2026

    @LeoGotardo

    I tried to reproduce this on Linux and couldn't. In every setup below, cap add android / cap update android wrote paths into the pnpm global store (<store>/links/@capacitor/app/<version>/<hash>/node_modules/@capacitor/app), and all of those paths existed:

    pnpm Store setting Layout @capacitor/cli Node
    11.20.0 enableGlobalVirtualStore: true single app 8.6.2 22.23.3 and 26.6.0
    11.20.0 enableGlobalVirtualStore: true workspace (apps/mobile) 8.5.0 22.23.3
    12.23.0 virtualStoreType: global single app 8.5.0 22.23.3
    11.20.0 installed with the local store first, then switched to the global store and reinstalled without deleting node_modules single app 8.5.0 22.23.3

    The CLI resolves each plugin with require.resolve('<plugin>/package.json'), which follows the node_modules/@capacitor/* symlinks to their real location. It only falls back to the plain node_modules/<plugin> path when that call throws. When those symlinks point into the global store, the generated paths point there too.

    The node_modules/.pnpm/@capacitor+app@… paths in your report are exactly what cap add android writes for an app in a workspace (apps/<app>) that uses the local store. On a single machine, I could only get paths that don't exist with this sequence:

    1. Run cap add android (or cap update) with the local store. This writes ../../../node_modules/.pnpm/@capacitor+app@…/android into capacitor.settings.gradle, which the Android template doesn't gitignore, so it's usually committed with the rest of android/.
    2. In a fresh checkout, install with the global store and build without running cap update/cap sync. The paths from step 1 don't exist because node_modules/.pnpm has no @capacitor packages under the global store.
    3. Running cap update android fixes it: the paths now point into the global store and exist.

    Does that match your setup, for example a committed capacitor.settings.gradle / CapApp-SPM/Package.swift and a build or CI step that skips cap sync?

    The global store also makes the generated files machine-specific. The paths point outside the project, into the store, so they depend on where the store lives relative to the checkout. I copied the same workspace and lockfile to a second location with a different store directory, installed with --frozen-lockfile and ran cap add android. The link hash was identical, but the prefixes differed:

    machine 1: ../../../../store/v11/links/@capacitor/app/8.1.2/91fb95db…/node_modules/@capacitor/app/android
    machine 2: ../../../../../home/.local/share/pnpm/store/v11/links/@capacitor/app/8.1.2/91fb95db…/node_modules/@capacitor/app/android
    

    The file generated on machine 1 doesn't resolve on machine 2. With the local store this doesn't happen, because the paths stay inside the repository.

    One option would be for the CLI to write these paths through the project's node_modules/<plugin> symlink instead of the resolved store path, so the generated files don't depend on the store layout. I'm happy to open a PR for that if the maintainers think it's the right direction.

    If it's something else, could you run these from the app's directory and post the output?

    pnpm --version
    pnpm config get enableGlobalVirtualStore
    ls -la node_modules/@capacitor
    node -p "require.resolve('@capacitor/app/package.json')"

    It would also help to know where enableGlobalVirtualStore is set (pnpm-workspace.yaml, .npmrc or your global config) and whether the app is part of a workspace.

    I couldn't test the iOS side because I don't have a Mac. cap update ios builds the SPM plugin paths from the same resolved plugin path, though, so I'd expect it to behave the same way as Android here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    Stage

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions