Error when installing Ruby on Rails: “Failed to build gem native extension”

后端 未结 10 1645
太阳男子
太阳男子 2020-12-28 13:29

I\'m running Crunchbang 11 (Debian-based).

I\'m trying to install Ruby on Rails, like this:

gem install rails --version 4.0.0

I ge

相关标签:
10条回答
  • 2020-12-28 13:49

    Rails 4.0 needs RubyGem version 2.0.3, Just update your system by using following command

    gem update --system 2.0.3
    
    0 讨论(0)
  • 2020-12-28 13:49

    Just a follow up ... on different solution...

    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-28 13:54

    I had the same error when installing rails, but I solved it by running the command: gem install rails without adding sudo.

    0 讨论(0)
  • 2020-12-28 13:56

    Run the following command:

    sudo apt-get install ruby-dev zlib1g-dev liblzma-dev
    

    Then,

    sudo gem install rails
    
    0 讨论(0)
  • 2020-12-28 13:58

    For me this helped:

    sudo apt-get install ruby-dev
    
    0 讨论(0)
  • 2020-12-28 14:01

    For anyone got the error:"Failed to build gem native extension”, while running sudo gem install rails, and it said somethings about "nokogiri".

    It is possible because you are using the same ruby version as system is using (for mac user). The solution would be install RVM, use RVM to install another ruby version.

    So now you have 2 Ruby versions on your machine, RVM will automatically switch to the newly installed version. now, you can run gem install rails without error and without sudo as well.

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