在Mac OSX 10.8.2上安装Jekyll时出错

时间:2013-01-27 22:24:14

标签: ruby macos command-line installation jekyll

我是Ruby新手,对命令行来说比较新。我正在尝试安装Jekyll来构建静态站点,并且遇到了一些问题。我安装了Ruby v.1.8.7和Ruby Gems v.1.8.25,但是当我运行时出现这个错误:

$ sudo gem install jekyll

我明白了:

Building native extensions.  This could take a while...
ERROR:  Error installing jekyll:
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/fast-stemmer-1.0.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/fast-stemmer-1.0.1/ext/gem_make.out

有谁能告诉我如何为ruby安装头文件?我需要将它们安装在特定目录中吗?我是否需要将Ruby完全重新安装在不同的目录中,因为这是我的Mac附带的原始安装/设置?

更新

我已经安装了XCode并安装了RVM,但我无法超越这一点。当我尝试安装Ruby时,我得到了这个:

Daniels-MacBook-Air:~ danielrosenthal$ rvm -v

rvm 1.18.3 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

Daniels-MacBook-Air:~ danielrosenthal$ rvm install 1.8.7
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-1.8.7-p371.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
The provided compiler '/usr/bin/gcc' is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.
Daniels-MacBook-Air:~ danielrosenthal$ rvm requirements
Requirements for osx/10.8/x86_64

NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
             This is the *original* / standard Ruby Language Interpreter
      'ree'  represents Ruby Enterprise Edition
      'rbx'  represents Rubinius

Additional Dependencies:
# For update-system:
Always update your system first!

# For rvm:
Install: bash curl git patch

# For ruby:
Install: osx-gcc-installer libksba openssl libreadline git zlib1g libyaml libsqlite3     sqlite3 libxml2 libxslt autoconf libc6 libgdbm ncurses automake libtool bison pkg-config

# For jruby:
Install: openjdk ant

有人可以帮我解决这个问题吗?提前谢谢。

3 个答案:

答案 0 :(得分:4)

超越(或取而代之,取决于工具)Xcode,您需要命令行工具,可以从Xcode中的首选项窗格安装。 Xcode可以在App Store中找到,应该是免费的或非常便宜。

顺便说一句,我强烈建议你不要乱用系统自己的红宝石;安装rvm以获得完全隔离的ruby版本(您可以选择您喜欢的版本),您可以在其中安装所有宝石。

安装rvm后,只需执行以下操作:

rvm install 1.8.7
rvm use 1.8.7
gem install jekyll

<强>更新

如果你需要gcc来编译某个版本的Ruby,你应该install homebrew,然后使用这个命令安装gcc:

brew tap homebrew/dupes && brew install apple-gcc42

否则尝试安装ruby 1.9.3,其中AFAIK应该与LLVM / GCC一起使用(我现在不在Mac上,无法检查)。

答案 1 :(得分:0)

我过去做过这个,但不记得所有的细节。您可以尝试在超级用户上查看此相关帖子(解决方案#2:“找不到头文件”):https://superuser.com/questions/154292/ruby-rubygems-why-do-i-always-get-error-messages-when-trying-to-install-gems

答案 2 :(得分:0)

如果您尚未安装Xcode,请安装Xcode(https://developer.apple.com/xcode/)。 Plus 您需要命令行工具。

打开Xcode。转到Preferences > Downloads > Install Command Line Tools