Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.76] Project with spaces in the path fail to build with CMake error: Cannot specify link libraries for target "..." which is not built by this project. #47377

Closed
alferth-gonzalez opened this issue Nov 4, 2024 · 8 comments
Labels
Resolution: Fixed A PR that fixes this issue has been merged.

Comments

@alferth-gonzalez
Copy link

alferth-gonzalez commented Nov 4, 2024

Description

I get the following error after installing react-navigation dependencies:

npm run android

> MiProyectoNavigation@0.0.1 android
> react-native run-android

info Installing the app...

> Task :app:buildCMakeDebug[arm64-v8a] FAILED
C/C++: CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:9 (add_subdirectory):
C/C++:   add_subdirectory called with incorrect number of arguments
C/C++: Call Stack (most recent call first):
C/C++:   /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:10 (add_subdirectory):
C/C++:   add_subdirectory called with incorrect number of arguments
C/C++: Call Stack (most recent call first):
C/C++:   /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:89 (target_link_libraries):
C/C++:   Cannot specify link libraries for target "react_codegen_safeareacontext"
C/C++:   which is not built by this project.
C/C++: Call Stack (most recent call first):
C/C++:   CMakeLists.txt:31 (include)
C/C++: ninja: error: rebuilding 'build.ninja': subcommand failed
90 actionable tasks: 12 executed, 78 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:buildCMakeDebug[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a'
  [0/2] Re-checking globbed directories...
  [1/2] Re-running CMake...
  -- Configuring incomplete, errors occurred!
  See also "/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a/CMakeFiles/CMakeOutput.log".
  FAILED: build.ninja
  /Users/alferthgonzalez/Library/Android/sdk/cmake/3.22.1/bin/cmake --regenerate-during-build -S"/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/default-app-setup" -B"/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a"

  C++ build system [build] failed while executing:
      /Users/alferthgonzalez/Library/Android/sdk/cmake/3.22.1/bin/ninja \
        -C \
        "/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a" \
        appmodules
    from /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app
  CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:9 (add_subdirectory):
    add_subdirectory called with incorrect number of arguments
  Call Stack (most recent call first):
    /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include)
    CMakeLists.txt:31 (include)


  CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:10 (add_subdirectory):
    add_subdirectory called with incorrect number of arguments
  Call Stack (most recent call first):
    /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include)
    CMakeLists.txt:31 (include)


  CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:89 (target_link_libraries):
    Cannot specify link libraries for target "react_codegen_safeareacontext"
    which is not built by this project.
  Call Stack (most recent call first):
    CMakeLists.txt:31 (include)


  ninja: error: rebuilding 'build.ninja': subcommand failed

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 2s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':app:buildCMakeDebug[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a' [0/2] Re-checking globbed directories... [1/2] Re-running CMake... -- Configuring incomplete, errors occurred! See also "/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a/CMakeFiles/CMakeOutput.log". FAILED: build.ninja /Users/alferthgonzalez/Library/Android/sdk/cmake/3.22.1/bin/cmake --regenerate-during-build -S"/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/default-app-setup" -B"/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a" C++ build system [build] failed while executing: /Users/alferthgonzalez/Library/Android/sdk/cmake/3.22.1/bin/ninja \ -C \ "/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a" \ appmodules from /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:9 (add_subdirectory): add_subdirectory called with incorrect number of arguments Call Stack (most recent call first): /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include) CMakeLists.txt:31 (include) CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:10 (add_subdirectory): add_subdirectory called with incorrect number of arguments Call Stack (most recent call first): /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include) CMakeLists.txt:31 (include) CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:89 (target_link_libraries): Cannot specify link libraries for target "react_codegen_safeareacontext" which is not built by this project. Call Stack (most recent call first): CMakeLists.txt:31 (include) ninja: error: rebuilding 'build.ninja': subcommand failed * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org. BUILD FAILED in 2s.
info Run CLI with --verbose flag for more details.`

Steps to reproduce

React Native Version

0.76.1

Affected Platforms

Runtime - Android

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 15.0.1
  CPU: (8) arm64 Apple M2
  Memory: 81.22 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.20.4
    path: ~/.nvm/versions/node/v18.20.4/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v18.20.4/bin/yarn
  npm:
    version: 10.7.0
    path: ~/.nvm/versions/node/v18.20.4/bin/npm
  Watchman:
    version: 2024.10.21.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/alferthgonzalez/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.0
      - iOS 18.0
      - macOS 15.0
      - tvOS 18.0
      - visionOS 2.0
      - watchOS 11.0
  Android SDK:
    API Levels:
      - "31"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 34.0.0
      - 35.0.0
    System Images:
      - android-34 | Google APIs ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12483815
  Xcode:
    version: 16.0/16A242d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 3.1.2
    path: /Users/alferthgonzalez/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.0
    wanted: 15.0.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.1
    wanted: 0.76.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

I get the following error after installing react-navigation dependencies:

npm run android

> MiProyectoNavigation@0.0.1 android
> react-native run-android

info Installing the app...

> Task :app:buildCMakeDebug[arm64-v8a] FAILED
C/C++: CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:9 (add_subdirectory):
C/C++:   add_subdirectory called with incorrect number of arguments
C/C++: Call Stack (most recent call first):
C/C++:   /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:10 (add_subdirectory):
C/C++:   add_subdirectory called with incorrect number of arguments
C/C++: Call Stack (most recent call first):
C/C++:   /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:89 (target_link_libraries):
C/C++:   Cannot specify link libraries for target "react_codegen_safeareacontext"
C/C++:   which is not built by this project.
C/C++: Call Stack (most recent call first):
C/C++:   CMakeLists.txt:31 (include)
C/C++: ninja: error: rebuilding 'build.ninja': subcommand failed
90 actionable tasks: 12 executed, 78 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:buildCMakeDebug[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a'
  [0/2] Re-checking globbed directories...
  [1/2] Re-running CMake...
  -- Configuring incomplete, errors occurred!
  See also "/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a/CMakeFiles/CMakeOutput.log".
  FAILED: build.ninja
  /Users/alferthgonzalez/Library/Android/sdk/cmake/3.22.1/bin/cmake --regenerate-during-build -S"/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/default-app-setup" -B"/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a"

  C++ build system [build] failed while executing:
      /Users/alferthgonzalez/Library/Android/sdk/cmake/3.22.1/bin/ninja \
        -C \
        "/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a" \
        appmodules
    from /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app
  CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:9 (add_subdirectory):
    add_subdirectory called with incorrect number of arguments
  Call Stack (most recent call first):
    /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include)
    CMakeLists.txt:31 (include)


  CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:10 (add_subdirectory):
    add_subdirectory called with incorrect number of arguments
  Call Stack (most recent call first):
    /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include)
    CMakeLists.txt:31 (include)


  CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:89 (target_link_libraries):
    Cannot specify link libraries for target "react_codegen_safeareacontext"
    which is not built by this project.
  Call Stack (most recent call first):
    CMakeLists.txt:31 (include)


  ninja: error: rebuilding 'build.ninja': subcommand failed

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 2s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':app:buildCMakeDebug[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a' [0/2] Re-checking globbed directories... [1/2] Re-running CMake... -- Configuring incomplete, errors occurred! See also "/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a/CMakeFiles/CMakeOutput.log". FAILED: build.ninja /Users/alferthgonzalez/Library/Android/sdk/cmake/3.22.1/bin/cmake --regenerate-during-build -S"/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/default-app-setup" -B"/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a" C++ build system [build] failed while executing: /Users/alferthgonzalez/Library/Android/sdk/cmake/3.22.1/bin/ninja \ -C \ "/Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/.cxx/Debug/4h5ta233/arm64-v8a" \ appmodules from /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:9 (add_subdirectory): add_subdirectory called with incorrect number of arguments Call Stack (most recent call first): /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include) CMakeLists.txt:31 (include) CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:10 (add_subdirectory): add_subdirectory called with incorrect number of arguments Call Stack (most recent call first): /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include) CMakeLists.txt:31 (include) CMake Error at /Users/alferthgonzalez/Desktop/React Native/MiProyectoNavigation/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:89 (target_link_libraries): Cannot specify link libraries for target "react_codegen_safeareacontext" which is not built by this project. Call Stack (most recent call first): CMakeLists.txt:31 (include) ninja: error: rebuilding 'build.ninja': subcommand failed * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org. BUILD FAILED in 2s.
info Run CLI with --verbose flag for more details.`

