ionic-team / ionic-cli

The Ionic command-line interface
MIT License
2k stars 651 forks source link

Ionic plugin installation from git URL throws error: Failed to fetch plugin <...> via registry #4679

Open azharbeebeejaun opened 3 years ago

azharbeebeejaun commented 3 years ago

Description:

I'm trying to install a plugin (cordova-plugin-bugfender) from a git URL pointing to a specific commit. ionic cordova throws an error while cordova directly installs it without any issue. Command is available below.

Steps to Reproduce:

Run the following command on an Ionic project based on the version dumps below.

ionic cordova plugin add git+https://github.com/bugfender/cordova-plugin-bugfender.git#1a57c5d6cb3f878b5e5577cd5f26f22b8406e130

Output:

$ ionic cordova plugin add git+https://github.com/bugfender/cordova-plugin-bugfender.git#1a57c5d6cb3f878b5e5577cd5f26f22b8406e130 --verbose
  ionic:utils-terminal Environment variables for CI detected: CI +0ms
  ionic:lib Terminal info: { ci: true, shell: '/bin/bash', tty: true, windows: false } +0ms
  ionic:lib CLI global options: { _: [ 'cordova', 'plugin', 'add', 'git+https://github.com/bugfender/cordova-plugin-bugfender.git#1a57c5d6cb3f878b5e5577cd5f26f22b8406e130' ], help: null, h: null, verbose: true, quiet: null, interactive: false, color: true, confirm: null, json: null, project: null, '--': [] } +3ms
  ionic:lib:project Project type from config: @ionic/angular (angular) +0ms
  ionic:lib:project Project details: { configPath: '/Users/distiller/sharinpix-app/ionic.config.json', errors: [], context: 'app', type: 'angular' } +0ms
  ionic Context: { binPath: '/usr/local/lib/node_modules/@ionic/cli/bin/ionic', libPath: '/usr/local/lib/node_modules/@ionic/cli', execPath: '/Users/distiller/sharinpix-app', version: '6.1.0' } +0ms
  ionic:lib:integrations:cordova:config Loading Cordova Config (config.xml: '/Users/distiller/sharinpix-app/config.xml', package.json: '/Users/distiller/sharinpix-app/package.json') +0ms
> cordova plugin add git+https://github.com/bugfender/cordova-plugin-bugfender.git#1a57c5d6cb3f878b5e5577cd5f26f22b8406e130 --verbose
No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "git+https://github.com/bugfender/cordova-plugin-bugfender.git#1a57c5d6cb3f878b5e5577cd5f26f22b8406e130"
fetch: Installing git+https://github.com/bugfender/cordova-plugin-bugfender.git#1a57c5d6cb3f878b5e5577cd5f26f22b8406e130 to /Users/distiller/sharinpix-app
Running command: npm install git+https://github.com/bugfender/cordova-plugin-bugfender.git#1a57c5d6cb3f878b5e5577cd5f26f22b8406e130 --save-dev
Command finished with error code 0: npm install,git+https://github.com/bugfender/cordova-plugin-bugfender.git#1a57c5d6cb3f878b5e5577cd5f26f22b8406e130,--save-dev
Failed to fetch plugin git+https://github.com/bugfender/cordova-plugin-bugfender.git#1a57c5d6cb3f878b5e5577cd5f26f22b8406e130 via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
CordovaError: CordovaError: Could not determine package name from output:
up to date, audited 2113 packages in 5s

