ruby-on-rails - OS X 10.10 后 Yosemite 安装 Rails 错误

标签 ruby-on-rails ruby rvm

我全新安装了 Mac OS Yosemite,但现在 Rails 无法正常工作。

当我尝试执行 rails s 时,它告诉我执行 bundle install

我在尝试运行 bundle install 后收到此消息:

Errno::EACCES: Permission denied - /Users/giowong/rails_project/doctible_pre_treatment/vendor/bundle/ruby/2.0.0/gems/bcrypt-3.1.7/.gitignore

我做了

sudo gem update --system

bundle install

当我这样做时,我得到了这些讨厌的东西:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20141107-39214-1ds3j4x.rb extconf.rb 
checking for ruby/util.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
 need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir  
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
  /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:434:in      `try_do': The compiler failed to generate an executable file. (RuntimeError)
  You have to install development tools first.
from          /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:549:in `block in try_compile'
from        /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:502:in `with_werror'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:549:in `try_compile'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:1044:in `block in have_header'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:1043:in `have_header'
from extconf.rb:14:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in      /Users/giowong/rails_project/doctible_pre_treatment/vendor/bundle/ruby/2.0.0/gems/bcrypt-3.1.7 for inspection.

 Results logged to     /Users/giowong/rails_project/doctible_pre_treatment/vendor/bundle/ruby/2.0.0/extensions/universal-darwin-14/2.0.0/bcrypt-3.1.7/gem_make.out
 An error occurred while installing bcrypt (3.1.7), and Bundler cannot continue.
 Make sure that `gem install bcrypt -v '3.1.7'` succeeds before bundling.

我试过使用

安装
 \curl -sSL https://get.rvm.io | bash -s stable --rails

但运气不好。

最佳答案

我不建议使用 OS X 提供的默认 Ruby,因此请安装 RVM。您还需要安装 Xcode 命令行工具:

xcode-select --install # click install, not Get Xcode

然后验证是否安装了gcc:

gcc --version

然后才运行:

\curl -sSL https://get.rvm.io | bash -s stable --rails

关于ruby-on-rails - OS X 10.10 后 Yosemite 安装 Rails 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26808775/

相关文章:

ruby-on-rails - netzke中如何显示三格

ruby-on-rails - 部分表单渲染但不显示

ruby - 使用 RVM 修复 Mac OS Sierra 上未初始化的常量 OpenSSL::Digest::DSS

bash - $GEM_PATH 通常设置在哪里?

ruby-on-rails - Rails+Builder. 生成没有实体的 XML 输出

javascript - Minitest 的 assert_select 的 capybara 等价物是什么?

ruby-on-rails - 设计两次注册提交表格?

javascript - Rails生产模式下如何压缩/public中的js,css文件

arrays - 将散列视为数组?

ruby - Pow、RVM 和 ZSH 不能一起工作