React-native: Watchman Error, cannot deploy to device

Created on 15 Apr 2016  路  10Comments  路  Source: facebook/react-native

I've been looking all day for a solution, and either I'm looking in the wrong places, or this error hasn't been seen yet.

I'm trying to deploy my app to my iPhone 6 (iOS 9.3) in _Release_ mode. This is my AppDelegate.m:

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import "AppDelegate.h"

#import "RCTRootView.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  /**
   * Loading JavaScript code - uncomment the one you want.
   *
   * OPTION 1
   * Load from development server. Start the server from the repository root:
   *
   * $ npm start
   *
   * To run on device, change `localhost` to the IP address of your computer
   * (you can get this by typing `ifconfig` into the terminal and selecting the
   * `inet` value under `en0:`) and make sure your computer and iOS device are
   * on the same Wi-Fi network.
   */

  //jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

  /**
   * OPTION 2
   * Load from pre-bundled file on disk. The static bundle is automatically
   * generated by the "Bundle React Native code and images" build step when
   * running the project on an actual device or running the project on the
   * simulator in the "Release" build configuration.
   */

  jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"鈼硷笌鈼硷笌鈼硷笌鈼硷笌"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

@end

It boots up fine in _Debug_ mode, but when I try to bundle it for release, the build fails and I get the following error from watchman:

[sane] Warning: Lost connection to watchman, reconnecting..
[sane] Warning: Lost connection to watchman, reconnecting..
2016-04-15T16:33:51,872: [cli] failed to identify PDU: fill_buffer: EOF
2016-04-15T16:33:51,874: [cli] unable to talk to your watchman on /usr/local/Cellar/watchman/4.4.0/var/run/watchman/%n-state/sock! (Undefined error: 0)

2016-04-15T16:33:51,873: [cli] failed to identify PDU: fill_buffer: EOF
2016-04-15T16:33:51,874: [cli] unable to talk to your watchman on /usr/local/Cellar/watchman/4.4.0/var/run/watchman/%n-state/sock! (Undefined error: 0)

Watchman:  watchman--no-pretty get-sockname returned with exit code 1 2016-04-15T16:33:51,873: [cli] failed to identify PDU: fill_buffer: EOF
2016-04-15T16:33:51,874: [cli] unable to talk to your watchman on /usr/local/Cellar/watchman/4.4.0/var/run/watchman/%n-state/sock! (Undefined error: 0)

 ERROR  watchman--no-pretty get-sockname returned with exit code 1 2016-04-15T16:33:51,873: [cli] failed to identify PDU: fill_buffer: EOF
2016-04-15T16:33:51,874: [cli] unable to talk to your watchman on /usr/local/Cellar/watchman/4.4.0/var/run/watchman/%n-state/sock! (Undefined error: 0)

Error: watchman--no-pretty get-sockname returned with exit code 1 2016-04-15T16:33:51,873: [cli] failed to identify PDU: fill_buffer: EOF
2016-04-15T16:33:51,874: [cli] unable to talk to your watchman on /usr/local/Cellar/watchman/4.4.0/var/run/watchman/%n-state/sock! (Undefined error: 0)

    at ChildProcess.<anonymous> (/Users/jonlaing/projects/Partisan/node_modules/fb-watchman/index.js:198:18)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:818:16)
    at Socket.<anonymous> (internal/child_process.js:319:11)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at Pipe._onclose (net.js:469:12)

Versions

  • OSX 10.11.4
  • Xcode 7.3
  • react-native 0.23.1
  • node 5.0
  • npm 3.3.6
  • watchman 4.4.0

I'm not all that familiar with the inner workings of all this, so any help would be greatly appreciated. Thanks for your time!

Locked

Most helpful comment

Hey did you find a solution for this? I'm getting the same problem
screen shot 2016-11-03 at 9 51 03 pm

All 10 comments

Oh, for the record, I've tried uninstalling and reinstalling watchman via homebrew, including doing it with the --HEAD parameter, and I still get the same issue.

For the record, I tried this with a completely blank react-native project, and got the same error, so it's not particular to my project.

Also, if I run watchman --no-pretty get-sockname in the terminal by itself, it seems to work just fine, which is what makes me think this is an issue with react-native and not watchman... just a guess though.

I can't exactly tell you what happened, but after trying all kinds of stuff, I eventually, in frustration tried npm install and sure enough the error is gone and I can deploy to my phone. It's always the stupidest thing right? Anyway, I'm leaving this here for posterity just in case someone like me runs into a similar problem.

This is one of those days where I really hate technology, haha.

So, after being able to deploy after a simple npm install a few days ago, I'm back to where I started. The only things that have changed in my code is that I added some Jest tests, but those shouldn't affect a release deploy to my knowledge.

Anyway, yeah, so I'm back to the same error, and back to having no idea how to fix it.

Not sure if this is at all helpful, but this is what Xcode has to say about the error:

uncaught error Error: SyntaxError: Unexpected token }
    at Object.parse (native)
    at /Users/jonlaing/projects/Partisan/node_modules/node-haste/lib/Package.js:108:23
    at run (/Users/jonlaing/projects/Partisan/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:89:22)
    at /Users/jonlaing/projects/Partisan/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:102:28
    at flush (/Users/jonlaing/projects/Partisan/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:14:5)
    at doNTCallback0 (node.js:428:9)
    at process._tickCallback (node.js:357:13)

I thought I'd chime back in. I'm able to get my app running. I had to set "Dead Code Stripping" to "No" in Xcode. Hopefully this will save someone else the nonsense of trying to figure this out.

Hey did you find a solution for this? I'm getting the same problem
screen shot 2016-11-03 at 9 51 03 pm

"Usually this happens when watchman isn't running. Create an empty .watchmanconfig file in your project's root folder or initialize a git or hg repository in your project."

@yjkimjunior tried creating a .watchmanconfig file in the project's root folder, tried creating a new project using react-native init test and initialized git inside of the project.

still getting the same lost connection warnings 馃憥

opened issue on stackoverflow: http://stackoverflow.com/questions/40414166/react-native-npm-start-with-watchman-error

Was this page helpful?
0 / 5 - 0 ratings