Reproducer

git@github.com:alferth-gonzalez/NavigationApp.git

Screenshots and Videos

No response

@react-native-bot react-native-bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Version Info labels Nov 4, 2024
@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@react-native-bot
Copy link
Collaborator

⚠️ Add or Reformat Version Info
ℹ️ We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.70.2

@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:

@react-native-bot
Copy link
Collaborator

⚠️ Add or Reformat Version Info
ℹ️ We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.70.2

@migueldaipre
Copy link
Collaborator

Your root folder contains whitespace.

Rename React Native to ReactNative instead and try again.

@cortinico
Copy link
Contributor

git@github.com:alferth-gonzalez/NavigationApp.git

This repository doesn't exists (or is not public). Can you update it @alferth-gonzalez ?

@alferth-gonzalez
Copy link
Author

git@github.com:alferth-gonzalez/NavigationApp.git

This repository doesn't exists (or is not public). Can you update it @alferth-gonzalez ?

Done, I've already put it in public.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Nov 4, 2024
@cortinico cortinico changed the title ERROR CMAKE [0.76] Project with spaces in the path fail to build with CMake error: Cannot specify link libraries for target "..." which is not built by this project. Nov 4, 2024
cortinico added a commit to cortinico/react-native that referenced this issue Nov 4, 2024
Summary:
Fixes facebook#47364
Fixes facebook#47377
Fixes facebook#37124

We're having problems is a path contains a space ' ' because when autolinking,
the `add_subdirectory()` function of CMake consider the path with space as 2 parameters.

This fixes it by properly quoting the path.

Changelog:
[Android] [Fixed] - Properly handle paths with spaces in autolinking

Differential Revision: D65434413
@cortinico
Copy link
Contributor

It turns out is a problem with having a space ' ' in your path.

The fix for this is here:

Will be shipped in 0.76.2.

In the meantime, the workaround is to don't use spaces in your full path or apply the change from the PR with patch-package

@cortinico cortinico added Resolution: PR Submitted A pull request with a fix has been provided. and removed Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Attention Issues where the author has responded to feedback. Needs: Version Info labels Nov 4, 2024
@cortinico cortinico added Resolution: Fixed A PR that fixes this issue has been merged. and removed Resolution: PR Submitted A pull request with a fix has been provided. labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Fixed A PR that fixes this issue has been merged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants