seanshpark / macOS

problems and solutions
MIT License
0 stars 0 forks source link

Homebrew #2

Open seanshpark opened 2 years ago

seanshpark commented 2 years ago

Playing with Homebrew...

seanshpark commented 2 years ago

My internal SSD is 256G, not enough to install programs without worry...

Let's use SSD for home of brew.

seanshpark commented 2 years ago

Installation

seanshpark commented 2 years ago

Cache files in $HOME/Library/Caches ?

There's an environment variable that can redirect to external drive

export HOMEBREW_CACHE=/Volumes/HDD/Library.user/Caches/Homebrew
seanshpark commented 2 years ago

Installing python3

brew install python3
brew install python3-pip --> X
brew install python3-venv --> X

Add: warnings while running brew install python3

Warning: Building pkg-config from source:
  The bottle needs to be installed into /opt/homebrew
...
Warning: Building openssl@1.1 from source as the bottle needs:
- HOMEBREW_CELLAR: /opt/homebrew/Cellar (yours is /Volumes/SSD/homebrew/Cellar)
- HOMEBREW_PREFIX: /opt/homebrew (yours is /Volumes/SSD/homebrew)
...
Warning: Building python@3.9 from source:
  The bottle needs the Apple Command Line Tools to be installed.
  You can install them, if desired, with:
    xcode-select --install
brew install virtualenv

need a reboot to use brew python3 instead of system /usr/bin/python3 --> open new terminal


mac's python 2.x is in /System as

ll /System/Library/Frameworks/Python.framework/Versions 
total 0
drwxr-xr-x   7 root  wheel  224 Dec  8 08:39 ./
drwxr-xr-x   5 root  wheel  160 Dec  8 08:39 ../
lrwxr-xr-x   1 root  wheel    3 Dec  8 08:39 2.3@ -> 2.7
lrwxr-xr-x   1 root  wheel    3 Dec  8 08:39 2.5@ -> 2.7
lrwxr-xr-x   1 root  wheel    3 Dec  8 08:39 2.6@ -> 2.7
drwxr-xr-x  11 root  wheel  352 Dec  8 08:39 2.7/
lrwxr-xr-x   1 root  wheel    3 Dec  8 08:39 Current@ -> 2.7

but python3 is in usr/bin

ll /usr/bin/python3
-rwxr-xr-x  1 root  wheel  167088 Dec  8 08:39 /usr/bin/python3*

--

manually add symbolic link in homebrew/bin

and as before, need reboot to take effect...? --> open new terminal

emsspree commented 2 years ago

Hi,

you don’t need to reboot, just start a new shell session. If it does not work it is configured wrong.

Homebrew installs “formulae” in /usr/local/Cellar, not in ………/homebrew/bin. It creates symlinks in /usr/local/bin and/or /usr/local/opt and updates them when a formula is updates. Instead of trying to install Homebrew into another location install it the normal way and move Cellar to your external SSD, then create a symlink: ln -s /Volumes/SSD/Cellar /usr/local/Cellar (same for “casks”, they are in /usr/local/Caskroom)

You should not have ………/homebrew/bin in PATH. Instead, have /usr/local/bin before /usr/bin/ in PATH. This should be pre-configured in Big Sur and newer (don’t know if it was in Catalina already). Check your PATH with printenv PATH and, if needed, edit /private/etc/paths.

You also should not try to symlink python3 as python, it can cause many problems.

Read: https://docs.brew.sh/Homebrew-and-Python and https://docs.python-guide.org/starting/install3/osx/

seanshpark commented 2 years ago

you don’t need to reboot, just start a new shell session. If it does not work it is configured wrong.

Wow, may thanks! I didn't expect someone will look at my logging :) I'll study more and check my configuration!

seanshpark commented 2 years ago

What should happen

emsspree commented 2 years ago

Wow, may thanks! I didn't expect someone will look at my logging :) I'll study more and check my configuration!

I came across it while browsing GitHub while bored on the train 😉

What should happen

  • symbolic links from Cellar to /usr/local/xxx instead in homebrew/xxx
  • where xxx are bin, lib, include, share and more?

You don’t have to create symlinks, Homebrew does it for you. Under /usr/local/Homebrew/ is the program itself installed but not the packages. The packages are installed under /usr/local/Cellar in sub-dirs with the version number in their names. Every time you upgrade, the version number is changed.

When it upgrades packages, Homebrew will re-create/change symlinks or move/copy files to their needed locations. So you don’t have to care about.

You can do: Move the Cellar directory to your external drive and create a symlink (ln -s /Volumes/SSD/Cellar /usr/local/Cellar). You could use the environment variable HOMEBREW_CELLAR but then you have to change more than only that.

seanshpark commented 2 years ago

node install

brew install node
% node --version   
v17.3.0

% npm --version
8.3.0
seanshpark commented 2 years ago
brew install llvm
To use the bundled libc++ please add the following LDFLAGS:
  LDFLAGS="-L/Volumes/SSD/homebrew/opt/llvm/lib -Wl,-rpath,/Volumes/SSD/homebrew/opt/llvm/lib"

llvm is keg-only, which means it was not symlinked into /Volumes/SSD/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have llvm first in your PATH, run:
  echo 'export PATH="/Volumes/SSD/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc

For compilers to find llvm you may need to set:
  export LDFLAGS="-L/Volumes/SSD/homebrew/opt/llvm/lib"
  export CPPFLAGS="-I/Volumes/SSD/homebrew/opt/llvm/include"