zsh 的brew 安装?

问题描述 投票:0回答:10

嗨,我刚刚按照 Thoughtbot 笔记本电脑设置运行 OSX Lion 的 Mac Mini 服务器 服务器。我不确定一切是否安装正确。请指教。

我没有

~/.bash_profile
~/.bashrc
,但我有
~/.profile

但是这里是

.zshrc
的内容,因为我使用
.zsh

   1 # load our own completion functions
   2 fpath=(~/.zsh/completion $fpath)
   3 
   4 # completion
   5 autoload -U compinit
   6 compinit
   7 
   8 # automatically enter directories without cd
   9 setopt auto_cd
  10 
  11 # use vim as an editor
  12 export EDITOR=vim
  13 
  14 # aliases
  15 if [ -e "$HOME/.aliases" ]; then
  16   source "$HOME/.aliases"
  17 fi
  18 
  19 # vi mode
  20 bindkey -v
  21 bindkey "^F" vi-cmd-mode
  22 bindkey jj vi-cmd-mode
  23 
  24 # use incremental search
  25 bindkey "^R" history-incremental-search-backward
  26 
  27 # add some readline keys back
  28 bindkey "^A" beginning-of-line
  29 bindkey "^E" end-of-line
  30 
  31 # handy keybindings
  32 bindkey "^P" history-search-backward
  33 bindkey "^Y" accept-and-hold
  34 bindkey "^N" insert-last-word
  35 bindkey -s "^T" "^[Isudo ^[A" # "t" for "toughguy"
  36 
  37 # expand functions in the prompt
  38 setopt prompt_subst
  39 
  40 # prompt
  41 export PS1='[${SSH_CONNECTION+"%n@%m:"}%~] '
  42 
  43 # ignore duplicate history entries
  44 setopt histignoredups
  45 
  46 # keep TONS of history
  47 export HISTSIZE=4096
  48 
  49 # look for ey config in project dirs
  50 export EYRC=./.eyrc
  51 
  52 # automatically pushd
  53 setopt auto_pushd
  54 export dirstacksize=5
  55 
  56 # awesome cd movements from zshkit
  57 setopt AUTOCD
  58 setopt AUTOPUSHD PUSHDMINUS PUSHDSILENT PUSHDTOHOME
  59 setopt cdablevars
  60 
  61 # Try to correct command line spelling
  62 setopt CORRECT CORRECT_ALL
  63 
  64 # Enable extended globbing
  65 setopt EXTENDED_GLOB
  66 
  67 # RVM
  68 [[ -s '/Users/pma/.rvm/scripts/rvm' ]] && source '/Users/pma/.rvm/scripts/rvm'

Brew 向 Brew 医生投诉

[~] brew doctor
/usr/bin is in your PATH before Homebrew's bin. This means that system-
provided programs will be used before Homebrew-provided ones. This is an
issue if you install, for instance, Python.

Consider editing your .bashrc to put:
  /usr/local/bin
ahead of /usr/bin in your $PATH.

zsh:

[~] zsh --version
zsh --version
zsh 4.3.11 (i386-apple-darwin11.0)

那么如何确保brew安装正确并消除brew doctor中的错误?

zsh homebrew
10个回答
133
投票

这对我在 macOS ARM (Apple M1) 上有效:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

然后:

export PATH="/opt/homebrew/bin:$PATH" >> ~/.zshrc

84
投票

尝试在您的

.zshrc

中设置此行
export PATH=/usr/local/bin:$PATH

27
投票

这对我有用:

export PATH="/usr/local/bin:$PATH" >> ~/.zshrc

22
投票

不确定这是否已经晚了,但您可以简单地运行此命令将 Homebrew 添加到您的

PATH

eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)

11
投票

我使用ohmyzsh。进入目录

cd /usr/local/bin
brew doctor

您会注意到它显示如下警告:

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
autoconf
automake
gdbm
gnupg
libgpg-error
libksba
libtool
libyaml
mongodb
node
pcre
pkg-config
zsh

您必须在此处运行命令:

brew link zsh

这为我链接了。


9
投票

遵循@Sajjad 的回答确实有帮助,但每次我启动一个新终端时都必须运行该命令

export PATH="/opt/homebrew/bin:$PATH" >> ~/.zshrc

我不太了解unix,但我相信这里发生的事情是我们正在追加

export PATH="/opt/homebrew/bin:$PATH"
部分到我们的
.zshrc
文件,位于文件末尾的文件结构的根部。

所以,我跑了

nano ~/.zshrc

并添加了

export PATH="/opt/homebrew/bin:$PATH" 

最后,从那时起它适用于所有终端。

我在 M1(如果相关的话)


8
投票

打开 ~/.zshrc 文件,文件第一行显示

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

只需注释掉第二行,它就会开始工作:)


5
投票

通过以下命令安装 Homebrew 后

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

奔跑

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/atubasi/.zprofile

然后运行

eval "$(/opt/homebrew/bin/brew shellenv)"

这将评估您的 Homebrew 设置是否正常工作。您可以运行

brew help
以确保您的 zsh 配置文件中定义了brew。


0
投票

由于某种原因,这里的解决方案都不适合我,直到我不得不将以下两行的both放入我的.zshrc文件中

export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"

export PATH="/home/linuxbrew/.linuxbrew/sbin:$PATH"

然后重新启动您的 zsh shell,它应该可以工作。


0
投票

要永久修复,只需执行以下命令:

echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
© www.soinside.com 2019 - 2024. All rights reserved.