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

react-native link @react-native-community/async-storage fails #273

Closed
patrice4github opened this issue Mar 27, 2019 · 42 comments · Fixed by #321
Closed

react-native link @react-native-community/async-storage fails #273

patrice4github opened this issue Mar 27, 2019 · 42 comments · Fixed by #321
Labels
bug Something isn't working on hold

Comments

@patrice4github
Copy link

patrice4github commented Mar 27, 2019

Environment

info 
  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
      Memory: 352.69 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.12.0 - /usr/local/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.7.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5199772
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: ^16.6.3 => 16.8.5 
      react-native: ^0.59.2 => 0.59.2 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Description

The link in this new lib fails. The commands states to to log a bug:

$ react-native link @react-native-community/async-storage
info Linking "@react-native-community/async-storage" iOS dependency
error Something went wrong while linking. Error: Cannot read property 'match' of undefined 
Please file an issue here: https://github.com/react-native-community/react-native-cli/issues
error Cannot read property 'match' of undefined

Reproducible Demo

react-native link @react-native-community/async-storage

@patrice4github patrice4github added the bug Something isn't working label Mar 27, 2019
@thymikee
Copy link
Member

Can you reinstall react-native (e.g. remove from lockfile and install again) and see if that helps?

@patrice4github
Copy link
Author

Same thing after a complete clean.

@thymikee
Copy link
Member

I couldn't reproduce on a clean project. Can you set up a repo with reproduction so we can investigate?

@patrice4github
Copy link
Author

I'll have to admit, "error Something went wrong while linking." is not the greatest error message. It seems like the stack trace is eaten. Perhaps we could start by displaying the full stack trace of the fatal error message and see what object "matched" is called on.

Let me see if I can re-create it outside an my private project.

@thymikee
Copy link
Member

FYI @krizzu

@jsmmth
Copy link

jsmmth commented Mar 31, 2019

Getting the same not sure what it is, I also got it for NetInfo package and managed to get around it by basically re-doing all the pods and deleting node modules and doing a cache clean etc etc... but this time around (with async-storage) none of that seems to be doing it 🤔

React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 84.49 MB / 16.00 GB
      Shell: 5.7.1 - /usr/local/bin/zsh
    Binaries:
      Node: 11.9.0 - /usr/local/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.5.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    IDEs:
      Xcode: 10.2/10E125 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: ^0.59.2 => 0.59.2
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

@grabbou
Copy link
Member

grabbou commented Apr 1, 2019

I'll try to reproduce it and fix this. It's definitely a bug somewhere in the linking logic that might be happening due to specific structure of your project.

@patrice4github
Copy link
Author

This appears to be longer reproducible after an upgrade to 0.59.3.
I was replaced by another error after an upgrade from 0.59.2 to 0.59.3.

error Failed to get dependency config

I'm not sure if this error stops the link execution and hides the previous error.
I'm attaching the package.json of my project. I've copied the file to brand new project, created with 0.59.3 and this error no doesn't occur there.

With the CLI, are all the errors reported or the does an error fail fast?
(Is there a chance this upgrade error hides the previous one or should it be logged separately?)

Thanks.
package.json.zip

@jsmmth
Copy link

jsmmth commented Apr 2, 2019

I'll check this out tonight thanks for the update @patrice4github

@grabbou
Copy link
Member

grabbou commented Apr 3, 2019

Can't reproduce on master with any of the packages and fresh react-native init. Please provide a reproduction (ideally package your entire project w/o node_modules and send it to my at grabbou@gmail.com).

@grabbou grabbou added the on hold label Apr 3, 2019
@patrice4github
Copy link
Author

Too bad we can't reproduce it.

About this:

error Cannot read property 'match' of undefined

I think we should focus on displaying the stack trace of such error. The code crashes, knowing where would give us the cause of the error right away, pretty much. Just a suggestion.

@thymikee
Copy link
Member

thymikee commented Apr 3, 2019

Right, give me a second, I'll publish a patch with a fix for that!

@thymikee
Copy link
Member

thymikee commented Apr 3, 2019

@patrice4github please try to re-install react-native to get the cli v1.6.0, you'll be able to run with --verbose which will show the stack trace :)

@grabbou
Copy link
Member

grabbou commented Apr 3, 2019

Linking AppCenter doesn't work too. Will check

@blakek
Copy link

blakek commented Apr 5, 2019

We ran into this when upgrading react-native versions with a project name containing a dash (it worked fine before the upgrade).
For some reason, the project name was passed to the react-native CLI as project-name.xcodeproj, but the Podfile had both project and target hard-coded toprojectname. Replacing all instances of the dashed name fixed the issue for us.

@fe-linjin
Copy link

run -------- react-native link react-native-webview

