Ionic-framework: bug: Ionic emulate Ios fails to run The session does not open my app

Created on 8 Jul 2015  路  29Comments  路  Source: ionic-team/ionic-framework

Type: bug

Platform: ios 7 browser

Ionic emulate ios failed on Mac OS Yosemite. Their have some cases were the ios device emulated, but shortly after the terminal console shoots up the error message below.

* BUILD SUCCEEDED *
No target specified for emulator. Deploying to iPhone-6 simulator An error was encountered processing the command (code=146): Invalid device state An error was encountered processing the command (code=146): Exception encountered connecting to CoreSimulatorBridge: Unable to connect to CoreSimulatorBridge ENOENT, no such file or directory '/Users/yay/Library/Logs/CoreSimulator/2CAA2C39-7F22-4AF2-BBDE-86609188F37C/system.log' Error code 1 for command: ios-sim with args: launch,/Users/yay/code/myApp/platforms/ios/build/emulator/myApp.app,--devicetypeid,com.apple.CoreSimulator.SimDeviceType.iPhone-6,--stderr,/Users/yay/code/myApp/platforms/ios/cordova/console.log,--stdout,/Users/yay/code/myApp/platforms/ios/cordova/console.log,--exit Error: /Users/yay/code/myApp/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:134: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)

Most helpful comment

the following worked for me:

//remove with sudo
sudo ionic platform remove ios

//add iOS back without sudo
ionic platform add ios

//worked for me
ionic emulate ios

All 29 comments

This is a permissions issue:

running sudo ionic start requires you to build / emulate with sudo to remove/build files which won't work when emulating, hence your error.

Don't use sudo for creating or emulating.

i have that same problem, if i don't use sudo like you suggest, i get "rm: could not remove file (code EACCES):" on all files. Xcode 6.4, last node/npm. But as u say this is a sudo problem, so how to resolve this dilema?

It's because you created the ionic project using Sudo.

Recursively chown that folder to your user.

Thank you for your answer! But sorry english isn't my native languagem, i dont quite understand. My projet was created on a windowns system, with android platform, and right now i fork this project on a mac via github. There is a solution? what is "Recursively chown that folder to your user." Thank you again, my startup depend in resolve that problem =)

i tested creating a project without sudo and emulate with and without sudo, and got the same erros.

ionic start test
sudo ionic platform add ios(can't go to the next step without sudo here)
ionic emulate iOS: rm: could not remove file (code EACCES):
sudo ionic emulate iOS: Invalid device state An error was encountered processing the command (code=146): Exception encountered connecting to CoreSimulatorBridge: Unable to connect to CoreSimulatorBridge ENOENT, no such file or directory '/Users/yay/Library/Logs/CoreSimulator/2CAA2C39-7F22-4AF2-BBDE-86609188F37C/system.log' Error

Indeed it was a permission issue thanks @iamthemovie

the following worked for me:

//remove with sudo
sudo ionic platform remove ios

//add iOS back without sudo
ionic platform add ios

//worked for me
ionic emulate ios

amazing !!!!!
it work for me

So you shouldn't ever have to run the ionic command with sudo, ever.
Since the cli is installed globally already, the current user has access to all it's commands. The only time this could be an issue with with nvm and not having a globally available version of node

Worked like a charm. Indeed it was a permission problem.

@rajkotecha Thx, you save my day!

@rajkotecha's fix also worked for me.

I'm having the problem but I can't seem to diagnose how to fix the permission issue.

when I do

ionic platform add ios

I get a error to fetch platform..
...operation ont permitted, utime "somepath/package/.npmignore

Do I need to eliminate a line in this file?

craigm26 sudo chown -Rv [USERNAME] /Users/[USERNAME] - helped me!

If you're still having issues, can you post over here? https://github.com/driftyco/ionic-cli

Also, just in case, try installing the beta: npm install -g ionic@beta

Thanks guys/gals

sudo chown -Rv [USERNAME] /Users/[USERNAME] helped me too!

I had access error for update-notifier-cordova.json; and this is what that worked for me:
sudo chown [USERNAME]:admin /Users/[USERNAME]/.config/configstore/update-notifier-cordova.json

to get the reomve/add mentioned above to work I had to delete the .cordova/lib/npm_cache/cordova-ios folder...then all was well

I had the issue too. Even though I create project without sudo, I cannot add platform ios successfully with the permission error.
And this worked for me too:
sudo chown [USERNAME]:admin /Users/[USERNAME]/.config/configstore/update-notifier-cordova.json

Thank you

+1
Even though my issues wasn't related to permissions, removing the platform and adding it back solved the issue I was having. Never faced this before.

I can confirm, for me helped what zzsanduo suggested:
sudo chown [USERNAME]:admin /Users/[USERNAME]/.config/configstore/update-notifier-cordova.json

Thanks everyone for the tips here. One other thing: if you're using tmux, you'll need to open a new terminal outside of tmux before the emulate command can run. There was some hack you could use to get around this in the past but I don't have that tip handy anymore and couldn't find it after a cursory google search

this work for me
chown -R $(whoami) /project_folder

ionic run ios (whitout sudo)

(y)

@mlynch This fixed it, I tried everything to do with permissions. I've now found a few messages noting the issue with tmux, but wasn't even something I'd considered initially.

Yep, thank you craigm26, sudo chown -Rv [USERNAME] /Users/[USERNAME] did the trick.

@rajkotecha Thanks!

SOLVED

I'd added ios platform with sudo. That why it happened. Now I do it without sudo, it works well.

  1. Remove platform (with sudo)
    $ sudo ionic cordova platform rm ios

  2. Add platform (without sudo)
    $ ionic cordova platform add ios

  3. Emulate
    $ ionic cordova run ios

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

masimplo picture masimplo  路  3Comments

danbucholtz picture danbucholtz  路  3Comments

daveshirman picture daveshirman  路  3Comments

fdnhkj picture fdnhkj  路  3Comments

alan-agius4 picture alan-agius4  路  3Comments