Carlos Mermingas Carlos Mermingas - 1 year ago 52
Ruby Question

Ruby gem show "Invalid argument" error for almost every command

I am working through NativeScript's set-up on OS X El Capitan and I am stuck at the point where I am supposed to install

. Almost everything that I try to do with
shows the same error:

$ sudo gem install xcodeproj
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument

The following commands show the same error, wether I run it with
or not:

$ gem update --system
$ gem update
$ gem install whatever
$ gem install cocoapods

I have the following versions:

$ ruby --version
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

$ gem --version

I've tried some of the help that I've found online, including reinstalling
, restarting but nothing has helped.

I guess that I have a configuration problem with Ruby.

Any suggestions on how to troubleshoot this?

Answer Source

I just had a similar issue after updating everything via Homebrew.

I solved the issue by uninstalling Ruby and installing it via rbenv, then reinstalling cocoa pods.


  1. Uninstall ruby

    $ brew uninstall ruby

  2. Install rbenv and ruby-build

    $ brew install rbenv ruby-build

  3. Add this to ~/.bash_profile

    eval "$(rbenv init -)"

  4. Install Ruby

    $ rbenv install 2.3.1

    $ rbenv global 2.3.1