Failing to add cordova plugin from Github

Bitrise Build Issue Report template

Description of the issue

I have an entry in my package.json file that loads a cordova plugin directly from github as the current npm release has issues. Locally this works fine but when trying to run Ionic Archive in Bitrise the step fails trying to retrieve the plugin.

package.json entry:

    "cordova-plugin-file-transfer": "github:apache/cordova-plugin-file-transfer",

Error:

Discovered plugin "cordova-plugin-file-transfer". Adding it to the project
Failed to fetch plugin github:apache/cordova-plugin-file-transfer via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
CordovaError: Error: npm: Command failed with exit code 1 Error output:

Environment:

Where did the issue happen?

Issue occurred on a bitrise.io build using XCode 13.2.X Stack, Ionic Archive 2.X.X step

Reproducibility

  • _Does a “Rebuild” help? No
  • _Does a rebuild without caches help? No
  • Does the issue happen sporadically, or every time? : Every Time
  • Does upgrading the build Step to the latest version help? : No
  • When did the issue start? : Ever since trying to add this project

Local reproduction

I do not get this error locally or when compiling using Ionic Appflow (another CI/CD option I’m looking to migrate away from)

Build log

Relevant log extract from the Ionic Archive Step:

Config:
- Platform: android
- Configuration: release
- Target: device
- BuildConfig: /var/folders/11/nh0v1jld7zd7b9zqm1774gtm0000gn/T/__bitrise-cordova-build-config__755136760/build.json
- Options: --prod --verbose
- Username: 
- Password: 
- RunPrepare: false
- IonicVersion: 
- CordovaVersion: latest
- WorkDir: /Users/vagrant/git
- DeployDir: /Users/vagrant/deploy
- AndroidAppType: aab
- UseCache: true
Js package manager used: npm
Updating cordova version to: latest
$ npm "remove" "cordova" "--force"
$ npm "install" "-g" "cordova@latest" "--force"
cordova version: 11.0.0
ionic version: 6.19.0
Building project
$ ionic "cordova" "build" "--release" "--device" "android" "--buildConfig" "/var/folders/11/nh0v1jld7zd7b9zqm1774gtm0000gn/T/__bitrise-cordova-build-config__755136760/build.json" "--prod" "--verbose" "--" "--" "--packageType=bundle"
2022-08-30T18:58:35.028Z ionic:utils-terminal:info Environment variables for CI detected: CI
2022-08-30T18:58:35.128Z ionic:lib Terminal info: { ci: true, shell: '/bin/bash', tty: false, windows: false }
2022-08-30T18:58:35.129Z ionic:lib CLI global options: { _: [ 'cordova', 'build' ], help: null, h: null, verbose: true, quiet: null, interactive: false, color: true, confirm: null, json: null, release: true, device: 'android', buildConfig: '/var/folders/11/nh0v1jld7zd7b9zqm1774gtm0000gn/T/__bitrise-cordova-build-config__755136760/build.json', prod: true, project: null, '--': [ '--', '--packageType=bundle' ] }
2022-08-30T18:58:35.397Z ionic:lib:project Project type from config: @ionic/angular (angular)
2022-08-30T18:58:35.397Z ionic:lib:project Project details: { context: 'app', type: 'angular', errors: [], configPath: '/Users/vagrant/git/ionic.config.json' }
2022-08-30T18:58:35.400Z ionic Context: { binPath: '/usr/local/lib/node_modules/@ionic/cli/bin/ionic', libPath: '/usr/local/lib/node_modules/@ionic/cli', execPath: '/Users/vagrant/git', version: '6.19.0' }
✔ Creating ./www directory for you in 729.03μs
2022-08-30T18:58:35.456Z ionic:lib:integrations:cordova:config Loading Cordova Config (config.xml: '/Users/vagrant/git/config.xml', package.json: '/Users/vagrant/git/package.json')
> cordova platform add android --save
Using cordova-fetch for cordova-android@10.1.0
Adding android project...
Creating Cordova project for the Android platform:
	Path: platforms/android
	Package: com.slatedev.[REDACTED]
	Name: Notis
	Activity: MainActivity
	Android target: android-30
Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@10.1.0
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
Discovered plugin "cordova-plugin-statusbar". Adding it to the project
Installing "cordova-plugin-statusbar" for android
Adding cordova-plugin-statusbar to package.json
Discovered plugin "cordova-plugin-device". Adding it to the project
Installing "cordova-plugin-device" for android
Adding cordova-plugin-device to package.json
Discovered plugin "cordova-plugin-splashscreen". Adding it to the project
Installing "cordova-plugin-splashscreen" for android
Adding cordova-plugin-splashscreen to package.json
Discovered plugin "cordova-plugin-ionic-webview". Adding it to the project
Installing "cordova-plugin-ionic-webview" for android
Subproject Path: CordovaLib
Subproject Path: app
Adding cordova-plugin-ionic-webview to package.json
Discovered plugin "cordova-plugin-ionic-keyboard". Adding it to the project
Installing "cordova-plugin-ionic-keyboard" for android
Adding cordova-plugin-ionic-keyboard to package.json
Discovered plugin "cordova-plugin-facebook-connect". Adding it to the project
Installing "cordova-plugin-facebook-connect" for android
Subproject Path: CordovaLib
Subproject Path: app
Adding cordova-plugin-facebook-connect to package.json
Discovered plugin "cordova-plugin-camera". Adding it to the project
Installing "cordova-plugin-camera" for android
Subproject Path: CordovaLib
Subproject Path: app
Adding cordova-plugin-camera to package.json
Discovered plugin "ionic-plugin-deeplinks". Adding it to the project
Installing "ionic-plugin-deeplinks" for android
Adding ionic-plugin-deeplinks to package.json
Discovered plugin "cordova-plugin-x-socialsharing". Adding it to the project
Installing "cordova-plugin-x-socialsharing" for android
Installing "es6-promise-plugin" for android
Subproject Path: CordovaLib
Subproject Path: app
Adding cordova-plugin-x-socialsharing to package.json
Discovered plugin "cordova-plugin-geolocation". Adding it to the project
Installing "cordova-plugin-geolocation" for android
Adding cordova-plugin-geolocation to package.json
Discovered plugin "cordova-plugin-googlemaps". Adding it to the project
Installing "cordova-plugin-googlemaps" for android
Subproject Path: CordovaLib
Subproject Path: app
      Official document https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.6.0/README.md Please consider to buy a beer for us 🍺 https://github.com/mapsplugin/cordova-plugin-googlemaps#buy-us-a-beer
    
