douglasnaphas / configs

Configuration files for things like bash, screen, and vim
GNU General Public License v2.0
2 stars 1 forks source link

Make the brew installation arch-dependent #9

Closed douglasnaphas closed 2 years ago

douglasnaphas commented 3 years ago

This should vary based on the arch:

# homebrew
BREW_DIR=/opt/homebrew
BREW_BIN_DIR=${BREW_DIR}/bin
BREW_BIN=${BREW_BIN_DIR}/brew
if [[ -e ${BREW_BIN} ]] ; then
  eval "$(${BREW_BIN} shellenv)"
fi

Screen Shot 2021-11-01 at 11 18 47 AM

douglasnaphas commented 3 years ago

I'd want to use /usr/local/bin or whatever brew uses for x86 if arch returns x86. Or use /opt/homebrew if arch indicates ARM64.

douglasnaphas commented 3 years ago

As part of doing this (thinking broadly), I'm going to straighten out my lab VM situation. Currently I can't ssh into dev01.douglasnaphas.com (getting ec2-user@dev01.douglasnaphas.com: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). in response to ssh -i ~/VMs/dev01.douglasnaphas.com/MacBookAir2021-10.pem ec2-user@dev01.douglasnaphas.com). I want to (1) delegate that name to a lab account, and (2) set it up so that when I deploy a CDK stack, dev01.douglasnaphas.com is created and ready.

douglasnaphas commented 3 years ago

https://github.com/cdk-turnkey/just-a-vm/projects/1 is created to accomplish the side quest in the previous comment.

douglasnaphas commented 3 years ago

My x86 Linux VM says this when I install brew:

Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    echo 'eval "$(/home/ec2-user/.linuxbrew/bin/brew shellenv)"' >> /home/ec2-user/.bash_profile
    eval "$(/home/ec2-user/.linuxbrew/bin/brew shellenv)"
- Install Homebrew's dependencies if you have sudo access:
    sudo yum groupinstall 'Development Tools'
  For more information, see:
    https://docs.brew.sh/Homebrew-on-Linux
- We recommend that you install GCC:
    brew install gcc
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh
douglasnaphas commented 3 years ago

A better approach might be to put brew last on the PATH.

That way Homebrew-installed packages will get overridden by shims like pyenv and nvm, and I can override in favor of Homebrew packages by symlinking from /usr/local/bin.

douglasnaphas commented 3 years ago

Pursuant to my last comment, I want a Bash function that will produce PATH -> (PATH, but with the path containing brew in the lowest-priority position).

douglasnaphas commented 3 years ago

I actually need both a universal do the shellenv thing brew installation tells you to put in your .bashrc and a thing at the end of my .bashrc to put brew last in the PATH. The shellenv thing I think does stuff related to other directories brew has to know about.

https://github.com/Homebrew/brew/blob/6913c7c84e51cd9eb3aa78f9dd9f5d7a4dc65d23/Library/Homebrew/brew.sh https://github.com/Homebrew/brew/blob/bd8db0737de7cf3ce7788c0377f08c6b41a1b6db/Library/Homebrew/cmd/shellenv.sh https://github.com/Homebrew/brew/blob/4836ea0ba2119619697af87edf5fdb2280e90238/Library/Homebrew/extend/ENV/super.rb

douglasnaphas commented 3 years ago

My putlast function needs to be looking for the directory that holds brew.

douglasnaphas commented 2 years ago

Now that I think about it, /usr/local/bin should also be first in the path.

douglasnaphas commented 2 years ago

Ugh, on my M1 Mac there is a brew executable in both /opt/homebrew/bin and /usr/local/bin.

| ~/repos/configs @ Douglass-Air (douglasnaphas) [01:43:13] master
| 489 => ls /usr/local/bin/
aws           aws_completer bash          brew          opa           opa-0.28.0    opa-0.33.1    opa-0.34.2

