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

run-ios command ignores the verbose option #1391

Closed
liamjones opened this issue Apr 4, 2021 · 10 comments · Fixed by #1946
Closed

run-ios command ignores the verbose option #1391

liamjones opened this issue Apr 4, 2021 · 10 comments · Fixed by #1946
Labels
bug report bug Something isn't working command: run-ios no-stale-bot This issue cannot be marked as stale by stale bot

Comments

@liamjones
Copy link
Contributor

liamjones commented Apr 4, 2021

Environment

info Fetching system and libraries information...
System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 1.47 GB / 16.00 GB
    Shell: 5.8 - /usr/local/bin/zsh
  Binaries:
    Node: 10.24.0 - /var/folders/h6/g6rldscd6h389g9w42_7k_jm0swv2d/T/yarn--1617537855315-0.38815081056993295/node
    Yarn: 1.22.10 - /var/folders/h6/g6rldscd6h389g9w42_7k_jm0swv2d/T/yarn--1617537855315-0.38815081056993295/yarn
    npm: 6.14.11 - ~/.nvm/versions/node/v10.24.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.0 - /Users/liam.jones/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 23, 25, 26, 27, 28, 29
      Build Tools: 27.0.3, 28.0.3, 29.0.2, 29.0.3, 30.0.3, 31.0.0
      System Images: android-21 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1.3 4.1.3
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_282 - /usr/bin/javac
    Python: 3.9.2 - /usr/local/opt/python/libexec/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: 0.63.4 => 0.63.4
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Description

run-ios detects the presence of xcpretty and uses it if installed. The command-line help for the run-ios command states:

--verbose Do not use xcpretty even if installed

However, when run with the verbose option, xcpretty is still used.

I've dug into this a little, it looks like the verbose option is checked for in buildProject(), here: https://github.com/react-native-community/cli/blob/v4.14.0/packages/platform-ios/src/commands/runIOS/index.ts#L307

However, if I debug the command as it's running, verbose is undefined.

The issue seems to be coming from Command.prototype.opts() inside commander. Here it copies the values from properties on this (the Command) into result[key]: https://github.com/tj/commander.js/blob/v2.20.3/index.js#L779. This works for other options like packager (set via --no-packager). I can see packager, etc exist on this for the working properties but for some reason this.verbose doesn't.

I've not been able to work out why this happens yet (nor if it's a problem in the cli or commander).

I've also created a fresh RN 0.64.0 project to check the behaviour is the same (and it is).

Reproducible Demo

  1. Install xcpretty
  2. Create RN project
  3. Run run-ios and note xcpretty formatted output
  4. Run run-ios --verbose and note xcpretty formatted output is still present
@liamjones
Copy link
Contributor Author

Okay, I now understand what's going on. Essentially, with commander ^2.19.0 you cannot have the same option name on a subcommand as the parent. In this instance, both react-native and react-native run-ios have the option --verbose. react-native will essentially consume the verbose option so it's not visible to run-ios. This behaviour is changeable in v7 via the options added in this PR tj/commander.js#1427.

Potential options I can see;

  1. Upgrade commander - I'm assuming going from v2 to v7 is going to be a lot of work.
  2. Change the run-ios --verbose option to a different name so it no longer collides with react-native's --verbose option (also check there are no other option collisions on other commands)

I'm going to have a look at doing the second option as a starting point.

@liamjones
Copy link
Contributor Author

I see the project already has a workaround for this in the init command: https://github.com/react-native-community/cli/blob/master/packages/cli/src/commands/init/init.ts#L208.

Would another workaround in run-ios be preferable to option 2 above?

@grabbou
Copy link
Member

grabbou commented Jul 19, 2021

I would imagine we can pass commander.verbose

if (commander.verbose) {
logger.error(err.message);
} else {
to here
const passedOptions = this.opts();

{...passedOptions, verbose: commander.verbose()}

We have tried upgrading to a newer version, but that was quite a challenge. I would say for now, the easiest workaround is to pass it this way, or provide a utility function isVerboseMode() that would check process.argv itself, like the init workaround you have linked.

Either way, I'd be happy to accept this as a PR!

@grabbou grabbou added bug Something isn't working command: run-ios labels Jul 19, 2021
@RedMickey
Copy link

Hi, I faced a similar issue on React Native version 0.68.0-rc.2.

@liamjones
Copy link
Contributor Author

Oh, I forgot to come back to this one. I'll see about doing a PR

@github-actions
Copy link

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

@github-actions github-actions bot added the stale label Nov 26, 2022
@liamjones
Copy link
Contributor Author

Still waiting on PR #1571 to be approved and merged to fix this.

@adamTrz adamTrz removed the stale label Nov 28, 2022
@github-actions
Copy link

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

@github-actions github-actions bot added the stale label Feb 27, 2023
@liamjones
Copy link
Contributor Author

PR conversation stalled, I'll resurrect it.

@github-actions github-actions bot removed the stale label Feb 28, 2023
@github-actions
Copy link

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

@github-actions github-actions bot added the stale label May 30, 2023
@szymonrybczak szymonrybczak added no-stale-bot This issue cannot be marked as stale by stale bot and removed stale labels May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report bug Something isn't working command: run-ios no-stale-bot This issue cannot be marked as stale by stale bot
Projects
None yet
5 participants