skip to Main Content

I see many, many instances of similar issues related to recent Mac OS/xCode updates with multitudes of proposed solutions that seem to work as often as not. So far, none have worked for me. Here’s what i’m seeing.

I have a long-standing xCode project with cocoapods. A second developer did some updates on a different system which resulted in build errors reading:

"The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation."

When I use the terminal to attempt "pod init, pod update, pod install, pod deintegrate etc… I get:

-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory

The actual Ruby version that exists on my machine is 2.6, not 2.3

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby:

There is no folder on my machine located at

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby:

$ which ruby says: /usr/bin/ruby
That file does exist.

Multiple sources say that ruby installed by HOMEBREW would be found at:

/usr/local/opt/ruby/bin/ruby

There is currently no alias for Ruby in that location.
/usr/local/opt is full of folder aliases but there is no "ruby" alias

I’ve deleted & reinstalled the xCode commandline tools but when I try to do basically anything with homebrew (brew doctor, brew update, brew upgrade etc…)I get errors like this:

Mainframe:~ username$ brew -v
Homebrew 0.9.5
Mainframe:~ username$ brew upgrade
Traceback (most recent call last):
    4: from /usr/local/Library/brew.rb:31:in `<main>'
    3: from /usr/local/Library/Homebrew/os/mac.rb:15:in `version'
    2: from /usr/local/Library/Homebrew/os/mac.rb:15:in `new'
    1: from /usr/local/Library/Homebrew/os/mac/version.rb:24:in `initialize'
/usr/local/Library/Homebrew/version.rb:176:in `initialize': Version value must be a string (TypeError)

All of this started (apparently) because something is different on the other developers machine. I’ve been chasing this issue around in circles for days and getting nowhere.

Having done all of this, I’m thinking the problem lies somewhere back at the beginning with my machine looking for a Ruby 2.3 that does not exist rather than the 2.6 that DOES exist but I have no clue how to tell for sure or how to fix it.

Any help would be greatly appreciated.

2

Answers


  1. Chosen as BEST ANSWER

    Solution: Hack the pod file

    Short version: 1.) Open the file at usr/local/bin/pod 2.) Change 2.3 to 2.6 in the top line

    Long version:

    There is an executable file located at: usr/local/bin/pod The contents are as follows:

    #!/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/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.a"
    
    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
    
    load Gem.bin_path('cocoapods', 'pod', version)
    

    I opened the file at: usr/local/bin/pod and edited the first line to change 2.3 to 2.6.

    This had some effect. Now if I cd into my xcode project and try to run "pod update" I get a different error.

    Mainframe:graffwriter username$ pod update
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin20/rbconfig.rb:229: warning: Insecure world writable dir /Users/pilotrase/bin/FDK/Tools/osx in PATH, mode 040777
    Traceback (most recent call last):
        2: from /usr/local/bin/pod:22:in `<main>'
        1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:262:in `bin_path'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
    

    The pods now seem to be missing...

    I ran:

    sudo gem install -n /usr/local/bin cocoapods
    

    It seems to have worked.

    I ran:

    pod update
    

    It seems to have worked.

    I opened the xCode project and ran a build. The error no longer occurred and the build succeeded.


  2. The actual Ruby version that exists on my machine

    Actually, that’s the source of the problem. Under no circumstances should you use the system ruby! Use rbenv to take control of your ruby versions.

    sudo gem install ...
    

    Blap! Game over, thank you for playing. The fact that you have to say sudo is a major giveaway. This will lead to huge trouble later. Again, this is because you’re using the evil system ruby. This was always wrong. It is not intended for public use! Use rbenv and never say sudo again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search