| ~/repos/configs @ Douglass-Air (douglasnaphas) [01:52:31] master Δ
| 490 => ls /opt/homebrew/bin/
2to3             ccmake           gbase64          gdate            gettextize       glink            gnumfmt          gruncon          gstty            guname           idle3.9          md5sum           msguniq          python3          stdbuf           xzcmp
2to3-3.9         chcon            gbasename        gdbm_dump        gexpand          gln              god              gseq             gsum             gunexpand        idn2             msgattrib        ngettext         python3-config   tac              xzdec
acountry         chromium         gbasenc          gdbm_load        gexpr            glogname         gpaste           gsha1sum         gsync            guniq            jq               msgcat           node             python3.9        timeout          xzdiff
adig             cmake            gcat             gdbmtool         gfactor          gls              gpathchk         gsha224sum       gtac             gunlink          lzcat            msgcmp           npm              python3.9-config tmux             xzegrep
ahost            cpack            gchcon           gdd              gfalse           gmd5sum          gpinky           gsha256sum       gtail            guptime          lzcmp            msgcomm          nproc            realpath         tomlq            xzfgrep
autopoint        ctest            gchgrp           gdf              gfmt             gmkdir           gpr              gsha384sum       gtee             gusers           lzdiff           msgconv          npx              recode-sr-latin  truncate         xzgrep
awk              envsubst         gchmod           gdir             gfold            gmkfifo          gprintenv        gsha512sum       gtest            gvdir            lzegrep          msgen            numfmt           runcon           unlzma           xzless
b2sum            event_rpcgen.py  gchown           gdircolors       ggroups          gmknod           gprintf          gshred           gtimeout         gwc              lzfgrep          msgexec          onig-config      sha1sum          unxz             xzmore
base32           factor           gchroot          gdirname         ghead            gmktemp          gptx             gshuf            gtouch           gwho             lzgrep           msgfilter        pinky            sha224sum        wget             yq
basenc           g[               gcksum           gdu              ghostid          gmv              gpwd             gsleep           gtr              gwhoami          lzless           msgfmt           pip3             sha256sum        wheel3
bash             gawk             gcomm            gecho            gid              gnice            greadlink        gsort            gtrue            gyes             lzma             msggrep          pip3.9           sha384sum        xgettext
bashbug          gawk-5.1.0       gcp              genv             ginstall         gnl              grealpath        gsplit           gtruncate        hostid           lzmadec          msginit          ptx              sha512sum        xq
brew             gb2sum           gcsplit          gettext          gjoin            gnohup           grm              gstat            gtsort           htop             lzmainfo         msgmerge         pydoc3           shred            xz
brotli           gbase32          gcut             gettext.sh       gkill            gnproc           grmdir           gstdbuf          gtty             idle3            lzmore           msgunfmt         pydoc3.9         shuf             xzcat

| ~/repos/configs @ Douglass-Air (douglasnaphas) [01:52:46] master Δ
| 491 => ls -l /opt/homebrew/bin/brew
-rwxr-xr-x  1 douglasnaphas  admin  4263 Oct  6 16:18 /opt/homebrew/bin/brew

| ~/repos/configs @ Douglass-Air (douglasnaphas) [01:53:03] master Δ
| 492 => ls -l /usr/local/bin/brew
lrwxr-xr-x  1 douglasnaphas  admin  20 Nov  1 08:25 /usr/local/bin/brew -> ../Homebrew/bin/brew

Screen Shot 2021-12-04 at 1 54 09 AM

douglasnaphas commented 2 years ago

Whatever I'm doing, /opt/homebrew/sbin is now in the path twice 😢 .

| ~/repos/configs @ Douglass-Air (douglasnaphas) [10:19:05] master Δ
| 562 => say_path
/opt/homebrew/bin
/opt/homebrew/sbin
/Users/douglasnaphas/.nvm/versions/node/v16.13.0/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/opt/homebrew/sbin

Screen Shot 2021-12-05 at 10 19 37 AM

douglasnaphas commented 2 years ago

Current changes on my gh-9 branch seem to work well enough.

| ~ @ Douglass-Air (douglasnaphas) [19:20:01]
| 703 => say_path
/Users/douglasnaphas/.nvm/versions/node/v16.13.0/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/opt/homebrew/bin
/opt/homebrew/sbin

| ~ @ Douglass-Air (douglasnaphas) [19:20:06]
| 704 => nvm ls
       v12.22.7
       v14.18.1
->     v16.13.0
         system
default -> 16.13.0 (-> v16.13.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v16.13.0) (default)
stable -> 16.13 (-> v16.13.0) (default)
lts/* -> lts/gallium (-> v16.13.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.7
lts/fermium -> v14.18.1
lts/gallium -> v16.13.0

| ~ @ Douglass-Air (douglasnaphas) [19:20:13]
| 705 => nvm use v12.22.7
Now using node v12.22.7 (npm v8.1.2)

| ~ @ Douglass-Air (douglasnaphas) [19:20:19]
| 706 => node --version
v12.22.7

| ~ @ Douglass-Air (douglasnaphas) [19:20:23]
| 707 =>

Screen Shot 2021-12-05 at 7 20 33 PM

douglasnaphas commented 2 years ago

Actually I do need to put the brew directory last in the path. The brew dir is coming out first in the PATH on Linux with no nvm installed, which is not desired.

| ~/repos/configs @ ip-10-0-118-103 (ec2-user) [00:29:48] gh-9  
| 35 => say_path
/home/ec2-user/.linuxbrew/bin
/home/ec2-user/.linuxbrew/sbin
/usr/local/bin
/usr/bin
/usr/local/sbin
/usr/sbin
/home/ec2-user/.local/bin
/home/ec2-user/bin

Screen Shot 2021-12-05 at 7 33 53 PM

douglasnaphas commented 2 years ago

Seems to be working on Linux now, and still working on Mac M1.

| ~/repos/configs @ ip-10-0-118-103 (ec2-user) [02:03:09] gh-9  
| 51 => say_path
/usr/local/bin
/usr/bin
/usr/local/sbin
/usr/sbin
/home/ec2-user/.local/bin
/home/ec2-user/bin
/home/ec2-user/.linuxbrew/bin
/home/ec2-user/.linuxbrew/sbin

Screen Shot 2021-12-05 at 9 03 40 PM