开发者

brew installation for zsh?

Hi I just followed the thoughtbot laptop setup for my Mac Mini Server running OSX Lion Server. I'm not sure that everything is installed correctly. Please advise.

I don't have a ~/.bash_profile or ~/.bashrc but i do have a ~/.profile

But here are contents for .zshrc since I use .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 b开发者_如何学Cindkey "^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 complains with brew doctor

[~] 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)

So how can I ensure brew is installed correctly and remove the errors from brew doctor?


This worked for me on macOS ARM (Apple M1):

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

and then:

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


Try setting this line in your .zshrc

export PATH=/usr/local/bin:$PATH


This worked for me:

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


Not sure if this is late but you can simply run this to add Homebrew to your PATH:

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


I use ohmyzsh. Go to the directory

cd /usr/local/bin
brew doctor

You will notice it shows warnings like:

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

You will have to run a command here:

brew link zsh

And that link it for me.


Open the ~/.zshrc file first line in file says

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

just comment out second line it will start working :)


Following @Sajjad's answer did help but I had to run that command every time I started a new terminal which was

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

I don't know much unix but what's going on here I believe is that we are appening export PATH="/opt/homebrew/bin:$PATH" part to our .zshrc file which at the root of our file structure at the end of the file.

So, I ran

nano ~/.zshrc

and added

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

at the end and it worked for all terminals from then on.

I am on the M1 if that is relevant


After installing Homebrew by the below command

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

Run

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

Then run

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

This will evaluate if your setup for Homebrew is working fine or not. You can run brew help to ensure that brew is defined in your zsh profile.


For some reason none of the solutions here worked for me until I had to put both of the following two lines into my .zshrc file

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

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

Then restart your zsh shell and it should work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