Skip to content

fix: add support for resolving Viro Android path in workspace environments#493

Open
busybox11 wants to merge 1 commit into
ReactVision:developfrom
busybox11:fix/android-resolve-root
Open

fix: add support for resolving Viro Android path in workspace environments#493
busybox11 wants to merge 1 commit into
ReactVision:developfrom
busybox11:fix/android-resolve-root

Conversation

@busybox11

@busybox11 busybox11 commented Jul 7, 2026

Copy link
Copy Markdown

Summary

Currently, Viro's Expo config plugin hardcodes ../node_modules/@reactvision/react-viro/android/... when writing the Android project paths into settings.gradle. This assumes react-viro is installed in the app's own node_modules.

In a monorepo (pnpm/yarn/npm/... workspace), the package is hoisted to the workspace root instead, so those paths don't exist and the Gradle build fails with:

Configuring project ':gvr_common' without an existing directory is not allowed.
The configured projectDirectory '.../apps/<app>/node_modules/@reactvision/react-viro/android/gvr_common' does not exist

What changed

I have added support for resolving react-viro's real install location instead of assuming it's app-local.

withViroSettingsGradle now uses require.resolve("@reactvision/react-viro/package.json", { paths: [projectRoot] }) and emits the path relative to the Android project root.

If resolution fails it falls back to the original ../node_modules/... string, so nothing changes for flat installs.

Why this is helpful

  • Fixes prebuild/build for anyone using Viro inside a monorepo with hoisted dependencies.
  • No behavior change for standard (non-workspace) projects — the resolved path collapses back to ../node_modules/@reactvision/react-viro/android.

Testing

  • tsc --noEmit passes.
  • Flat install → resolves to ../node_modules/@reactvision/react-viro/android (unchanged).
  • pnpm monorepo → resolves to the hoisted root path, and the target directories exist.

This PR was made against develop to make sure that there wasn't already a fix in the works. Can reopen against main instead, feel free to let me know if this is necessary.

@busybox11 busybox11 force-pushed the fix/android-resolve-root branch from bd46157 to b847384 Compare July 7, 2026 18:47
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.

1 participant