System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 37.18 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.10.0 - /var/folders/05/dbq77cwj3c5cl2r9c0qkh6h80000gn/T/yarn--1571277638840-0.6997444993602164/node
Yarn: 1.17.3 - /var/folders/05/dbq77cwj3c5cl2r9c0qkh6h80000gn/T/yarn--1571277638840-0.6997444993602164/yarn
npm: 6.11.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Android SDK:
API Levels: 28, 29
Build Tools: 27.0.3, 28.0.3, 29.0.0
System Images: android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 11.0/11A420a - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.1 => 0.61.1
We use react-native-unimodules, which require us to add a use_unimodules! to our Podfile, and our Podfile.lock then has entries like this:
EXTERNAL SOURCES:
appcenter:
:path: "../node_modules/appcenter/ios"
appcenter-analytics:
:path: "../node_modules/appcenter-analytics/ios"
appcenter-crashes:
:path: "../node_modules/appcenter-crashes/ios"
BVLinearGradient:
:path: "../node_modules/react-native-linear-gradient"
CodePush:
:path: "../node_modules/react-native-code-push"
DoubleConversion:
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
EXAppLoaderProvider:
:path: !ruby/object:Pathname
path: "../node_modules/expo-app-loader-provider/ios"
Running react-native run-ios then results in an error:
error unknown tag !<!ruby/object:Pathname> at line 452, column 5:
path: "../node_modules/expo-app- ...
^. Run CLI with --verbose flag for more details.
YAMLException: unknown tag !<!ruby/object:Pathname> at line 452, column 5:
path: "../node_modules/expo-app- ...
^
at generateError (/Users/osmanosman/Developer/mobile/node_modules/js-yaml/lib/js-yaml/loader.js:167:10)
at throwError (/Users/osmanosman/Developer/mobile/node_modules/js-yaml/lib/js-yaml/loader.js:173:9)
at composeNode (/Users/osmanosman/Developer/mobile/node_modules/js-yaml/lib/js-yaml/loader.js:1428:7)
at readBlockMapping (/Users/osmanosman/Developer/mobile/node_modules/js-yaml/lib/js-yaml/loader.js:1089:11)
at composeNode (/Users/osmanosman/Developer/mobile/node_modules/js-yaml/lib/js-yaml/loader.js:1359:12)
at readBlockMapping (/Users/osmanosman/Developer/mobile/node_modules/js-yaml/lib/js-yaml/loader.js:1089:11)
at composeNode (/Users/osmanosman/Developer/mobile/node_modules/js-yaml/lib/js-yaml/loader.js:1359:12)
at readBlockMapping (/Users/osmanosman/Developer/mobile/node_modules/js-yaml/lib/js-yaml/loader.js:1089:11)
at composeNode (/Users/osmanosman/Developer/mobile/node_modules/js-yaml/lib/js-yaml/loader.js:1359:12)
at readDocument (/Users/osmanosman/Developer/mobile/node_modules/js-yaml/lib/js-yaml/loader.js:1519:3)
It seems that _warnAboutPodInstall fails on checking Podfile.lock, and the entire command fails. Commenting out that line in runIOS/index.js fixes this.
Hopefully info above is enough, let me know if not. Note that this happens on 3.0.0-alpha* but not on 2.9.0m, which doesn't have that check.
It seems like this line is the culprit - https://github.com/react-native-community/cli/blob/926dcb78a3f9e8652b8a0e95d97ffd6283895b0e/packages/platform-ios/src/link-pods/getDependenciesFromPodfileLock.ts#L21
When Podfile.lock isn't a valid YAML file, js-yaml will throw an error on this check. In our case, it thinks :path: !ruby/object:Pathname is referring to a yaml key reference and can't find it, thus marking it as invalid. Seeing how ya'll only use the SPEC CHECKSUMS key for this warning, I would imagine there's a fairly simple workaround.
I do not know if Cocoapods guarantees that Podfile.lock is always a valid YAML file, so this might be a good thing to address for other cases as well.
Changed that file to
const CHECKSUM_KEY = 'SPEC CHECKSUMS';
// Previous portions of the lock file could be invalid yaml.
// Only parse parts that are valid
const tail = fileContent.split(CHECKSUM_KEY).slice(1);
const checksumTail = CHECKSUM_KEY + tail;
return Object.keys(safeLoad(checksumTail)[CHECKSUM_KEY] || {});
With a test file of
PODS:
- MyPackage (1.0.0)
EXTERNAL SOURCES:
ExternalInterface:
:path: !ruby/object:Pathname
path: "../node_modules/MyOtherPackage/ios"
SPEC CHECKSUMS:
MyPackage: 77fd5fb102a4a5eedafa2c2b0245ceb7b7c15e45
MyOtherPackage: a9bb76128853e98a9ef6d12b0c8c91debc9bc475
PODFILE CHECKSUM: a8110dc7c367fc529b8b6a1084258784444d62ec
COCOAPODS: 1.7.5
Tried to create a PR but looks like I'm getting 403 permission denied when trying to push a branch.
@Titozzz @orta can you advise here?
@Maushundb you need to create a fork. See the contributing guide.
@Maushundb, just wanted to say - great investigation here! I appreciate writing this all down including reproductions and some troubleshooting.
@Maushundb you need to create a fork. See the contributing guide.
Ah I see, yeah happy to put up a PR if yall think excluding invalid parts of the file is the right way to go about it.
Hrm yeah, the ruby yaml parser must be leaking internal state - think @Maushundb has a solid answer above
@Maushundb Thanks for this find! I just ran into this issue while I was trying to upgrade React Native from 0.59.1 to 0.61.2. How can I implement this fix into my project?
For now I'd suggest using patch-package to implement the fix to that file (in your repo it'll be babelified, but still readable) until this is fixed and released.
In case this is helpful to anyone else with this same problem, the path for me to fix this issue was
node_modules/@react-native-community/cli-platform-ios/build/link-pods/getDependenciesFromPodfileLock.js (notice it's not Typescript like the file Maushundb referenced in one of the comments above). I simply replaced the final line of the getDependenciesFromPodfileLock() which looks like this:
...
return Object.keys((0, _jsYaml().safeLoad)(fileContent)['SPEC CHECKSUMS'] || {});
with the solution provided above:
...
const { safeLoad } = require("js-yaml");
const CHECKSUM_KEY = 'SPEC CHECKSUMS';
// Previous portions of the lock file could be invalid yaml.
// Only parse parts that are valid
const tail = fileContent.split(CHECKSUM_KEY).slice(1);
const checksumTail = CHECKSUM_KEY + tail;
return Object.keys(safeLoad(checksumTail)[CHECKSUM_KEY] || {});
Not sure if this will work for most people (or anyone else), but thought I should share 馃槃
For a quick fix, you can use :
"resolutions": {
"@react-native-community/cli-platform-ios": "2.9.0"
}
in your package.json to force the version
In case this is helpful to anyone else with this same problem, the path for me to fix this issue was
node_modules/@react-native-community/cli-platform-ios/build/link-pods/getDependenciesFromPodfileLock.js(notice it's not Typescript like the file Maushundb referenced in one of the comments above). I simply replaced the final line of thegetDependenciesFromPodfileLock()which looks like this:... return Object.keys((0, _jsYaml().safeLoad)(fileContent)['SPEC CHECKSUMS'] || {});with the solution provided above:
... const { safeLoad } = require("js-yaml"); const CHECKSUM_KEY = 'SPEC CHECKSUMS'; // Previous portions of the lock file could be invalid yaml. // Only parse parts that are valid const tail = fileContent.split(CHECKSUM_KEY).slice(1); const checksumTail = CHECKSUM_KEY + tail; return Object.keys(safeLoad(checksumTail)[CHECKSUM_KEY] || {});Not sure if this will work for most people (or anyone else), but thought I should share 馃槃
Thanks.
RN 0.61
This one is ok.
@react-native-community/cli-platform-ios 3.0.0-alpha.7 is not ok
I changed this manually. I am waiting the the new package.
I am still experience same issue with version 3.0.0 :(
Are you sure you're on the right version? If you're using RN, make sure you set your resolutions in package.json so that the CLI version gets resolved correctly:
"resolutions": {
"@react-native-community/cli-platform-ios": "3.0.0"
},
Most helpful comment
PR at https://github.com/react-native-community/cli/pull/810