环境为mac, 总共报了三种错误。

对应三种不同的解法。

1.   第一种如下, 提示 1.8 的版本找不到

$ brew update
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line : /usr/local/Library/brew.rb: Undefined error:

这种比较简单。 原因是mac 升级到 某一个版本之后, ruby版本升级到2.0 了, 但是 brew.rb 中的版本号是 写死了1.8 , 需要修改下。

先检查一下自己 ruby版本   $ cd /System/Library/Frameworks/Ruby.framework/Versions/

一般来说, 都是 2.0

之后  $ vi  /usr/local/Library/brew.rb    将第一行的 1.8 , 修改成 2.0 即可。

详细见:  http://stackoverflow.com/questions/24225959/how-to-get-ruby-homebrew-rvm-to-work-on-yosemite


2. 第二种情况, 错误提示如下。

$ brew update
/Library/Ruby/Site/2.0./rubygems/ext/builder.rb::in `run': ERROR: Failed to build gem native extension. (Gem::Ext::BuildError) /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile make "DESTDIR=" clean make "DESTDIR="
compiling monitor.c
In file included from monitor.c::
In file included from ./nio4r.h::
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0./ruby/backward/rubyio.h::: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
^
warning generated.
In file included from monitor.c::
In file included from ./nio4r.h::
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0./ruby/backward/rubyio.h::: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
^
warning generated.
compiling nio4r_ext.c
In file included from nio4r_ext.c::
In file included from ./nio4r.h::
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0./ruby/backward/rubyio.h::: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
^
In file included from nio4r_ext.c::
./../libev/ev.c::: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL 0.00000095367431640625 /* 1/2**20, good till 2200 */
^
./../libev/ev.c::: error: '_Noreturn' keyword must precede function declarator
ecb_inline void ecb_unreachable (void) ecb_noreturn;
^~~~~~~~~~~~
_Noreturn
./../libev/ev.c::: note: expanded from macro 'ecb_noreturn'
#define ecb_noreturn _Noreturn
^
./../libev/ev.c::: warning: 'extern' variable has an initializer [-Wextern-initializer]
EV_API_DECL struct ev_loop *ev_default_loop_ptr = ; /* needs to be initialised to make it a definition despite extern */

make failed, exit code 2


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nio4r-1.0.0 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-16/2.0.0/nio4r-1.0.0/gem_make.out
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:51:in `block in make'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:43:in `each'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:43:in `make'
from /Library/Ruby/Site/2.0.0/rubygems/ext/ext_conf_builder.rb:43:in `block in build'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tempfile.rb:324:in `open'
from /Library/Ruby/Site/2.0.0/rubygems/ext/ext_conf_builder.rb:17:in `build'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:161:in `block (2 levels) in build_extension'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:160:in `chdir'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:160:in `block in build_extension'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:159:in `synchronize'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:159:in `build_extension'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:198:in `block in build_extensions'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:195:in `each'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:195:in `build_extensions'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1436:in `block in build_extensions'
from /Library/Ruby/Site/2.0.0/rubygems/user_interaction.rb:45:in `use_ui'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1434:in `build_extensions'
from /Library/Ruby/Site/2.0.0/rubygems/stub_specification.rb:60:in `build_extensions'
from /Library/Ruby/Site/2.0.0/rubygems/basic_specification.rb:56:in `contains_requirable_file?'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:925:in `block in find_inactive_by_path'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:924:in `each'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:924:in `find'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:924:in `find_inactive_by_path'
from /Library/Ruby/Site/2.0.0/rubygems.rb:185:in `try_activate'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from /usr/local/Library/Homebrew/extend/pathname.rb:2:in `<top (required)>'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Library/Homebrew/global.rb:3:in `<top (required)>'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Library/brew.rb:17:in `<main>'


这种情况, 需要升级 gem 的版本。

一般来说是用  $ sudo gem update --system  来进行升级, 但是会报错。

$ sudo gem update --system
Password:
Sorry, try again.
Password:
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Not Found (http://ruby.taobao.org/specs.4.8.gz)

这种错误, 因为 gem源换了, 貌似原来的淘宝源不维护了。  具体见: https://ruby.taobao.org/  。 需要跟换一下gem源

$ sudo gem update --system
Password:
Updating rubygems-update
Fetching: rubygems-update-2.6..gem (%)
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/update_rubygems

这种错误也没明白, 提示是 没有操作权限。  在网上查了一个方法, 修改命令成如下方式就可以了。

$ sudo gem update -n /usr/local/bin --system

执行完成之后, gem -v 可以看到 版本更新了。

这样, 第二个 gem update的错误,就快要解决了。


第三个问题, 继续 brew update, 出现如下错误。

$ brew update
/Library/Ruby/Site/2.0./rubygems/core_ext/kernel_require.rb::in `require': cannot load such file -- mach (LoadError)
from /Library/Ruby/Site/2.0./rubygems/core_ext/kernel_require.rb::in `require'
from /usr/local/Library/Homebrew/extend/pathname.rb::in `<top (required)>'
from /Library/Ruby/Site/2.0./rubygems/core_ext/kernel_require.rb::in `require'
from /Library/Ruby/Site/2.0./rubygems/core_ext/kernel_require.rb::in `require'
from /usr/local/Library/Homebrew/global.rb::in `<top (required)>'
from /Library/Ruby/Site/2.0./rubygems/core_ext/kernel_require.rb::in `require'
from /Library/Ruby/Site/2.0./rubygems/core_ext/kernel_require.rb::in `require'
from /usr/local/Library/brew.rb::in `<main>'

