bug: Command failed with exit code 2 You may not have the required environment or OS to build this project
From @shivanshuit914 on March 3, 2015 19:15
Type: bug
Platform: desktop browser
> ionic build ios
ERROR building one of the platforms: Error: /Applications/MAMP/htdocs/myApp/platforms/ios/cordova/build: Command failed with exit code 2 You may not have the required environment or OS to build this project Error: /Applications/MAMP/htdocs/myApp/platforms/ios/cordova/build: Command failed with exit code 2 at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:756:16) at Process.ChildProcess._handle.onexit (child_process.js:823:5)
OS Mac Maverich, have followed this tutorial http://ionicframework.com/docs/guide/installation.html
Copied from original issue: driftyco/ionic#3225
hi i'm having the same problem in windows. when trying to build an android app.

currently we r building crosswalk 11.40.277.7.1 + meteorjs apk following this steps https://github.com/sujith3g/crosswalk-for-meteor
Could someone who can successfully perform ionic run android or ionic run android post their versions of Cordova, Ionic CLI, and ios-deply so I can up/downgrade accordingly? Thanks.
OS: Mac OS X Yosemite Node Version: v0.12.0 Cordova CLI: 4.3.0 Ionic CLI Version: 1.3.19 Xcode version: 6.2 (6C131e) ios-sim version: 3.1.1 ios-deploy version: 1.4.0 HTC Desire 510 (Android 4.4.2)
@dano2 Thanks, node was way out of date.
I got this error after adding the "PushPlugin" with ionic plugin add https://github.com/phonegap-build/PushPlugin.git By removing my older push notification plugin "PushWoosh" with ionic plugin remove com.pushwoosh.plugins.pushwoosh I was able to fix the error.
@blitz2150 I'm getting the same error when trying to build android in windows. Any luck for you?
@nasimghazanfari Try running the cordova command directly.
cd platforms/android/cordova
build.bat --debug
this will build and show debug log.
for me it told android-22 is missing. I have an S2 Rooted running 4.4.4 (android-19)... so I think it needs the latest Target SDK (Which is 22 Right now). Even though I had android-19 already downloaded, I still had to download android-22 to make ionic build my app.
so Just open your SDK Manager (Android) ... Download the API Level 22 files. Re Run the ionic build command. Worked for me.
@vasumahesh1 Thanks for the suggestion.
@blitz2150 you might try running that build command directly as well.
If anyone is still having issues with this, please run ionic info and post that information along with the build errors.
I narrowed my issue down to the ngCordova camera plugin. removing ios and re-adding it fixed the issue: cordova platform remove ios cordova platform add ios
I have a similar problem myself, running Ionic on my MacBook.
I have created a blank cordova project (following the guide on cordovan's site) and after doing the cordova build ios command, I have executed the cordova emulate ios to have this open the iOS Simulator.
After a short period of time the terminal returns the following output:-
** BUILD SUCCEEDED **
No target specified for emulator. Deploying to iPhone-6 simulator 2015-05-12 14:28:31.467 ios-sim[7059:89690] stderrPath: /Users/school/Documents/hello/platforms/ios/cordova/console.log 2015-05-12 14:28:31.467 ios-sim[7059:89690] stdoutPath: /Users/school/Documents/hello/platforms/ios/cordova/console.log Session could not be started: Error Domain=DTiPhoneSimulatorErrorDomain Code=2 "Timed out waiting for device to boot" UserInfo=0x7f8301d0c6c0 {NSLocalizedDescription=Timed out waiting for device to boot} Error code 1 for command: ios-sim with args: launch,/Users/school/Documents/hello/platforms/ios/build/emulator/HelloWorld.app,--devicetypeid,com.apple.CoreSimulator.SimDeviceType.iPhone-6,--stderr,/Users/school/Documents/hello/platforms/ios/cordova/console.log,--stdout,/Users/school/Documents/hello/platforms/ios/cordova/console.log,--exit Error: /Users/school/Documents/hello/platforms/ios/cordova/run: Command failed with exit code 2 at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23) at ChildProcess.emit (events.js:110:17) at maybeClose (child_process.js:1015:16) at Process.ChildProcess._handle.onexit (child_process.js:1087:5) Schools-Air:hello school$ sudo ionic info
OS: Mac OS X Yosemite Node Version: v0.12.2 Cordova CLI: 5.0.0 Ionic CLI Version: 1.3.22 Xcode version: Xcode 6.3.1 Build version 6D1002 ios-sim version: 3.1.1 ios-deploy version: 1.5.0
Kind of a sidenote but is there a quick command to get a list of all my current installation versions as gkimpson has displayed above? (For node, ionic, Cordova, etc)
@dano2 ionic info - you might also look at ionic help and see the listing of all commands, getting help for each ionic help serve.
@jbavari Very cool. Thanks!
I've run into this issue a few times as well in the past 2 weeks. Only with iOS builds though. When I say a "few times" I really mean only 2 times. I experience it when switching branches in my git project. Something about switching branches and coming back to the working branch, messes up the build. Below is my error, which sounds very similar to others. I've tried resolving it with chmod tricks, but they dont work. I havent tried removing iOS and re-adding it, I'm a little scared because my project has numerous plugins and SDK's. I resolved this issue the first time, but havent found a fix yet today.

Just adding to the discussion. After running "ionic run", don't cancel the process in the middle. I did, and ended up with this error and needed to remove then re-add the platform. Let any command take it's course, is my new rule of thumb with ionic.
Good news, ran a single command today and completely restored by build without harming any of my previous work: cordova platform update ios. Hope this helps someone else, I'm feeling very relieved.
Had these same issues after updating cordova, ionic, etc. Did pretty much everything from above, but still no joy. I also updated android sdk to 22. The final thing that helped me run a successful build was altering the AndroidManifest.xml.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.android">
<application/>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />
</manifest>
I was getting the "You may not have the required environment or OS to build this project" when trying to do Android release builds ionic build android --release after upgrading from ionic cli 1.3.19, ionic beta14 and cordova 4.3.0 to most current versions. iOS build/emulation are fine.
Main cause of the error was that cordova 5 uses gradle and not ant as the build tool. Using gradle broke some of my hooks as well. You can tell cordova/ionic to use ant instead of gradle by setting an environment variable, ANDROID_BUILD=ant. Stayed with ant since cordova considers gradle to still be experimental... and I didn't want to rewrite my hooks just yet. ;p
Same problem here (windows 8.1 32-bit). I can't build and run my Ionic app. However, I can use Ionic LAB to preview my app in the broswer.
