ruby - 在 Mac OSX 10.8.2 上安装 Jekyll 时出错

标签 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 <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="394e5840575c5c4a5c5e4c5057795e54585055175a5654" rel="noreferrer noopener nofollow">[email protected]</a>>, Michal Papis <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a2cfd2c3d2cbd1e2c5cfc3cbce8cc1cdcf" rel="noreferrer noopener nofollow">[email protected]</a>> [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

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

最佳答案

除了(或者不是,这取决于工具)Xcode,您还需要命令行工具,它可以从 Xcode 中的首选项 Pane 安装。 Xcode 可以在 App Store 中找到,并且应该是免费的或非常便宜。

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

安装 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,据我所知应该可以与 LLVM/GCC 一起使用(我现在不在 Mac 上,无法检查)。

关于ruby - 在 Mac OSX 10.8.2 上安装 Jekyll 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14553023/

相关文章:

Ruby 字符串分割成忽略所有特殊字符的单词 : Simpler query

ruby-on-rails - 如何在子类中包含行为?

C++,是否有可能(以及如何)通过 exec() 运行多 Action 、单行 curl 命令?

java - Mac OS X Activator New Play Framework 错误

c++ - 运行 SDL2 时 Xcode 崩溃

c# - 命令行参数参数限制

ruby-on-rails - 如何在 ruby​​ 中构建这个 JSON 对象?

ruby-on-rails - Ruby GPX 文件解析器

java - 使用JAVA在命令行中实现

windows - 为什么这个 Windows 批处理脚本找不到程序 net.exe?