Cli: ENOENT error when linking fonts (RN 0.59)

Created on 13 Mar 2019  ·  4Comments  ·  Source: react-native-community/cli

Environment

info
  React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
      Memory: 94.71 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.15.1 - /usr/local/bin/node
      Yarn: 1.13.0 - /usr/local/bin/yarn
      npm: 6.4.1 - /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
      Android SDK:
        API Levels: 27, 28
        Build Tools: 28.0.3
        System Images: android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5264788
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.0 => 0.59.0

Description

Linking font assets causes an ENOENT. Worked fine in RN 0.58

❯❯❯ react-native link
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
info Linking assets to ios project
info Linking assets to android project
error Something went wrong while linking. Error: ENOENT: no such file or directory, copyfile '/Users/tallpants/Projects/somernapp/assets/fonts/FrankRuhlLibre-Black.ttf' -> '/Users/tallpants/Projects/somernapp/android/app/src/main/assets/fonts/FrankRuhlLibre-Black.ttf'
Please file an issue here: https://github.com/react-native-community/react-native-cli/issues
error ENOENT: no such file or directory, copyfile '/Users/tallpants/Projects/somernapp/assets/fonts/FrankRuhlLibre-Black.ttf' -> '/Users/tallpants/Projects/somernapp/android/app/src/main/assets/fonts/FrankRuhlLibre-Black.ttf'

Reproducible Demo

  • react-native init a new project.
  • Create an assets directory in the root, and a fonts directory inside that with some fonts:
projectroot/
    assets/
        fonts/
            FrankRuhlLibre-Black.ttf
            FrankRuhlLibre-Bold.ttf
            // ...
  • Add this as a top-level key in package.json:
  "rnpm": {
    "assets": [
      "./assets/fonts/"
    ]
  },
  • Run react-native link
bug

Most helpful comment

problem still exists

All 4 comments

Some more information: I got around it for now by manually copying the fonts to android/app/src/main/assets/fonts. Running react-native link again after copying it manually doesn't throw any errors.

❯❯❯ react-native link
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
info Linking assets to ios project
info Linking assets to android project
info Assets have been successfully linked to your project

Creating the android/app/src/main/assets/fonts folder manually will allow linking to function correctly. It looks like we just need to verify the whole tree exists before copying

231 is fixing that regression. I'd appreciate verifying that :)

problem still exists

Was this page helpful?
0 / 5 - 0 ratings