nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.29k stars 2.32k forks source link

Nx Executors/Generators that use Pod Install Utility Fail #17249

Closed john-redd closed 1 year ago

john-redd commented 1 year ago

Current Behavior

As of version 16.0.0+beta5 of the @nx/react-native plugin, any executor or generator that makes use of the runPodInstall utility will fail. This utility can be found in file. This is the commit in the version 16.0.0+beta5 release that introduced this new behavior.

The reason for this behavior is that the deprecation warnings for changes to ruby ERB.new() are routed to stderr when invoking the pod install command in a child process. I am unfortunately not very familiar with Ruby and I am not exactly sure what Ruby version starts to report these deprecation warnings. I currently get this behavior with the system default installation (ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]) of ruby on my M2 Mac.

The easiest way to reproduce this issue is with the nx command for generating a new nx workspace with the react-native template.

npx create-nx-workspace happynrwl \
--preset=react-native \
--appName=mobile \
--nxCloud=false \
--verbose

This command produces the following output.

 >  NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

 >  NX   Creating your v16.2.2 workspace.

   To make sure the command works reliably in all environments, and that the preset is applied correctly,
   Nx will run "npm install" several times. Please wait.

✔ Installing dependencies with npm
✖ Creating your workspace in happynrwl

 >  NX   Failed to create a workspace.

   Exit code: 1
   Log file: /var/folders/05/r9w4s9tj1t35bkf2dv5zv5800000gn/T/tmp-73616-2NqnRGUr9UW3/error.log

I will include the mentioned log file in the failure logs section of the report.

The last two lines of the output contained in the failure logs are the deprecation warnings that are causing the command to fail.

Here is the source file. If you look at line 51, you will see a valid syntax that won't cause the error, but what is shipped in react native releases can be found here. The deprecated syntax is what is shipped. I am not 100% positive at what point in the deployment cycle of react-native this occurs, but I am assuming it is done for some level of backwards compatibility for versions 2.6 & 2.7 of ruby.

Expected Behavior

This command should properly generate a react native workspace.

GitHub Repo

No response

Steps to Reproduce

  1. Run workspace generate command with react native template
  2. See failed command

Nx Report

nx report

 >  NX   Report complete - copy this into the issue template

   Node   : 16.19.0
   OS     : darwin arm64
   npm    : 8.19.3
   Hasher : Native

   nx                 : 16.2.2
   @nx/js             : 16.2.2
   @nx/jest           : 16.2.2
   @nx/linter         : 16.2.2
   @nx/workspace      : 16.2.2
   @nx/detox          : 16.2.2
   @nx/devkit         : 16.2.2
   @nx/eslint-plugin  : 16.2.2
   @nx/react          : 16.2.2
   @nx/react-native   : 16.2.2
   @nrwl/tao          : 16.2.2
   @nx/web            : 16.2.2
   typescript         : 5.0.4

Failure Logs

added 574 packages, and audited 575 packages in 3s

76 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

>  NX  Generating @nx/workspace:preset

