react-native-code-push icon indicating copy to clipboard operation
react-native-code-push copied to clipboard

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

Open snowjade opened this issue 10 years ago • 23 comments

  • 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$ `

snowjade avatar Sep 27 '16 04:09 snowjade

@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.

richardhuaaa avatar Sep 30 '16 22:09 richardhuaaa

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.

ljunb avatar Oct 08 '16 02:10 ljunb

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

StevePotter avatar Oct 08 '16 02:10 StevePotter

@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");

richardhuaaa avatar Oct 17 '16 22:10 richardhuaaa

/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

Kennytian avatar Oct 21 '16 07:10 Kennytian

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

robclouth avatar Oct 24 '16 09:10 robclouth

@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?

matrosov-nikita avatar Dec 16 '16 11:12 matrosov-nikita

@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~

Ge-yuan-jun avatar Dec 20 '16 06:12 Ge-yuan-jun

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

matrosov-nikita avatar Dec 20 '16 14:12 matrosov-nikita

@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.

Ge-yuan-jun avatar Dec 21 '16 06:12 Ge-yuan-jun

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

Ge-yuan-jun avatar Dec 21 '16 08:12 Ge-yuan-jun

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

vladimir-kotikov avatar Dec 21 '16 13:12 vladimir-kotikov

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

Jacse avatar May 10 '17 06:05 Jacse

@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 avatar May 10 '17 11:05 max-mironov

@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.

Jacse avatar May 10 '17 16:05 Jacse

@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-project\ios\"MyProject-tvOSTests\Info.plist"'

Might have to do with the double quotes.

Jacse avatar May 10 '17 18:05 Jacse

@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.

max-mironov avatar May 11 '17 14:05 max-mironov

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 avatar May 17 '17 11:05 ngxiaoyi

@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 avatar May 17 '17 11:05 max-mironov

@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 avatar May 17 '17 12:05 Jacse