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

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

Closed
snowjade opened this issue Sep 27, 2016 · 23 comments
Assignees

Comments

@snowjade
Copy link

  • 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 snowjade changed the title "path must be a string or Buffer" "path must be a string or Buffer" when react-native link react-native-code-push Sep 27, 2016
@richardhuaaa
Copy link
Contributor

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

@ljunb
Copy link

ljunb commented Oct 8, 2016

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.

@StevePotter
Copy link

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

@richardhuaaa
Copy link
Contributor

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

@Kennytian
Copy link

Kennytian commented Oct 21, 2016

/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. Kennytian/react-native-instabug#14.

@Silhouettes Please tell me what to fix this issue

@robclouth
Copy link

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

@matrosov-nikita
Copy link

@snowjade, @ljunb, @StevePotter, it seems that Info.plist and AppDelegate.m aren't in the same folder.
I've sent PR (#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?

@Ge-yuan-jun
Copy link

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

@matrosov-nikita
Copy link

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

@Ge-yuan-jun
Copy link

@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
Copy link

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

@vladimir-kotikov
Copy link

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

@Jacse
Copy link

Jacse commented May 10, 2017

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

@max-mironov
Copy link
Contributor

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

@Jacse
Copy link

Jacse commented May 10, 2017

@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
Copy link

Jacse commented May 10, 2017

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

@max-mironov
Copy link
Contributor

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

@ngxiaoyi
Copy link

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"'

@max-mironov
Copy link
Contributor

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

@Jacse
Copy link

Jacse commented May 17, 2017

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

@max-mironov
Copy link
Contributor

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

max-mironov pushed a commit to max-mironov/react-native-code-push that referenced this issue May 17, 2017
@max-mironov
Copy link
Contributor

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

@Jacse
Copy link

Jacse commented May 23, 2017

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

max-mironov pushed a commit that referenced this issue May 23, 2017
sergey-akhalkov pushed a commit that referenced this issue Jun 1, 2017
… build (#861)

* Fixed issue with error on parsing plist path

See #534 (comment) for details

* Fixed issue with [Android] restartApp() throwing exception w/ release build

#847

* Changed return value to null for getUpdateMetadata instead of empty string

In accordance with docs and #862

* Code refactoring: moved variable assignment out of loop
sergey-akhalkov pushed a commit that referenced this issue Jun 1, 2017
* Fixed issue with error on parsing plist path

See #534 (comment) for details

* Changed return value to null for getUpdateMetadata instead of empty string

In accordance with docs and #862
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests