Pod Command Uses Wrong Ruby Path

Some days ago, I updated my Macbook Pro’s OS to 10.10, then I changed the default Ruby version to other verson rather than the system default version. Today, when I used the pod install to install some third libraries, I found the followed error:

1
-bash: /usr/local/bin/pod: /usr/local/Cellar/ruby/2.1.2_3/bin/ruby: bad interpreter: No such file or directory

Then I knew that the pod command used wrong ruby version.

Try many ways, but I still can’t solve it. Then I opened the cocoaPods Guides and found the followed text:

CocoaPods is built with Ruby and it will be installable with the default Ruby available on OS X. You can use a Ruby Version manager, however we recommend that you use the standard Ruby available on OS X unless you know what you're doing.

Ok, I am sorry for seeing the text too late. But now, how should I do? I have no idea. Maybe I can see what it is in the pod file.

Then I run which pod on the terminal.

1
2
shunzhu:~ vale$ which pod
/usr/local/bin/pod

Then run mate /usr/local/bin/pod:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/local/Cellar/ruby/2.1.2_3/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'cocoapods' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
end

gem 'cocoapods', version
load Gem.bin_path('cocoapods', 'pod', version)

Maybe I find something, the code in the first line, it is very similar with the error hint:

1
-bash: /usr/local/bin/pod: /usr/local/Cellar/ruby/2.1.2_3/bin/ruby: bad interpreter: No such file or directory

Ok, let me change the first line code to this #!/usr/bin/ruby

Try pod again:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
shunzhu:~ vale$ pod
Setting up CocoaPods master repo
Setup completed
Usage:

$ pod COMMAND

CocoaPods, the Objective-C library package manager.

Commands:

+ init Generate a Podfile for the current directory.
+ install Install project dependencies to Podfile.lock versions
+ ipc Inter-process communication
+ lib Develop pods
+ list List pods
+ outdated Show outdated project dependencies
+ plugins Show available CocoaPods plugins
+ push Temporary alias for the `pod repo push` command
+ repo Manage spec-repositories
+ search Searches for pods
+ setup Setup the CocoaPods environment
+ spec Manage pod specs
+ trunk Interact with the CocoaPods API (e.g. publishing new
specs)
+ try Try a Pod!
+ update Update outdated project dependencies and create new
Podfile.lock

Options:

--silent Show nothing
--completion-script Print the auto-completion script
--version Show the version of the tool
--verbose Show more debugging information
--no-ansi Show output without ANSI codes
--help Show help banner of specified command
shunzhu:~ vale$

Until here, I think I have solved the issue. Thanks God!!!