23 vulnerabilities (11 low, 3 moderate, 9 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
CordovaError: Failed to fetch plugin git+https://github.com/bugfender/cordova-plugin-bugfender.git#1a57c5d6cb3f878b5e5577cd5f26f22b8406e130 via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
CordovaError: CordovaError: Could not determine package name from output:
up to date, audited 2113 packages in 5s

23 vulnerabilities (11 low, 3 moderate, 9 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
    at /Users/distiller/sharinpix-app/node_modules/cordova-lib/src/plugman/fetch.js:140:43
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
[ERROR] An error occurred while running subprocess cordova.

        cordova plugin add git+https://github.com/bugfender/cordova-plugin-bugfender.git... exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.
  ionic:utils-process onBeforeExit handler: 'process.exit' received +0ms
  ionic:utils-process onBeforeExit handler: running 1 functions +0ms
  ionic:utils-process processExit: exiting (exit code: 1) +19ms

My ionic info (and cordova info):

$ ionic info
Ionic:

   Ionic CLI                     : 6.1.0 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.3.0
   @angular-devkit/build-angular : 0.803.28
   @angular-devkit/schematics    : 8.3.26
   @angular/cli                  : 8.3.26
   @ionic/angular-toolkit        : 2.0.0

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : ios 6.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 23 other plugins)

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   ios-deploy : 1.11.4
   ios-sim    : 8.0.2
   NodeJS     : v15.7.0 (/usr/local/Cellar/node/15.7.0/bin/node)
   npm        : 7.4.3
   OS         : macOS Catalina
   Xcode      : Xcode 12.4 Build version 12D4e

$ cordova info
Cordova Packages:

    cli: 10.0.0
        common: 4.0.2
        create: 3.0.0
        lib: 10.0.0
            common: 4.0.2
            fetch: 3.0.1
            serve: 4.0.0

Project Installed Platforms:

    ios: 6.1.0

Environment:

    OS: macOS Catalina 10.15.5 (19F101) (darwin 19.5.0) x64
    Node: v15.7.0
    npm: 7.4.3

ios Environment:

    xcodebuild:
Xcode 12.4
Build version 12D4e

Other Information:

Possible related issue: https://github.com/ionic-team/ionic-cli/issues/2716. But, the error messages are not the same at first and the fixes don't work.

The same plugin can be installed using cordova directly but Ionic won't find it when building the project.

$ cordova plugin add git+https://github.com/bugfender/cordova-plugin-bugfender.git#1a57c5d6cb3f878b5e5577cd5f26f22b8406e130
Installing "cordova-plugin-bugfender" for ios
Plugin dependency "cordova-plugin-device@2.0.3" already fetched, using that version.
Dependent plugin "cordova-plugin-device" already installed on ios.
"framework" tag with type "podspec" is deprecated and will be removed. Please use the "podspec" tag.
Running command: pod install --verbose
     Cloning into '/var/folders/6y/gy9gggt14379c_k39vwb50lc0000gn/T/d20210428-1115-mc4njq'...

     Note: switching to '13a8999a430f8565bf11a75205102602b0fe2ab9'.

     You are in 'detached HEAD' state. You can look around, make experimental

     changes and commit them, and you can discard any commits you make in this
     state without impacting any branches by switching back to a branch.

     If you want to create a new branch to retain commits you create, you may
     do so (now or later) by using -c with the switch command. Example:

       git switch -c <new-branch-name>

     Or undo this operation with:

       git switch -

     Turn off this advice by setting config variable advice.detachedHead to false

Adding cordova-plugin-bugfender to package.json

From what I saw on https://github.com/apache/cordova-lib/issues/859, cordova-fetch@3.0.1 was released to fix this but issue still persists for me as I'm already up to date with that version.

Workaround From https://github.com/apache/cordova-cli/issues/541, I tried to downgrade npm using npm install npm@6 and it fixes the issue on Ionic.

koti-muppavarapu commented 2 years ago

Hi,

Did you find a solution or workaround for this. I am facing the same issue.

Ionic:

Ionic CLI : 6.20.1 (/usr/local/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/angular 5.6.14 @angular-devkit/build-angular : 12.2.2 @angular-devkit/schematics : 12.2.2 @angular/cli : 12.2.2 @ionic/angular-toolkit : 4.0.0

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1) Cordova Platforms : android 9.0.0, ios 5.1.1 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 11 other plugins)

Utility:

cordova-res : 0.15.4 native-run (update available: 1.6.0) : 1.5.0

System:

Android SDK Tools : 26.1.1 (/Users/krao/Library/Android/sdk) ios-sim : 8.0.2 NodeJS : v16.15.1 (/usr/local/bin/node) npm : 8.11.0 OS : macOS Monterey Xcode : Xcode 13.4.1 Build version 13F100

cordova plugin add git+ssh://git@bitbucket.org/XXX/XXX.git Failed to fetch plugin git+ssh://git@bitbucket.org/XXX/XXX.git via registry. Probably this is either a connection problem, or plugin spec is incorrect. Check your connection and plugin name/version/URL.

koti-muppavarapu commented 2 years ago

npm version is the root cause for this issue. Downgraded to version 6.14.17 and now I am able to add plugin successfully.