Fetching prettier...
CREATE apps/mobile/.ruby-version
CREATE apps/mobile/Gemfile
CREATE apps/mobile/android/app/build.gradle
CREATE apps/mobile/android/app/debug.keystore
CREATE apps/mobile/android/app/proguard-rules.pro
CREATE apps/mobile/android/app/src/androidTest/java/com/mobile/DetoxTest.java
CREATE apps/mobile/android/app/src/debug/AndroidManifest.xml
CREATE apps/mobile/android/app/src/debug/java/com/mobile/ReactNativeFlipper.java
CREATE apps/mobile/android/app/src/main/AndroidManifest.xml
CREATE apps/mobile/android/app/src/main/java/com/mobile/MainActivity.java
CREATE apps/mobile/android/app/src/main/java/com/mobile/MainApplication.java
CREATE apps/mobile/android/app/src/main/res/drawable/rn_edit_text_material.xml
CREATE apps/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
CREATE apps/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
CREATE apps/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
CREATE apps/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
CREATE apps/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
CREATE apps/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
CREATE apps/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
CREATE apps/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
CREATE apps/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
CREATE apps/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
CREATE apps/mobile/android/app/src/main/res/values/strings.xml
CREATE apps/mobile/android/app/src/main/res/values/styles.xml
CREATE apps/mobile/android/app/src/main/res/xml/network_security_config.xml
CREATE apps/mobile/android/app/src/release/java/com/mobile/ReactNativeFlipper.java
CREATE apps/mobile/android/build.gradle
CREATE apps/mobile/android/gradle/wrapper/gradle-wrapper.jar
CREATE apps/mobile/android/gradle/wrapper/gradle-wrapper.properties
CREATE apps/mobile/android/gradle.properties
CREATE apps/mobile/android/gradlew.bat
CREATE apps/mobile/android/gradlew
CREATE apps/mobile/android/settings.gradle
CREATE apps/mobile/app.json
CREATE apps/mobile/babel.config.json
CREATE apps/mobile/ios/.xcode.env
CREATE apps/mobile/ios/Podfile
CREATE apps/mobile/ios/Mobile/AppDelegate.h
CREATE apps/mobile/ios/Mobile/AppDelegate.mm
CREATE apps/mobile/ios/Mobile/Images.xcassets/AppIcon.appiconset/Contents.json
CREATE apps/mobile/ios/Mobile/Images.xcassets/Contents.json
CREATE apps/mobile/ios/Mobile/Info.plist
CREATE apps/mobile/ios/Mobile/LaunchScreen.storyboard
CREATE apps/mobile/ios/Mobile/main.m
CREATE apps/mobile/ios/Mobile.xcodeproj/project.pbxproj
CREATE apps/mobile/ios/Mobile.xcodeproj/xcshareddata/xcschemes/Mobile.xcscheme
CREATE apps/mobile/ios/Mobile.xcworkspace/contents.xcworkspacedata
CREATE apps/mobile/ios/MobileTests/Info.plist
CREATE apps/mobile/ios/MobileTests/MobileTests.m
CREATE apps/mobile/metro.config.js
CREATE apps/mobile/package.json
CREATE apps/mobile/src/app/App.spec.tsx
CREATE apps/mobile/src/app/App.tsx
CREATE apps/mobile/src/main.tsx
CREATE apps/mobile/test-setup.ts
CREATE apps/mobile/tsconfig.app.json
CREATE apps/mobile/tsconfig.json
CREATE apps/mobile/project.json
UPDATE .gitignore
CREATE babel.config.json
UPDATE nx.json
CREATE tsconfig.base.json
CREATE .prettierrc
CREATE .prettierignore
UPDATE .vscode/extensions.json
UPDATE package.json
CREATE jest.preset.js
CREATE jest.config.ts
CREATE .eslintrc.json
CREATE .eslintignore
CREATE apps/mobile/.eslintrc.json
CREATE apps/mobile/jest.config.ts
CREATE apps/mobile/tsconfig.spec.json
CREATE apps/mobile-e2e/.babelrc
CREATE apps/mobile-e2e/.detoxrc.json
CREATE apps/mobile-e2e/jest.config.json
CREATE apps/mobile-e2e/src/app.spec.ts
CREATE apps/mobile-e2e/test-setup.ts
CREATE apps/mobile-e2e/tsconfig.e2e.json
CREATE apps/mobile-e2e/tsconfig.json
CREATE apps/mobile-e2e/project.json
CREATE apps/mobile-e2e/.eslintrc.json

added 850 packages, changed 1 package, and audited 1425 packages in 11s

