OS-X, Rails: “Failed to build gem native extension”

后端 未结 12 2164
梦毁少年i
梦毁少年i 2020-12-03 02:22

I\'m stuck trying to install rails on my mac. I have OS X 10.6.8 and I have confirmed that I have Ruby, version 1.8.7

I ran sudo gem update and su

相关标签:
12条回答
  • 2020-12-03 03:02

    Try to install Ruby via RVM. I solved in this way

    How to install ruby on Ubuntu with rvm

    0 讨论(0)
  • 2020-12-03 03:05

    There are two possible reasons for the fail:

    1. PRIMARY REASON: Missing Xcode Command Line Tools

    Verifying Xcode Command Line Tools Installation manually: Check for presence of "/usr/include/iconv.h" (if absent=>Missing or improperly installed Xcode CLT)

    Installing Xcode CLT: Try running xcode-select --install on terminal and follow the instructions. If it fails, open Xcode.app, select from menu "Xcode" - "Open Developer Tool" - "More Developer Tools" to open the developer site, download the installer for your OS version and run it.

    1. SECONDARY REASON(if 1. fails): Version issues Try upgrading the ruby version using rbenv.

    Hope it helps!

    0 讨论(0)
  • 2020-12-03 03:09

    If you have XCode 4 or later you will need to open it and go to Preferences -> Downloads -> Components and install the Command Line tools as they aren't installed by default. Couldn't install Rails until this happened.

    0 讨论(0)
  • 2020-12-03 03:09

    Just a follow up ...

    it may be that you are on a mac and rails cannot find the right compiler for c headers.

    just install xcode from apps store / homebrew or go to terminal ...

    $ xcode-select --install

    complete the installation and agree on the licensing etc, then ...

    $ sudo gem install rails

    0 讨论(0)
  • 2020-12-03 03:11

    Switch Ruby to Homebrew version:

    $ brew install ruby
    $ brew link --overwrite ruby
    
    $ echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
    $ echo 'export LDFLAGS="-L/usr/local/opt/ruby/lib"' >> ~/.bash_profile
    $ echo 'export CPPFLAGS="-I/usr/local/opt/ruby/include"' >> ~/.bash_profile
    
    0 讨论(0)
  • 2020-12-03 03:14

    Did you install the OS X developer tools? You'll need to do this to be able to build native extensions

    0 讨论(0)
提交回复
热议问题