ruby 如何在 OSX 上从自制​​软件中避免“无法加载此类文件 -- utils/popen”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24652996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 06:31:53  来源:igfitidea点击:

How to avoid "cannot load such file -- utils/popen" from homebrew on OSX

rubymacosrubygemshomebrew

提问by kerokero

I'm getting an error when I run brewin the terminal:

brew在终端中运行时出现错误 :

 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- utils/popen (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Library/Homebrew/utils.rb:6:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Library/Homebrew/global.rb:9:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Library/brew.rb:16:in `<main>'

These are my gem settings:

这些是我的宝石设置:

- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-02-24 patchlevel 451) [universal.x86_64-darwin13]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
  - ruby
  - universal-darwin-13
- GEM PATHS:
  - /Library/Ruby/Gems/2.0.0
  - /Users/ronaldkwan/.gem/ruby/2.0.0
  - /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
- GEM CONFIGURATION:
  - :update_sources => true
  - :verbose => true
  - :backtrace => false
  - :bulk_threshold => 1000

回答by Vineet Kapoor

The problem mainly occurs after updating OS X to El Capitan (OS X 10.11) or macOS Sierra (macOS 10.12).

该问题主要发生在将 OS X 更新到 El Capitan (OS X 10.11) 或 macOS Sierra (macOS 10.12) 之后。

This is because of file permission issues with El Capitan's or later macOS's new SIP process. Try changing the permissions for the /usr/localdirectory:

这是因为 El Capitan 或更高版本 macOS 的新 SIP 进程存在文件权限问题。尝试更改/usr/local目录的权限:

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

If it still doesn't work, use these steps inside a terminal session and everything will be fine:

如果它仍然不起作用,请在终端会话中使用这些步骤,一切都会好起来的:

cd /usr/local/Library/Homebrew  
git reset --hard  
git clean -df
brew update

This may be because homebrew is not updated.

这可能是因为自制软件没有更新。

回答by richarddong

First, open a terminal session and run:

首先,打开一个终端会话并运行:

cd /usr/local/
git status

to see if Homebrew is clean.

看看 Homebrew 是否干净。

If it's dirty, run:

如果它很脏,请运行:

git reset --hard && git clean -df

then

然后

brew doctor
brew update

If it's still broken, try this in your session:

如果它仍然坏了,请在您的会话中尝试此操作:

sudo rm /System/Library/Frameworks/Ruby.framework/Versions/Current
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8 /System/Library/Frameworks/Ruby.framework/Versions/Current

This will force Homebrew to use Ruby 1.8 from the system's installation.

这将强制 Homebrew 使用系统安装中的 Ruby 1.8。

回答by odemolliens

Uninstall homebrew:

卸载自制软件:

 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

Then reinstall

然后重新安装

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Warning: This script will remove: /Library/Caches/Homebrew/- thks benjaminsila

警告:此脚本将删除:/Library/Caches/Homebrew/- thks benjaminsila

回答by Inanc Gumus

In my case I just needed to removeHomebrew's executable using:

在我的情况下,我只需要使用以下命令删除Homebrew 的可执行文件:

sudo rm -f `which brew`

Then reinstallHomebrew:

然后重新安装Homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

回答by Josef Rysanek

After updating to El Capitan, /usr/localhas root:wheelrights.

更新到 El Capitan 后,/usr/local拥有root:wheel权利。

Change the rights back to the user using:

使用以下命令将权限更改回用户:

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

and:

和:

brew doctor && brew update

This helped me to get Homebrew working again.

这帮助我让 Homebrew 再次工作。

回答by d0ping

First I executed:

首先我执行:

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

Then:

然后:

cd $(brew --prefix) && git fetch origin && git reset --hard origin/master

回答by Fred

This issue should be fixed in the newest version of Homebrew. Try reinstalling it, which is described on the Homebrewhome page.

这个问题应该在最新版本的 Homebrew 中修复。尝试重新安装它,这在Homebrew主页上有描述。

回答by Dennis

To me it feels like you have missing header files for popen, which is a C system library.

对我来说,感觉就像你缺少 popen 的头文件,它是一个 C 系统库。

Check if you have installed xcode successful with the command line tools and have accepted the license.

检查您是否已使用命令行工具成功安装 xcode 并已接受许可证。

See this thread for more information: How to install Xcode Command Line Tools

有关更多信息,请参阅此主题:如何安装 Xcode 命令行工具

回答by mrded

To restore your Homebrew setup try this:

要恢复您的 Homebrew 设置,请尝试以下操作:

cd /usr/local/Homebrew/Library && git stash && git clean -d -f && git reset --hard && git pull