173 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
creating symlinks for apps/mobile
Running `pod install` from "/Users/johnredd/covr/nx-react-native/happynrwl/apps/mobile/ios"
Auto-linking React Native module for target `Mobile`: RNSVG
Framework build type is static library
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
[Codegen] Found FBReactNativeSpec
Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`
Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
Fetching podspec for `hermes-engine` from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`
Downloading dependencies
Installing CocoaAsyncSocket (7.6.5)
Installing DoubleConversion (1.1.6)
Installing FBLazyVector (0.71.8)
Installing FBReactNativeSpec (0.71.8)
Installing Flipper (0.125.0)
Installing Flipper-Boost-iOSX (1.76.0.1.11)
Installing Flipper-DoubleConversion (3.2.0.1)
Installing Flipper-Fmt (7.1.7)
Installing Flipper-Folly (2.6.10)
Installing Flipper-Glog (0.5.0.5)
Installing Flipper-PeerTalk (0.0.4)
Installing Flipper-RSocket (1.4.3)
Installing FlipperKit (0.125.0)
Installing OpenSSL-Universal (1.1.1100)
Installing RCT-Folly (2021.07.22.00)
Installing RCTRequired (0.71.8)
Installing RCTTypeSafety (0.71.8)
Installing RNSVG (13.9.0)
Installing React (0.71.8)
Installing React-Codegen (0.71.8)
Installing React-Core (0.71.8)
Installing React-CoreModules (0.71.8)
Installing React-RCTActionSheet (0.71.8)
Installing React-RCTAnimation (0.71.8)
Installing React-RCTAppDelegate (0.71.8)
Installing React-RCTBlob (0.71.8)
Installing React-RCTImage (0.71.8)
Installing React-RCTLinking (0.71.8)
Installing React-RCTNetwork (0.71.8)
Installing React-RCTSettings (0.71.8)
Installing React-RCTText (0.71.8)
Installing React-RCTVibration (0.71.8)
Installing React-callinvoker (0.71.8)
Installing React-cxxreact (0.71.8)
Installing React-hermes (0.71.8)
Installing React-jsi (0.71.8)
Installing React-jsiexecutor (0.71.8)
Installing React-jsinspector (0.71.8)
Installing React-logger (0.71.8)
Installing React-perflogger (0.71.8)
Installing React-runtimeexecutor (0.71.8)
Installing ReactCommon (0.71.8)
Installing SocketRocket (0.6.0)
Installing Yoga (1.14.0)
Installing YogaKit (1.18.1)
Installing boost (1.76.0)
Installing fmt (6.2.1)
Installing glog (0.3.5)
Installing hermes-engine (0.71.8)
Installing libevent (2.1.12)
Generating Pods project
Setting REACT_NATIVE build settings
Setting CLANG_CXX_LANGUAGE_STANDARD to c++17 on /Users/johnredd/covr/nx-react-native/happynrwl/apps/mobile/ios/Mobile.xcodeproj
Pod install took 10 [s] to run
Integrating client project
Pod installation complete! There are 60 dependencies from the Podfile and 50 total pods installed.

 >  NX   

   Running pod install failed, see above.
   Do you have CocoaPods (https://cocoapods.org/) installed?

   Check that your XCode path is correct:
   sudo xcode-select --print-path

   If the path is wrong, switch the path: (your path may be different)
   sudo xcode-select --switch /Applications/Xcode.app

   Pass --verbose to see the stacktrace.

 >  NX   Workspace creation failed, see above.

Error: Workspace creation failed, see above.
    at ChildProcess.<anonymous> (/private/var/folders/05/r9w4s9tj1t35bkf2dv5zv5800000gn/T/tmp-73616-2NqnRGUr9UW3/node_modules/@nx/workspace/src/generators/new/generate-preset.js:44:24)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)

npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
/Users/johnredd/covr/nx-react-native/happynrwl/node_modules/react-native/scripts/react_native_pods_utils/script_phases.rb:51: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.
/Users/johnredd/covr/nx-react-native/happynrwl/node_modules/react-native/scripts/react_native_pods_utils/script_phases.rb:51: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.

Operating System

Additional Information

Until this is fixed, you can use one of the following workaround.

Option One

To suppress the deprecation warnings produced by the child process that invokes pod install you can the following line to your shell profile (eg: .zshrc, .bashrc, etc)

export RUBYOPT=-W0

Once again I am not very familiar with the ruby ecosystem, but I believe that this will suppress all warnings, not just deprecation warnings, so for those that do ruby development, this is probably not the greatest behavior.

Option Two

You can use the same environment variable, just at the command/process level like so.

RUBYOPT=-W0 nx run-ios mobile

or

RUBYOPT=-W0 npx create-nx-workspace happynrwl \ --preset=react-native \ --appName=mobile \ --nxCloud=false \ --verbose

This probably the preferred workaround for those who do ruby development and don't want to globally suppress their warnings.

Proposed Solutions

I am happy to help out with a long term fix, but would like to know the preferred direction of the Nx team. I am currently seeing three options as of right now.

  1. Revert the change implemented in the commit referenced above.
  2. Move warnings produced by the child process that invokes pod install to stdout instead of stderr.
  3. Provide a option to all commands that make use of the runPodInstall utility (app generator, run-ios, and possibly others. I haven't checked this in depth yet) that allows for suppressing of ruby warnings via the RUBYOPT=-W0 environment variable being set in the child process.

I believe that one of these three is the best solution for because this issue has the mentioned instance that comes directly from the react-native source, and getting a fix upstream in that source could probably take a while, especially if the use of the deprecated syntax is in fact a backwards compatibility effort.

xiongemi commented 1 year ago

should be fixed in pr https://github.com/nrwl/nx/pull/17382 should be in the next release 16.4.0

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.