"ionic cordova platform --no-build" on Ionic Pro tries to install browser platform" into /platforms/android


#1

Ionic Pro builds are failing, while local builds pass…

Here’s a snippet from log of my Build ae070d, when platforms are installed by ionic cordova prepare --no-build:

> ionic cordova prepare --no-build
> cordova prepare
Discovered platform "android@^6.2.3" in config.xml or package.json. Adding it to the project
Using cordova-fetch for cordova-android@^6.2.3
Adding android project...
Creating Cordova project for the Android platform:
	Path: platforms/android
	Package: com.payrange.ldecode
	Name: MyApp
	Activity: MainActivity
	Android target: android-26
Subproject Path: CordovaLib
Android project created with cordova-android@6.4.0
Discovered platform "browser@^4.1.0" in config.xml or package.json. Adding it to the project
Using cordova-fetch for cordova-browser@^4.1.0
Error: Platform android already added.

Then later, when platform browser is prepared by ionic cordova prepare --no-build browser --dev, it fails:

> ionic cordova prepare --no-build browser --dev           

--no-confirm: Platform browser is not installed! Would you like to install it? No
[ERROR] Can't prepare for browser unless the platform is installed.

        Did you mean just ionic cordova prepare?
        

npm ERR! code ELIFECYCLE
npm ERR! errno 1

There are few unexpected issues with that:

  1. ionic cordova prepare --no-build tries to fetch “browser” platform and stops with “Platform android already added” - very baffling bug in Ionic! Why the heck does it try to fetch browser platform into android platform (which was indeed fetched ok prior to that)??

  2. ionic cordova prepare --no-build browser --dev tries to ask the user whether to install browser platform and then auto-answers “No” due to --no-interactive in Ionic Pro build. There are two issues with that: A. command without ... browser --dev does not try to ask questions, while command with it asks the user - very inconsistent behavior. B. platform installs should default to “yes” in CI / --no-interactive, instead of “no”. How else the build is supposed to continue??

Some background info:
I did not have the first ionic cordova prepare --no-build command initially, but builds were failing after auto-answering “No”. So I tried to prefetch platforms and found out that ionic cordova prepare --no-build without specific platform name fetches all platforms and does it silently. I use --no-build flag as ionic is built to www prior to cordova for multiple targets (–prod, --dev and --staging by means of environment variables), and redoing ionic build is a waste of time.

Any thoughts on how to build with cordova browser platform:

  1. So the prefetch by ionic cordova platforms prepare works correctly for browser platform, not confusing it with android?
  2. ionic cordova platforms prepare browser does not ask a question about installing the platform?
  3. How can the questions (about installing missing platform) be auto-answered “yes”?