简体   繁体   English

尝试在终端中安装滑轨,不确定什么错误意味着

[英]Trying to install rails in terminal, not sure what error means

I'm getting this when trying to install rails using: gen install rails I barely have any idea what I'm doing :/ Trying to learn :) 我在尝试使用以下方法gen install rails时遇到了这个问题: gen install rails我几乎不知道我在做什么:/试图学习:)

ERROR:  Error installing rails:
ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.7.5 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.7.5/ext/json/ext/generator/gem_make.out

Thanks in advance! 提前致谢!

I've tried following directions here (http://rubyonrails.org/download) and here (http://rubygems.org/pages/download). 我尝试按照此处(http://rubyonrails.org/download)和此处(http://rubygems.org/pages/download)的指示进行操作。

I'm going to assume that you're new to Ruby as well, just in case doing so can help others who need this answered. 我将假设您也是Ruby的新手,以防万一这样做可以帮助需要此答案的其他人。 Please don't take offense. 请不要冒犯。

It looks like your installation of Ruby is out of date or broken. 您的Ruby安装似乎已过期或已损坏。 Mac OSX comes with a default Ruby installed, but I honestly have no idea if it's complete or out of date because I always install my own. Mac OSX附带了默认的Ruby,但是老实说,我不知道它是否完整或过时,因为我总是自己安装。

Getting a Build Environment Ready 准备好构建环境

By default, MacOSX does not have the capacity to build C applications, which is what the "standard" ruby runtime is. 默认情况下,MacOSX不具有构建C应用程序的能力,这就是“标准” ruby​​运行时的功能。 So, you need to install a C building toolchain, which in many cases is GCC & friends. 因此,您需要安装一个C构建工具链,在很多情况下是GCC和朋友。

Without XCode Installed 没有安装XCode

  1. Find the " Additional Developer Tools " link on the XCode product page XCode产品页面上找到“ 其他开发人员工具 ”链接
  2. Click it 点击它
  3. Find and install the " Command Line Tools " for your version of OSX 查找并安装适用于您的OSX版本的“ 命令行工具

With XCode Installed 安装了XCode

  1. Open XCode 打开XCode
  2. Open the Downloads preferences pane 打开下载首选项窗格
  3. Find the " Command Line Tools " and install them 找到“ 命令行工具 ”并安装它们

Once you've installed them, close any open terminal windows before proceeding to ensure that the build tools are in your path. 安装它们之后,请关闭所有打开的终端窗口,然后再继续进行操作以确保构建工具在您的路径中。

Installing Ruby 安装Ruby

There are a few ways to get Ruby going on a new linux system, but the most widely recommended one is to use rvm . 有几种方法可以使Ruby在新的linux系统上运行,但是最广泛推荐的方法是使用rvm

RVM is a tool which helps install and manage different Ruby environments, so you can easily switch between them and upgrade (or downgrade for a specific project or issue). RVM是一种工具,可帮助安装和管理不同的Ruby环境,因此您可以轻松地在它们之间进行切换和升级(或针对特定项目或问题降级)。 It's found here (direct link to the installation instructions) You most likely want to do the first of the Quick guided installs, which will simply install it for your user. 可在此处找到(直接链接到安装说明)。您很可能想进行快速指导安装中的第一个,这将简单地为您的用户安装它。 It'll also install the latest stable version of ruby. 它还将安装最新的稳定版本的ruby。

There is a GUI for installing RVM, called JewelleryBox . 有一个用于安装RVM的GUI,称为JewelleryBox It's fairly pretty and will notify you when there's new versions. 它相当漂亮,当有新版本时会通知您。

Once the app itself is installed: 一旦安装了应用程序本身:

  1. Click Add Ruby in the toolbar 点击工具栏中的添加Ruby
  2. Choose a Ruby version. 选择一个Ruby版本。 MRI is the "Official" ruby... It's the one which kicked everything off. MRI是“官方”红宝石……它是一切的开端。 For now, the latest stable is ruby-1.9.3-p327, so pick that one ;) 现在,最新的马stable是ruby-1.9.3-p327,所以选择一个;)
  3. Make sure the make default checkbox is ticked, then hit the "Install" button. 确保选中“ 默认设置”复选框,然后单击“安装”按钮。
  4. Hopefully everything worked! 希望一切正常!

Installing Rails 安装滑轨

Ruby's almost ubiquitous means of fetching libraries, including Rails, is with rubygems and the gem command. Ruby几乎无处不在的获取库(包括Rails)的方法是使用rubygems和gem命令。 In this case, gem install rails should get you started. 在这种情况下, gem install rails应该可以帮助您入门。 Oh, and make sure you open a new terminal window after installing a new ruby, and check it's installed with ruby -v . 哦,请确保在安装新的ruby之后打开一个新的终端窗口,并检查是否已安装ruby -v

Another nice thing 另一个好东西

Bundler is a neat package manager built on top of rubygems. Bundler是建立在rubygems之上的整洁的软件包管理器。 Install it with gem install bundle (oh, and Rails will install it as a dependancy). 使用gem install bundle安装它(哦,Rails将作为依赖项安装它)。 Its got its docs at this link but for basic, raw rails, you shouldn't need to do anything with it. 它在此链接上有其文档,但是对于基本的原始Rails,您无需对其进行任何操作。

Good Luck 祝好运

Have a blast learning Rails, I hope you find it makes webapp development more fun for you ^_^ 快速学习Rails,希望您发现它使Webapp开发对您来说更有趣^ _ ^

我尝试了很长时间才能使Rails在Mac OS X上平稳运行,而我能找到的最佳解决方案是通过JewelryBox安装。

Do you have the file 你有文件吗

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

cause I don't and I'm on Mac OS X as well... 因为我没有,我也在Mac OS X上...

Firstly create a rvm version with ruby version. 首先用ruby创建一个rvm版本。
And create a gemset with some name under that rvm. 并在该rvm下创建一个具有某些名称的gemset。
Do gem install bundler before installing any thing. 在安装任何东西之前,请先执行gem install bundler
Then install rails with gem install rails which installs the latest version of rails. 然后使用gem install rails ,后者会安装最新版本的rails。
And go ahead. 继续吧

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM