ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
11.8k stars 993 forks source link

bug: cannot upgrade @capacitor packages to latest with yarn #3200

Closed josh-m-sharpe closed 4 years ago

josh-m-sharpe commented 4 years ago

related: https://github.com/ionic-team/capacitor/issues/3188 related: https://github.com/ionic-team/capacitor/issues/3196

The unmet peer dependency was supposedly fixed with 2.2.1, but it persists when using yarn.

Ionic supports yarn.

yarn add @capacitor/core@latest @capacitor/android@latest @capacitor/ios@latest @capacitor/cli@latest

yarn add v1.22.4
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning "@ionic/angular-toolkit > copy-webpack-plugin@5.1.1" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning " > @capacitor/android@2.2.1" has incorrect peer dependency "@capacitor/core@~2.2.0".
warning " > @capacitor/ios@2.2.1" has incorrect peer dependency "@capacitor/core@~2.2.0".
error An unexpected error occurred: "expected manifest".
mhartington commented 4 years ago

@josh-m-sharpe you've opened a few issues now that are all similar but are not related to capacitor.

Testing things out in a project does not recreate your issue

$ yarn add @capacitor/{core,ios,android,cli}@latest
yarn add v1.22.4
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning " > @ionic/angular-toolkit@2.2.0" has unmet peer dependency "@angular-devkit/architect@>=0.800.0".
warning " > @ionic/angular-toolkit@2.2.0" has unmet peer dependency "@angular-devkit/core@>=8.0.0".
warning " > @ionic/angular-toolkit@2.2.0" has unmet peer dependency "@angular-devkit/schematics@>=8.0.0".
warning "@ionic/angular-toolkit > copy-webpack-plugin@5.1.1" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
[4/4] 🔨  Building fresh packages...

success Saved lockfile.
success Saved 4 new dependencies.
info Direct dependencies
├─ @capacitor/android@2.2.1
├─ @capacitor/cli@2.2.1
├─ @capacitor/core@2.2.1
└─ @capacitor/ios@2.2.1
info All dependencies
├─ @capacitor/android@2.2.1
├─ @capacitor/cli@2.2.1
├─ @capacitor/core@2.2.1
└─ @capacitor/ios@2.2.1
✨  Done in 4.27s.

Please provide more details/information.

josh-m-sharpe commented 4 years ago

@mhartington I appreciate you taking the time to actually use yarn to asses the issue.

I guess I'd disagree that the issue has nothing to do with capacitor. @jcesarmobile even said he fixed it in 2.2.1

As of this writing, it seems the steps I outlined in #3188 (for a new project) no longer result in an error, but the issue does persist in our real projects. It only happens with capacitor packages.

mhartington commented 4 years ago

Then it sounds like you need to either rebuild your lock file or debug it further. The steps I outlined were from a project updating to the latest release, and not a fresh install.

If we can't recreate it with similar situations, then maybe the issue is due to an error in your yarn setup. But it is not a capacitor specific issue.

It is an issue with your package manager.

josh-m-sharpe commented 4 years ago

Ok. It may be an issue with [our] package manager [that this community supports] and it's preventing me (and probably others) from keeping [our] packages up to date.

I've narrowed things down to a barebones package.json that contains only @capacitor and @capacitor-community packages. yarn seems fully capable of bulk updating all other sets of packages - so it still seems to indicate the problem exists somewhere within capacitor-land. I'm not sure where else you'd like me to file the issue.

If you start with this package.json

{
  "dependencies": {
    "@capacitor/android": "2.2.1",
    "@capacitor/core": "2.2.1",
    "@capacitor/ios": "2.2.1"
  },
  "devDependencies": {
    "@capacitor/cli": "2.2.1"
  }
}

Add a @capacitor-community plugin (in the case below I'm using fcm, but I've also verified the issue with firebase-crashlytics, firebase-analytics and native-audio)

 rm -rf node_modules package-lock.json yarn.lock
% yarn install
yarn install v1.22.4
warning package.json: No license field
info No lockfile found.
warning No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...

success Saved lockfile.
✨  Done in 11.90s.
% yarn add @capacitor-community/fcm@latest
yarn add v1.22.4
warning package.json: No license field
warning No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
warning No license field
success Saved 1 new dependency.
info Direct dependencies
└─ @capacitor-community/fcm@1.0.6
info All dependencies
└─ @capacitor-community/fcm@1.0.6
✨  Done in 1.65s.
%yarn add @capacitor/{core,ios,android,cli}@latest
yarn add v1.22.4
warning package.json: No license field
warning No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
error An unexpected error occurred: "expected manifest".
info If you think this is a bug, please open a bug report with the information provided in "/Users/jsharpe/testdeps/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
josh-m-sharpe commented 4 years ago

Here's another example. We've been using this fork of a crashyltics plugin for a while: https://github.com/josh-m-sharpe/capacitor-firebase-crashlytics/ - it show the same issues the cap community plugins do.

We install it directly from the repo: yarn add https://github.com/josh-m-sharpe/capacitor-firebase-crashlytics

I updated its package.json to use version numbers for capacitor instead of latest with this commit: https://github.com/josh-m-sharpe/capacitor-firebase-crashlytics/commit/33e707fa84bde79080c6797ddf466d7b2e880790

This seems to resolve the issue:

% yarn add https://github.com/josh-m-sharpe/capacitor-firebase-crashlytics.git

yarn add v1.22.4
warning package.json: No license field
warning No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...

warning No license field
success Saved 1 new dependency.
info Direct dependencies
└─ capacitor-firebase-crashlytics@0.1.0
info All dependencies
└─ capacitor-firebase-crashlytics@0.1.0
✨  Done in 2.15s.
% yarn add @capacitor/{core,ios,android,cli}@latest

yarn add v1.22.4
warning package.json: No license field
warning No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
warning No license field
warning "@capacitor/cli" is already in "devDependencies". Please remove existing entry first before adding it to "dependencies".
success Saved 4 new dependencies.
info Direct dependencies
├─ @capacitor/android@2.2.1
├─ @capacitor/cli@2.2.1
├─ @capacitor/core@2.2.1
└─ @capacitor/ios@2.2.1
info All dependencies
├─ @capacitor/android@2.2.1
├─ @capacitor/cli@2.2.1
├─ @capacitor/core@2.2.1
└─ @capacitor/ios@2.2.1
✨  Done in 1.11s.
mhartington commented 4 years ago

Ok, so the error in the yarn-error.log file would have been good information to have. That and the extra details of the community plugin.

As mentioned earlier, the error is not with capacitor and any official packages. The error is related to the community packages that list latest for the @capacitor/core version.

Closing @capacitor-community/fcm locally and installing things works fine.

But trying to run:

yarn add @capacitor/{core,ios,android,cli}@latest

Will produce the error noted above. However, changing the dep version in fcm to

  "dependencies": {
    "@capacitor/core": "^2.0.0"
  },

Will not produce the error above. The issue seems to be on the community side of things and not related to capacitor proper.

@dwieeb we should make a note of this for community plugins.

josh-m-sharpe commented 4 years ago

Thanks @mhartington - I appreciate you taking the time to dig in and assess.

ionitron-bot[bot] commented 1 year ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.