根据 http://stackoverflow.com/questions/24652996/homebrew-not-working-on-osx  的最高票答案就可以解决。

$ sudo chown -R $(whoami):admin /usr/local  

如果这个指令没有解决, 则采用下面的步骤。 
1. open terminal
2. $ cd /usr/local/Homebrew , 这里的路径我是: /usr/local/Library/
3. $ git reset --hard
4. $ git clean -df
5. $ brew update
至此, 这个问题解决了。

mac brew update 报错的更多相关文章

  1. mac下brew install 报错

    mac下brew install 报错 错误提示: 原因:是这个brew的权限不正确 修改一下这个brew的权限 chown root:wheel /usr/local/bin/brew

  2. Mac 下使用brew install 报错: Cowardly refusing to `sudo brew install'

    Mac 下使用brew install 报错: localhost:infer-osx-v0.6.0 admin$ sudo brew install opam Error: Cowardly ref ...

  3. Mac安装MySQL-python报错解决

    Mac安装MySQL-pyhton报错 今天在Mac上安装MySQL-python报错,搜遍网络都说什么mysql config路径问题,但是都不行. 解决方案 一开始遇到的问题是: Complete ...

  4. mysql执行update报错1175解决方法

    mysql执行update报错 update library set status=true where 1=1 Error Code: 1175. You are using safe update ...

  5. mysql执行update报错 Err] 1055 - 'information_schema.PROFILING.SEQ' isn't in GROUP BY

    mysql执行update报错 Err] 1055 - 'information_schema.PROFILING.SEQ' isn't in GROUP BY 今天开发的同事发来如下错误信息,最最简 ...

  6. kali linux 2.0配置更新源后apt-get update 报错

    这个是我/etc/apt/sources.list的更新源: deb http://http.kali.org/kali kali-rolling main contrib non-free deb ...

  7. Mac Angular打包报错xcode-select: error: tool 'xcodebuild' requires Xcode

    Mac Angular打包报错: Error: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer ...

  8. apt-get update 报错 W: Unknown Multi-Arch type 'no' for package 'compiz-core'

    源 #deb包 deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http:// ...

  9. Docker ubuntn 使用apt-get update报错

    在docker 容器中执行apt-get update有时候会报错,当然造成错误的原因有很多情况,具体情况具体分析, APT Hash sum mismatch错误的常见解决方法总结这篇博客写的不错, ...

随机推荐

  1. tfs 禁止多人签出

    好久没用tfs了,忘了怎么设置了,记录下 编辑----->高级

  2. Ado.net 访问Oracle乱码问题

    之前安装Oracle - OraClient10g_home1客户端,用Ado.net访问没有问题,后来安装ODP之后,自动的又安装了Oracle - OraClient12Home1,之后就出现乱码 ...

  3. [iOS]深入理解GCD

    看到一篇很好的文章,本来想翻译的,但发现已经有人翻译了,遂简单整理了一下,方便阅读学习 新博客[wossoneri.com] 什么是GCD GCD(Grand Central Dispatch)是li ...

  4. python网络编程:socketserver的基本使用

    本文内容: socketserver的介绍 socketserver的使用 socketserver的异步服务端 首发时间:2018-03-21 也可以使用socketserver来创建socket ...

  5. Excel实用录入技巧

    一.文本录入技巧 输入开头为0的序号 当直接输入单元格中的数字第一个为0时系统会默认去掉 只需要经单元格格式改为文本或者在单元格输入前使用英文状态下的单引号(‘) 例如:'0001 >>& ...

  6. 基于Bootstrap表单验证

    基于Bootstrap表单验证 GitHub地址:https://github.com/chentangchun/FormValidate 使用方式: 1.CSS样式 .valierror { bor ...

  7. Linux下内存查看命令

    在Linux下面,我们常用top命令来查看系统进程,top也能显示系统内存.我们常用的Linux下查看内容的专用工具是free命令. Linux下内存查看命令free详解: 在Linux下查看内存我们 ...

  8. 利用PCA进行故障监测

    利用PCA进行故障监测,传统的统计指标有两种:Hotelling-T2和平方预测误差(Squared prediction error, SPE).T2统计量反映了每个主成分在变化趋势和幅值上偏离模型 ...

  9. awk实战演示

    awk:报告生成器,格式化文本输出. 我们一般使用的awk命令其实就是gawk,在centos7系统下,awk是gawk的链接文件. 基本用法:gawk [options] 'program'  FI ...

  10. Linux防火墙基础与编写防火墙规则

    Iptables采用了表和链的分层结构,每个规则表相当于内核空间的一个容器,根据规则集的不同用途划分为默认的四个表,raw表,mangle表,nat表,filter表,每个表容器内包括不同的规则链,根 ...