Adding cordova-plugin-googlemaps to package.json
Discovered plugin "cordova-plugin-androidx". Adding it to the project
Installing "cordova-plugin-androidx" for android
Plugin doesn't support this project's cordova-android version. cordova-android: 10.1.0, failed version requirement: <9.0.0
Skipping 'cordova-plugin-androidx' for android
Adding cordova-plugin-androidx to package.json
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at /Users/vagrant/git/platforms/android/*-Info.plist, ignoring
Discovered plugin "cordova-plugin-androidx-adapter". Adding it to the project
Installing "cordova-plugin-androidx-adapter" for android
Adding cordova-plugin-androidx-adapter to package.json
Discovered plugin "cordova-plugin-filechooser". Adding it to the project
Installing "cordova-plugin-filechooser" for android
Adding cordova-plugin-filechooser to package.json
Discovered plugin "cordova-documentpicker". Adding it to the project
Installing "cordova-documentpicker" for android
Adding cordova-documentpicker to package.json
Discovered plugin "cordova-plugin-chooser". Adding it to the project
Installing "cordova-plugin-chooser" for android
Adding cordova-plugin-chooser to package.json
Discovered plugin "cordova-plugin-file-transfer". Adding it to the project
Failed to fetch plugin github:apache/cordova-plugin-file-transfer via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
CordovaError: Error: npm: Command failed with exit code 1 Error output:
npm WARN idealTree Removing dependencies.cordova-plugin-file-transfer in favor of devDependencies.cordova-plugin-file-transfer
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @agm/core@3.0.0-beta.0
npm ERR! Found: @angular/common@12.1.5
npm ERR! node_modules/@angular/common
npm ERR!   peer @angular/common@"^12.0.0 || ^13.0.0-0" from @angular/cdk@12.2.13
npm ERR!   node_modules/@angular/cdk
npm ERR!     peer @angular/cdk@"12.2.13" from @angular/material@12.2.13
npm ERR!     node_modules/@angular/material
npm ERR!       @angular/material@"^12.2.13" from the root project
npm ERR!     @angular/cdk@"^12.2.13" from the root project
npm ERR!   peer @angular/common@"^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0" from @angular/fire@6.1.5
npm ERR!   node_modules/@angular/fire
npm ERR!     @angular/fire@"^6.1.5" from the root project
npm ERR!   8 more (@angular/forms, @angular/material, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^9.1.0 || ^10.0.0" from @agm/core@3.0.0-beta.0
npm ERR! node_modules/@agm/core
npm ERR!   @agm/core@"^3.0.0-beta.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/common@10.2.5
npm ERR! node_modules/@angular/common
npm ERR!   peer @angular/common@"^9.1.0 || ^10.0.0" from @agm/core@3.0.0-beta.0
npm ERR!   node_modules/@agm/core
npm ERR!     @agm/core@"^3.0.0-beta.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/vagrant/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/vagrant/.npm/_logs/2022-08-30T18_58_42_962Z-debug-0.log
[ERROR] An error occurred while running subprocess cordova.
        
        cordova platform add android --save exited with exit code 1.
        
        Re-running this command with the --verbose flag may provide more information.
2022-08-30T18:58:47.504Z ionic:utils-process onBeforeExit handler: 'process.exit' received
2022-08-30T18:58:47.504Z ionic:utils-process onBeforeExit handler: running 1 functions
2022-08-30T18:58:47.540Z ionic:utils-process processExit: exiting (exit code: 1)
command failed, error: exit status 1

Based on the error it looks like the issue is this

What version of Node are you using locally?

The Xcode 13.2.x stack has Node 16 installed by default.

See: https://github.com/bitrise-io/bitrise.io/blob/master/system_reports/MACOS/INTEL/osx-xcode-13.2.x.log#L17

Node 12 is also available if required

See: https://github.com/bitrise-io/bitrise.io/blob/master/system_reports/MACOS/INTEL/osx-xcode-13.2.x.log#L199

My local test that worked was using v14.17.6
And my stack on Ionic Appflow that also worked was using v16.13.2

I tried adding “–legacy-peer-deps” to the Ionic Archive step but appeared to get the exact same result.

Comparing Ionic AppFlow to Bitrise since they are the same node version there is a difference in the command being run at the time the “cordova-plugin-file-transfer” lines that error in bitrise come up in the log:

Ionic AppFlow:

cordova platform add android --no-fetch

Bitrise:

ionic "cordova" "build" "--release" "--device" "android" "--buildConfig" "/var/folders/11/nh0v1jld7zd7b9zqm1774gtm0000gn/T/__bitrise-cordova-build-config__73168928/build.json" "--prod" "--verbose" "--legacy-peer-deps" "--" "--" "--packageType=bundle"

Assuming this is just a variation as Bitrise is combining the platform/prepare/build into a single command but thought it worth mentioning.

I think you want to add that flag to the npm install command not the ionic command

eg.

npm install --legacy-peer-deps

You can run any command you like with a Script step you do not have to use the pre-built step.

I did also add the --legacy-peer-deps to the npm install command

I tried subbing out the Ionic Archive step for a Script step running the exact same cordova platform add android --no-fetch command that works in Ionic Appflow and I get the same error as described above.

Stripping this issue back even further I reduced the script step command to simply cordova plugin add https://github.com/apache/cordova-plugin-file-transfer.git#master and got the exact same error.

So for whatever reason, the bitrise instance can’t get the plugin from github where it does work both locally and on the Ionic AppFlow stack. But I’m struggling to understand why

Still looking for advice on this error

Have you tried adding it like this instead?

"cordova-plugin-file-transfer": "git+https://github.com/apache/cordova-plugin-file-transfer",

See: How to install an npm package from GitHub directly - Stack Overflow

I tried this in both the package.json running a full ionic archive as well as the stripped back script step just running cordova plugin add and got the same error for both

"cordova-plugin-file-transfer": "git+https://github.com/apache/cordova-plugin-file-transfer",

cordova plugin add git+https://github.com/apache/cordova-plugin-file-transfer --nofetch

Can you create a simple open source example project reproducing the issue so I can take a look into this for you?

@damien.murphy - Grant Derepas / BitriseTesting · GitLab

I’ve not included the full build process or the full project files but I’ve put enough in here to reproduce the error. Using that android-debug workflow on bitrise it should get through the npm install step then error on that cordova plugin add step with the same error mentioned at the top of this thread

1 Like

I just added this app to my account and the workflow android-debug builds successfully for me.

I removed the activate ssh key step and the cache pull step since they are not required

image

Not seeing any errors.

@damien.murphy

If I try and run without the ssh key step the git clone step fails to clone the repo:

git@gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists

And with the SSH Key step but dropping the cache pull step I still get the same error adding the plugin

Here is the bitrise.yml that I am using which is building successfully

---
format_version: '11'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: ionic
workflows:
  android-debug:
    steps:
    - git-clone@6: {}
    - generate-cordova-build-configuration@0:
        inputs:
        - package_type: development
    - npm@1:
        inputs:
        - cache_local_deps: 'true'
        - command: ci
        title: npm install
    - script@1:
        inputs:
        - content: cordova plugin add git+https://github.com/apache/cordova-plugin-file-transfer
            --nofetch
    before_run: []
    meta:
      bitrise.io:
        stack: osx-xcode-13.2.x
meta:
  bitrise.io:
    stack: osx-xcode-13.2.x
    machine_type_id: g2.4core
app:
  envs:
  - opts:
      is_expand: false
    IONIC_PLATFORM: ios,android