error Something went wrong while linking. Error: Expected "/ Begin ", "/ End ", """, or [A-Za-z0-9_.] but "<" found.
Please file an issue here: https://github.com/react-native-community/react-native-cli/issues**

@grabbou
Copy link
Member

grabbou commented Apr 9, 2019

@codeprolin can you open your project with Xcode and then, run link again? Let me know if that helps.

@zbluephoenix
Copy link

@thymikee

@thymikee
Copy link
Member

@zbluephoenix thanks! @grabbou the error comes from findLineToAddPod function, can you investigate?

@zbluephoenix
Copy link

zbluephoenix commented Apr 12, 2019

@thymikee thank you for your reply。 I found a solution.
Add a comment to the Podfile file like this

# Add new pods below this line

屏幕快照 2019-04-12 下午9 54 53

$ react-native link react-native-gesture-handler --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
debug Package to link: react-native-gesture-handler
debug Reading /Users/jabin/CreateApplication/YYHQApp_iOS_RN/ios/Podfile
info Linking "react-native-gesture-handler" iOS dependency
debug Reading /Users/jabin/CreateApplication/YYHQApp_iOS_RN/ios/Podfile
debug Adding RNGestureHandler to Pod file"
debug Writing changes to /Users/jabin/CreateApplication/YYHQApp_iOS_RN/ios/Podfile
info iOS module "react-native-gesture-handler" has been successfully linked

@thymikee
Copy link
Member

Thanks for posting this! I can see the code is designed to expect this line which is very weird design choice. It could be named better, like "DO NOT REMOVE. THIS IS FOR CLI POD INTEGRATION TO WORK" or so. Maybe we can squeeze the change to 0.60.

@grabbou
Copy link
Member

grabbou commented Apr 16, 2019

We should definitely fix it by adding a better error message. I am going to work on it now.

@grabbou
Copy link
Member

grabbou commented Apr 16, 2019

@zbluephoenix what is the name of your .xcodeproj and what is the target XXX do line in Podfile? This is an edge case that I would like to fix.

@zbluephoenix
Copy link

platform:ios,’9.0’
inhibit_all_warnings!

targetsArray = ['YYHQApp','YYHQApp_Pro']

targetsArray.each do |t|
    target t do
    pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
    end
end

YYHQApp.xcodeproj

@grabbou

@grabbou
Copy link
Member

grabbou commented Apr 17, 2019 via email

@berdyshev
Copy link

berdyshev commented May 3, 2019

I'm getting this error while trying to link custom fonts directory with
react-native link ./src/resources/fonts (EDIT from maintainers: this is wrong usage of link. See #273 (comment))

→ react-native link ./src/resources/fonts --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
debug Package to link: ./src/resources/fonts
error Failed to get dependency config
debug Error: Failed to get dependency config
    at getDependencyConfig (native/node_modules/@react-native-community/cli/build/commands/link/getDependencyConfig.js:49:11)
    at Object.link [as func] (/native/node_modules/@react-native-community/cli/build/commands/link/link.js:97:61)
    at Promise.resolve.then (native/node_modules/@react-native-community/cli/build/cliEntry.js:152:22)
    at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:52:5)
    at Function.Module.runMain (internal/modules/cjs/loader.js:880:11)
    at internal/main/run_main_module.js:21:11

Note: we are using lerna and RN project is under the native subdirectory


react-native-cli: 2.0.1
react-native: 0.59.5

@thymikee
Copy link
Member

thymikee commented May 6, 2019

@berdyshev this is not a valid way to use link. You can only pass a valid RN module, like react-native link react-native-config. If you want to link assets, you'll need to use "rnpm" field for now, like:

"rnpm": {
  "assets": [
    "./src/resources/fonts",
  ]
}

@berdyshev
Copy link

@thymikee ok, thank you. should I run any command after that? Or just restart the react-native's packager?

@thymikee
Copy link
Member

thymikee commented May 6, 2019

Yes, you need to run react-native link after that to make linking happen

@devproivansurzhenko
Copy link

@thymikee I have pretty same issue as @berdyshev even if react-native link in action

i-surzhenko:SLM ivan.surzhenko$ react-native link --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
debug No package name provided, will attemp to link all possible packages.
warn Running `react-native link` without package name is deprecated and will be removed in next release. If you use this command to link your project assets, please let us know about your use case here: https://goo.gl/RKTeoc
error Failed to get dependency config
debug Error: Failed to get dependency config
    at getDependencyConfig (/Users/ivan.surzhenko/prj/SLM/node_modules/@react-native-community/cli/build/commands/link/getDependencyConfig.js:49:11)
    at dependencies.map.dependnecy (/Users/ivan.surzhenko/prj/SLM/node_modules/@react-native-community/cli/build/commands/link/linkAll.js:55:96)
    at Array.map (<anonymous>)
    at linkAll (/Users/ivan.surzhenko/prj/SLM/node_modules/@react-native-community/cli/build/commands/link/linkAll.js:55:45)
    at Object.link [as func] (/Users/ivan.surzhenko/prj/SLM/node_modules/@react-native-community/cli/build/commands/link/link.js:90:33)
    at Promise.resolve.then (/Users/ivan.surzhenko/prj/SLM/node_modules/@react-native-community/cli/build/cliEntry.js:152:22)
    at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:47:5)
    at Function.Module.runMain (internal/modules/cjs/loader.js:865:11)
    at internal/main/run_main_module.js:21:11

@devproivansurzhenko
Copy link

@berdyshev I have found a workaround. react-native-asset module ( https://www.npmjs.com/package/react-native-asset ) made the deal!

@marimendes
Copy link

The same here:

debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
debug Package to link: react-native-gesture-handler
error Failed to get dependency config
debug Error: Failed to get dependency config
    at getDependencyConfig (/home/marimendes/radop-app/node_modules/@react-native-community/cli/build/commands/link/getDependencyConfig.js:49:11)
    at Object.link [as func] (/home/marimendes/radop-app/node_modules/@react-native-community/cli/build/commands/link/link.js:97:61)
    at Promise.resolve.then (/home/marimendes/radop-app/node_modules/@react-native-community/cli/build/cliEntry.js:152:22)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

@awesomeo99
Copy link

awesomeo99 commented May 17, 2019

Yes, you need to run react-native link after that to make linking happen

I am having the same problem while installing fonts. I tried react-native-asset as suggested by @devproivansurzhenko and the fonts were still not installed.

@thymikee I followed your steps to install fonts and added
"rnpm": {
"assets": [
"./assets/fonts"
]
}

but still see same error upon react-native link
error Failed to get dependency config.

@grabbou
Copy link
Member

grabbou commented May 20, 2019

It would be great if you provided a source code somewhere (can be via private Github invitation) so we could look into that and fix it.

It's hard to debug locally w/o reproduction.

@devproivansurzhenko
Copy link

@awesomeo99 did you receive any error at react-native-asset run?

@devproivansurzhenko
Copy link

Interesting... created an RN app from scratch. react-native link works fine.

@Eyesonly88
Copy link

Eyesonly88 commented May 21, 2019

Workaround: doing react-native link works but doing react-native link ./assets/fonts (EDIT from maintainers: this is wrong usage of link. See #273 (comment)) gives the dependecy error. The downside of doing not specific link is that it will try and link all your dependencies.

react-native link ./assets/fonts --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
debug Package to link: ./assets/fonts
error Failed to get dependency config
debug Error: Failed to get dependency config
    at getDependencyConfig (/Users/juanpabloproverbio/Desktop/Software/mo/mobilityos-passenger-app/node_modules/@react-native-community/cli/build/commands/link/getDependencyConfig.js:49:11)
    at Object.link [as func] (/Users/juanpabloproverbio/Desktop/Software/mo/mobilityos-passenger-app/node_modules/@react-native-community/cli/build/commands/link/link.js:97:61)
    at Promise.resolve.then (/Users/juanpabloproverbio/Desktop/Software/mo/mobilityos-passenger-app/node_modules/@react-native-community/cli/build/cliEntry.js:152:22)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
    at Function.Module.runMain (module.js:696:11)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

Environment

  React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
      Memory: 800.01 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
      Yarn: 1.6.0 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        Build Tools: 26.0.3, 27.0.3, 28.0.2, 28.0.3
        API Levels: 21, 22, 23, 24, 25, 26, 27, 28
    IDEs:
      Android Studio: 3.4 AI-183.5429.30.34.5452501
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.5 => 0.59.5
    npmGlobalPackages:
      react-native-log-ios: 1.0.1

Package.json

...
"rnpm": {
    "assets": [
      "./assets/fonts/"
    ]
  },
...

@thymikee
Copy link
Member

Folks, using link like this: react-native link ./assets/fonts was never supported and will likely never be. Where do you get this information from? The link command accepts only an npm package name or nothing, so:

react-native link # good
react-native link react-native-config # good
react-native link @react-native-community/async-storage # good
react-native link ./some/path # bad, unsupported, it will try to use the path as npm package, that's why you get dependency error – it's not a dependency

@hardiknakrani25
Copy link

i'm getting this error while linking the async storage

>$ react-native link @react-native-community/async-storage --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
debug Package to link: @react-native-community/async-storage
error Failed to get dependency config
debug Error: Failed to get dependency config

@grabbou
Copy link
Member

grabbou commented May 21, 2019

This has been fixed in #321 and now, the error message is:

error Something went wrong while linking. Reason: We couldn't find a target to add a CocoaPods dependency. Make sure that you have a "target '<nameOfYourProject>' do" line in your Podfile. Alternatively, include "# Add new pods below this line" in a Podfile where we should add linked dependencies.

I am going to lock it.

Going to be released as a part of 0.60.

@react-native-community react-native-community locked as resolved and limited conversation to collaborators May 21, 2019
@thymikee
Copy link
Member

FYI this was fixed in the v2 of the CLI and wasn't yet ported to 1.x branch which is used by React Native 0.59. We'd be grateful for a PR to 1.x branch with the PR mentioned by @grabbou ported

@thymikee
Copy link
Member

Went ahead and ported it to 1.x: https://github.com/react-native-community/cli/releases/tag/v1.9.5. Hope it's gonna be easier to track the problem now!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working on hold
Projects
None yet
Development

Successfully merging a pull request may close this issue.