You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Valentin Haloiu (JIRA)" <ji...@apache.org> on 2018/02/06 12:55:00 UTC

[jira] [Created] (CB-13853) Plugin installation is not deterministic

Valentin Haloiu created CB-13853:
------------------------------------

             Summary: Plugin installation is not deterministic
                 Key: CB-13853
                 URL: https://issues.apache.org/jira/browse/CB-13853
             Project: Apache Cordova
          Issue Type: Bug
          Components: cordova-lib
    Affects Versions: cordova@8.0.0
         Environment: * Node {{9.5.0}}
 * NPM {{5.6.0}}
 * Cordova {{8.0.0}}
            Reporter: Valentin Haloiu


h2. Demo cordova project

[cordova-plugin-install-bug-demo|https://github.com/vially/cordova-plugin-install-bug-demo]
h2. Steps to reproduce

After cloning the repo {{cd}} into the root directory of the project and run:
 * {{npm install}}
 * {{cordova prepare ios --verbose}}

The plugins will fail to install correctly and the contents of the generated {{plugins/fetch.json}} file is messed up:
{noformat}
{
  "cordova-plugin-whitelist": {
    "source": {
      "type": "registry",
      "id": "cordova-plugin-whitelist@1.3.1"
    },
    "is_top_level": true,
    "variables": {}
  },
  "cordova-plugin-splashscreen": {
    "source": {
      "type": "registry",
      "id": "cordova-plugin-customurlscheme@^4.3.0"
    },
    "is_top_level": true,
    "variables": {
      "URL_SCHEME": "io.cordova.hellocordova"
    }
  }
}
{noformat}
 Also, the output of the {{cordova prepare ios --verbose}} makes it quite clear that something went wrong during the installation:
{noformat}
...
Discovered plugin "cordova-plugin-customurlscheme" in config.xml. Adding it to the project
No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "cordova-plugin-customurlscheme@^4.3.0"
Running command: npm install cordova-plugin-customurlscheme@^4.3.0 --production --no-save
Command finished with error code 0: npm install,cordova-plugin-customurlscheme@^4.3.0,-production,-no-save
Copying plugin "/path-to-project/cordova-install-plugin-bug/node_modules/cordova-plugin-splashscreen" => "/path-to-project/cordova-install-plugin-bug/plugins/cordova-plugin-splashscreen"
Calling plugman.install on plugin "/path-to-project/cordova-install-plugin-bug/plugins/cordova-plugin-splashscreen" for platform "ios
Plugin "cordova-plugin-splashscreen" already installed on ios.
...
{noformat}
The installation process seems to mess up the installation of the {{customurlscheme}} plugin with that of the {{splashscreen}} plugin.
h2. Underlying code issue

The root of the problem seems to be in the [add.js|https://github.com/apache/cordova-lib/blob/81f0a8214aa6dc2811bcb6472f4ce62cb8719024/src/cordova/plugin/add.js] {{cordova-lib}} file.

[Line 97|https://github.com/apache/cordova-lib/blob/81f0a8214aa6dc2811bcb6472f4ce62cb8719024/src/cordova/plugin/add.js#L97] prints the {{Calling plugman.fetch on plugin "customurlscheme"}} line, while [line 131|https://github.com/apache/cordova-lib/blob/81f0a8214aa6dc2811bcb6472f4ce62cb8719024/src/cordova/plugin/add.js#L131] prints {{Calling plugman.install on plugin "splashscreen"}}.

This seems to suggest that somewhere between these two lines cordova messes up the plugins somehow.

The code is somewhat difficult to understand but the root cause seems to be this [pluginInfo|https://github.com/apache/cordova-lib/blob/81f0a8214aa6dc2811bcb6472f4ce62cb8719024/src/cordova/plugin/add.js#L52] global variable. Its value is [assigned in the callback of a promise|https://github.com/apache/cordova-lib/blob/81f0a8214aa6dc2811bcb6472f4ce62cb8719024/src/cordova/plugin/add.js#L103], read from [another callback of a promise|https://github.com/apache/cordova-lib/blob/81f0a8214aa6dc2811bcb6472f4ce62cb8719024/src/cordova/plugin/add.js#L131], while [a whole chain of promises|https://github.com/apache/cordova-lib/blob/81f0a8214aa6dc2811bcb6472f4ce62cb8719024/src/cordova/plugin/add.js#L74] is set using a {{reduce}} function.
h2. Further information

Replacing {{"cordova-plugin-splashscreen": "^5.0.1"}} with {{"cordova-plugin-splashscreen": "5.0.1"}} in {{package.json}} makes the {{prepare}} command complete succesfully ([demo branch|https://github.com/vially/cordova-plugin-install-bug-demo/tree/no-fail]). This is a small example of the volatility of the bug.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org