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

Npx/Node detection is needed #628

Closed
1 of 2 tasks
ospfranco opened this issue Sep 11, 2024 · 5 comments
Closed
1 of 2 tasks

Npx/Node detection is needed #628

ospfranco opened this issue Sep 11, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@ospfranco
Copy link

Description

Just tried creating a new library using:

 npx create-react-native-library@latest blah

When I try to run the example app on Xcode the codegen step fails:

GXE6-39XwAA7-so

Packages

  • create-react-native-library
  • react-native-builder-bob

Selected options

C++ Turbo Module with new arch, NO backward compatibility, with Vanilla test app.

Link to repro

A new library, no change

Environment

System:
  OS: macOS 15.0
  CPU: (11) arm64 Apple M3 Pro
  Memory: 6.39 GB / 36.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.20.2
    path: ~/.local/share/mise/installs/node/18/bin/node
  Yarn:
    version: 3.6.1
    path: ~/.local/share/mise/installs/node/18/bin/yarn
  npm:
    version: 10.5.0
    path: ~/.local/share/mise/installs/node/18/bin/npm
  Watchman:
    version: 2024.06.24.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/osp/.local/share/mise/installs/ruby/3/bin/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:
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-33 | Google Play ARM 64 v8a
    Android NDK: 26.1.10909125
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 16.0/16A242
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/bin/javac
  Ruby:
    version: 3.3.1
    path: /Users/osp/.local/share/mise/installs/ruby/3/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.2
    wanted: 0.75.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
@ospfranco ospfranco added the bug Something isn't working label Sep 11, 2024
@ospfranco
Copy link
Author

Found the failing pre-action. It seems you are running an npx command without locating it first.

I'm using mise which doesn't add npm/node/npx to the path, so it fails to find the npx command.

OSP 000328

@ospfranco
Copy link
Author

I have worked around this by modifying the pre-action script:

eval "$($HOME/.local/bin/mise activate -C $SRCROOT bash --shims)"

cd "$WORKSPACE_PATH/../../../" && npx bob build --target codegen

Unfortunately I cannot find a better way to make tools like mise work correctly otherwise. I've tried modifying the /etc/paths file and pointing to the correct installation but it does not work when GUI programs like Xcode or my git client Fork, start.

In order to make the node scripts work I also have to do stuff like:

sudo ln -s $(which node) /usr/local/bin

Which works because the RN scripts use this env file to locate node before running the node commands. Probably you want to also use something similar or even the same .xcode.env.local file to detect the correct paths.

OSP 000331

@ospfranco ospfranco changed the title New library does not work with vanilla app Npx/Node detection is needed Sep 11, 2024
@atlj
Copy link
Collaborator

atlj commented Sep 13, 2024

I have worked around this by modifying the pre-action script:

eval "$($HOME/.local/bin/mise activate -C $SRCROOT bash --shims)"

cd "$WORKSPACE_PATH/../../../" && npx bob build --target codegen

We would love to support such tools definitely. Do you think there is a better way that's not specific to this tool that we can use to detect node? If we want to go this route where we have commands for each specific tool, it will
a. increase script overhead for everyone
b. be harder to maintain since we now need to support all the current and future tools that require special attention

@ospfranco
Copy link
Author

I don't think there is a generic way to detect this kind of tools. I had some issues with ASDF in the past (the predecessor to mise) and I remember seeing a bunch of ifs on the react-native scripts to detect nvm, asdf, etc

@ospfranco
Copy link
Author

Going to close this. This is not an issue with builder-bob itself, but rather with how Xcode detects installed tools and environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants