title: How to get Cocoapods running with RVM?
body: <p>Unfortunately, I recently upgraded the system Ruby to 2.3 on my Mac. Since I have to use Cocoapods 0.39 for a <a href="https://github.com/CocoaPods/CocoaPods/issues/4699" rel="nofollow noreferrer">specific project</a> which does not properly work, I would like to use an older version of Ruby. For this purpose, I installed RVM and then switched to <code>ruby-2.2-head</code>:</p>
  
  <pre><code>&gt; \curl -sSL https://get.rvm.io | bash -s stable --ruby
  &gt; rvm install 2.2-head
  &gt; rvm use 2.2-head --default
  </code></pre>
  
  <p>This worked fine. Then I tried to install Cocoapods and got the usual error message:</p>
  
  <pre><code>&gt; rvmsudo gem install cocoapods
  
  Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. Run:
  
      export rvmsudo_secure_path=1
  
  to avoid the warning, put it in shell initialization file to make it persistent.
  
  In case there is no `secure_path` in `/etc/sudoers`. Run:
  
      export rvmsudo_secure_path=0 
  </code></pre>
  
  <p>which I silenced by chosing the second option. Then I checked Cocoapods and got a fantastic error message:</p>
  
  <pre><code>&gt; pod --version
  
  /Users/bastian/.rvm/rubies/ruby-2.2-head/lib/ruby/site_ruby/2.2.0/rubygems.rb:250:in `find_spec_for_exe': can't find gem cocoapods (&gt;= 0.a) (Gem::GemNotFoundException)
    from /Users/bastian/.rvm/rubies/ruby-2.2-head/lib/ruby/site_ruby/2.2.0/rubygems.rb:278:in `activate_bin_path'
    from /Users/bastian/bin/pod:22:in `&lt;main&gt;'
  </code></pre>
  
  <p>Furthermore, Cocoapods is not listed with the following command:</p>
  
  <pre><code>&gt; gem list
  
  *** LOCAL GEMS ***
  
  bigdecimal (1.2.6)
  io-console (0.4.3)
  json (1.8.1)
  psych (2.0.8)
  rake (10.4.2)
  rdoc (4.2.0)
  </code></pre>
  
  <p>Cocoapods seems to be installed into the wrong directory:</p>
  
  <pre><code>&gt; which pod
  /Users/bastian/bin/pod
  </code></pre>
  
  <p>So if I switch back to the system Ruby, the <code>pod --version</code> command returns <code>0.39.0</code>.</p>
  
  <p>I guess that somehow Cocoapods was not installed with the RVM Ruby but rather with the system version. What did I do wrong?</p>