Failed to install 'onesignal-cordova-plugin': Error: pod: Command failed with exit code 31

Hi All,

When Im building my Ionic app with IONIC PRO this error pops up:

Installing "onesignal-cordova-plugin" for ios
Failed to install 'onesignal-cordova-plugin': Error: pod: Command failed with exit code 31
    at ChildProcess.whenDone (/Users/ionic/builds/project-1/platforms/ios/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
Failed to restore plugin "onesignal-cordova-plugin" from config.xml. You might need to try adding it again. Error: Error: pod: Command failed with exit code 31
--save flag or autosave detected
Running after script...
$ clean-up
Cleaning up files...
Successful clean up
ERROR: Job failed: Process exited with: 1. Reason was:  ()

Does somebody know’s a fix for this?

Ionic info

cli packages: (C:\Users\Thijmen\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 6.3.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2


    Node : v8.10.0
    npm  : 5.8.0
    OS   : Windows 10

Environment Variables:

    ANDROID_HOME : not set


    backend : pro

I had the problem not as same as this but it was also a pod related issue u need to install pod files in ur platform/ios folder
Use this for reference

Hi Akash,

When Im running an pod command it throws the following:

C:/Ruby24-x64/lib/ruby/2.4.0/rubygems.rb:271:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems.rb:299:in `activate_bin_path'
        from C:/Ruby24-x64/bin/pod:23:in `<main>'

I installed Ruby and installed cocoapods.

1 Like

i think ruby gem (package manager) is not installed in your system.
try using this
it might help you


I installed this package
Ruby+Devkit 2.4.4-1 (x64)

Still the same problem.

@akash705 Im 1 step further.

Getting the following message right now after running pod setup / pod repo update

C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/claide-1.0.2/lib/claide/command.rb:439:in `help!’: [!] You cannot run CocoaPods as root. (CLAide::Help)

you can’t run cocoapods as root because of security reasons .
in windows use a normal cmd prompt instead of admin cmd prompt

There I got still the same problem.

and what about pod install

Still the same.

Somebody knows a solution for this?