Skip to content

Buggy behaviour in launchDebugger.js on macOS #762

@StasD

Description

@StasD

Environment

System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
    Memory: 1.77 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.3 - /usr/local/bin/node
    Yarn: 1.19.0 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 27, 28, 29
      Build Tools: 27.0.3, 28.0.3, 29.0.2
      System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
      Android NDK: 20.0.5594570
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.1 => 0.61.1

Description

I was wondering why do I still get the message "For a better debugging experience please install Google Chrome" while I do have it installed, and the debugger was opening in Safari before I changed the default browser to Chrome...

So I found that the file
node_modules/@react-native-community/cli/build/commands/server/launchDebugger.js
was responsible for that message and I did some debugging.

I found out that you use open package to open urls in Chrome, and you correctly have 'google chrome' as the app name parameter for that package (on a mac). BUT! You check for the existence of command with such name before actually launching Chrome. And such a command ('google chrome') obviously does not exist, that's why please install Google Chrome message is displayed no matter what . So I suggest dropping the check for command existence altogether and rewriting the code similar to this:

  try {
    launchChrome(url);
  } catch {
    _cliTools().logger.info(`For a better debugging experience please install Google Chrome from: ${_chalk().default.underline.dim('https://www.google.com/chrome/')}`);
    (0, _launchDefaultBrowser.default)(url);
  } 

P.S.: Looks like nothing happens if I pass a wrong app name to 'open', it just suppresses any errors, so the fix might be not that easy.

P.P.S.: Changing from 'google chrome' to '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' in getChromeAppName function and also adding double quotes around ${commandName} in commandExistsUnixSync function seem to be enough to fix this bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions