Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-9559

Adding a plugin with caret in version results in an error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 5.2.0
    • None
    • cordova-lib
    • None
    • OS X 10.10.5
      cordova-cli 5.2.0

    Description

      Repro:

      cordova plugin add cordova-plugin-battery-status@^1.0.0
      Fetching plugin "cordova-plugin-battery-status@^1.0.0" via npm
      Failed to fetch plugin cordova-plugin-battery-status@^1.0.0 via registry.
      Probably this is either a connection problem, or plugin spec is incorrect.
      Check your connection and plugin name/version/URL.
      Error: No compatible version found: cordova-plugin-battery-status@'">=1.0.0 <2.0.0"'
      Valid install targets:
      ["0.2.1","0.2.3","0.2.4","0.2.5","0.2.6","0.2.7","0.2.9","0.2.10","0.2.11","0.2.12","1.0.0","1.1.0"]
      

      Expected:
      The plugin can be installed

      Actual:
      The plugin cannot be installed.

      Note in the error log, the version is expanded from:

       @^1.0.0
      

      to:

      @">=1.0.0 <2.0.0"
      

      But, it appears the double quotes around the expanded version in the error log are wrapped with single quotes now, resulting in the error.

      The version is expanded using this processPluginVersion function:
      https://github.com/apache/cordova-lib/blob/3e34b557c8bb6876022f0a4186b81d4ff8e5da75/cordova-lib/src/plugman/registry/registry.js#L282

      From this commit:
      https://github.com/apache/cordova-lib/commit/024b970b26d3d8b7f9a6b2f0eab2325d7716deef

      The fix appears to be not calling the function processPluginVersion and passing it to npm cache add as is:
      https://github.com/apache/cordova-lib/blob/3e34b557c8bb6876022f0a4186b81d4ff8e5da75/cordova-lib/src/plugman/registry/registry.js#L270

      The purpose of this function is because we are using an older version of npm that may not understand carets. Is this still truly the case? If not, we could get rid of this function – while still keeping CB-9147 fixed/resolved

      Attachments

        Activity

          People

            TimBarham Tim Barham
            shazron Shazron Abdullah
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: