Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 xcodeproj and cocoapods. Almost everything that I try to do with gem 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 sudo 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
2.6.7

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

I guess that I have a configuration problem with Ruby.

Any suggestions on how to troubleshoot this?

like image 311
Carlos Mermingas Avatar asked Sep 29 '16 20:09

Carlos Mermingas


People also ask

How do I install a ruby gem without a user?

-- [no-]user-install - Install in user’s home directory instead of GEM_HOME. The install command installs local or remote gem into a gem repository. For gems with executables ruby installs a wrapper file into the executable directory by default. This can be overridden with the –no-wrappers option.

What is argumenterror in Ruby?

An opinionated beast. You'll know when you're wrong. Raised when the arguments are wrong and there isn't a more specific Exception class. Ex: passing the wrong number of arguments Ex: passing an argument that is not acceptable: Ruby's ArgumentError is raised when you call a method with incorrect arguments.

Why does RubyGems ask for confirmation?

RubyGems will ask for confirmation if you are attempting to uninstall a gem that is a dependency of an existing gem. You can use the –ignore-dependencies option to skip this check. The unpack command allows you to examine the contents of a gem or modify them to help diagnose a bug.

What are the dependency commands in RubyGems?

The dependency commands lists which other gems a given gem depends on. For local gems only the reverse dependencies can be shown (which gems depend on the named gem). The dependency list can be displayed in a format suitable for piping for use with other commands. Display information about the RubyGems environment


1 Answers

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.

Steps:

  1. Uninstall ruby

    brew uninstall ruby

  2. Install rbenv and ruby-build

    brew install rbenv ruby-build

  3. You need to add Ruby to your path.

    A. If Terminal is your shell.

    Add eval "$(rbenv init -)" to ~/.bash_profile

    B. Or if you use another shell

    You can find the instruction by entering the command rbenv init NAME_OF_YOUR_SHELL.

  4. Install Ruby

    rbenv install 2.3.1

  5. Set the Ruby version

    rbenv global 2.3.1

    rbenv local 2.3.1

  6. Reinstall Cocoapods

    gem install cocoapods

like image 177
Krtko Avatar answered Oct 13 '22 00:10

Krtko