React-native-code-push: "path must be a string or Buffer" when react-native link react-native-code-push

Created on 27 Sep 2016  路  23Comments  路  Source: microsoft/react-native-code-push

  • react-native-code-push version: 1.14.6-beta
  • react-native version: 0.32.1
  • iOS/Android version: ...
  • Does this repro on a simulator, or only on a physical device? ...
  • Repro steps:

`Xiang-mbp:example-seller-app Xiang$ react-native link react-native-code-push
rnpm-install info Android module react-native-code-push is already linked
rnpm-install info iOS module react-native-code-push is already linked
fs.js:640
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^

TypeError: path must be a string or Buffer
at TypeError (native)
at Object.fs.openSync (fs.js:640:18)
at Object.fs.readFileSync (fs.js:508:33)
at Object. (/Users/Xiang/AndroidStudioProjects/MajorDevelopApplication/example-seller-app/node_modules/react-native-code-push/scripts/postlink/ios/postlink.js:13:24)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
/Users/Xiang/AndroidStudioProjects/MajorDevelopApplication/example-seller-app/node_modules/react-native/local-cli/rnpm/core/src/makeCommand.js:19
throw new Error(Error occured during executing "${ command }" command);
^

Error: Error occured during executing "node node_modules/react-native-code-push/scripts/postlink/run" command
at ChildProcess.prelink (/Users/Xiang/AndroidStudioProjects/MajorDevelopApplication/example-seller-app/node_modules/react-native/local-cli/rnpm/core/src/makeCommand.js:19:15)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:852:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
Xiang-mbp:example-seller-app Xiang$
`

All 23 comments

@StevePotter just tagging you on this issue (which is the same as #539) so that you can track it here! We are currently swamped, but I'll try to get onto this next week.

I got the same issue when I run 'rnpm link react-native-code-push'. My ReactNative is 0.25.0, and CodePush is 1.11.0-beta.

Thanks. It's a minor thing considering it was basically a noop.

@StevePotter, @ljunb, @snowjade - I'm investigating this now and would love any information you could give about your setup. What is happening is that the linking script is looking for an Info.plist in the same directory as your AppDelegate.m, and failing. Do you happen to have multiple AppDelegate.m files, or anything else unusual about your setup?

For reference, here is the offending code:

var appDelegatePath = glob.sync("**/AppDelegate.m", ignoreNodeModules)[0];
// Glob only allows foward slashes in patterns: https://www.npmjs.com/package/glob#windows
var plistPath = glob.sync(path.join(path.dirname(appDelegatePath), "*Info.plist").replace(/\\/g, "/"), ignoreNodeModules)[0];

var appDelegateContents = fs.readFileSync(appDelegatePath, "utf8");
var plistContents = fs.readFileSync(plistPath, "utf8");

/node_modules/react-native/local-cli/core/makeCommand.js:19
throw new Error(Error occured during executing "${ command }" command);

I'm a react native npm package author, also issue. https://github.com/Kennytian/react-native-instabug/issues/14.

@silhouettes Please tell me what to fix this issue

I'm having the same problem, and it's because my AppDelegate is a .mm file not .m, due it using some C++ stuff.

@snowjade, @ljunb, @StevePotter, it seems that Info.plist and AppDelegate.m aren't in the same folder.
I've sent PR (https://github.com/Microsoft/react-native-code-push/pull/639), that improves searching for Info.plist and AppDelegate.
@robclouth, also this PR adds opportunity to work with AppDelegate.mm files.
Guys, could you please check whether it works for you?

@silhouettes Do CodePush need the ios folder ? I find the AppDelegate.m file is only in the ios folder. But my app is integrated with Android, so I cannot use codePush? Appreciate your reply~

Hi, @Ge-yuan-jun, I've sent PR which fixes this issue. Could you pls check whether it works for you?

@matrosov-nikita Hi, I have tried your pr. the commad do not show the path must be a string error. But, I still cannot receive new bundle from code-push, so, if it is convenient, could you please help me find out why? Here is the link. I have push all my code to Github. Thanks for your time.

@matrosov-nikita your code is great! In my React Ntive app,it works!Thanks for your time~

Closing this as the most of the edge cases mentioned above fixed in #639

I am seeing this now on react-native 0.44 and react-native-code-push 2.0.3-beta

@Jacse - that looks interesting. However I was not able to reproduce it with RN 0.44 and RNCP 2.0.3-beta.
I've initialized new RN application with rninit init testapp_rn --source [email protected]
Added plugin with npm install --save [email protected] and run react-native link react-native-code-push.

So could you please be more specific about your environment/project structure. Ideally you can share with us the minimum app where we can reproduce this case.

@max-mironov my problem is probably just an edge-case, then. I just did a manual install instead.

Side note: While doing so I noticed that the docs seem to be outdated. The instructions seem to vary from what react-native link does.

@max-mironov this is the error I run into:
````
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^

Error: ENOENT: no such file or directory, open 'C:\Users\Jacob\my-projectios\"MyProject-tvOSTestsInfo.plist"'
````

Might have to do with the double quotes.

@Jacse thanks for this, the error should be relative to double quotes in path name.
My guess is that when we parse pbxproj here we probably have INFOPLIST_FILE value in quotes.

Is it possible for you to verify this (open project.pbxproj file in editor and share with us value for INFOPLIST_FILE key). If our assumptions are correct we will prepare PR to fix this case.

Please let us know what you find out.

same as @Jacse , noticed the double quotes under the file path string in the console output errors while I tried to link some plugin.

rnpm-install info Android module react-native-code-push is already linked
rnpm-install info iOS module react-native-code-push is already linked
fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/Users/royshen/workspace/statistics/statistics/ios/"statistics-tvOSTests/Info.plist"'

@ngxiaoyi - got it, thanks, could you please share with us the contents of your project.pbxproj file or the value of INFOPLIST_FILE key from pbxproj?

@max-mironov Sorry I only got back with this now. My .pbxproj contains 12 values for INFOPLIST_FILE. I have them all here for you:

  1. INFOPLIST_FILE = MitLectioTests/Info.plist;
  2. INFOPLIST_FILE = MitLectioTests/Info.plist;
  3. INFOPLIST_FILE = MitLectio/Info.plist;
  4. INFOPLIST_FILE = MitLectio/Info.plist;
  5. INFOPLIST_FILE = "MitLectio-tvOS/Info.plist";
  6. INFOPLIST_FILE = "MitLectio-tvOS/Info.plist";
  7. INFOPLIST_FILE = "MitLectio-tvOSTests/Info.plist";
  8. INFOPLIST_FILE = "MitLectio-tvOSTests/Info.plist";
  9. INFOPLIST_FILE = MitLectio/Info.plist;
  10. INFOPLIST_FILE = MitLectioTests/Info.plist;
  11. INFOPLIST_FILE = "MitLectio-tvOS/Info.plist";
  12. INFOPLIST_FILE = "MitLectio-tvOSTests/Info.plist";

You can see the tvOS values have quotes.

@Jacse - thanks for this, will fix this case for link command ASAP.

@Jacse, @ngxiaoyi - I've added PR to remove quotes from plist path, please verify if it works for you.

@max-mironov I can confirm your fix works, it now links successfully.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

diegocouto picture diegocouto  路  4Comments

sergey-akhalkov picture sergey-akhalkov  路  4Comments

vira-khdr picture vira-khdr  路  3Comments

jaysig picture jaysig  路  3Comments

panarasi picture panarasi  路  4Comments