Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.08k stars 9.64k forks source link

FIX do not overwrite common apps across system = Linuxbrew should append instead of prepend $PATH to bin dir #12677++ #13281

Closed allanlaal closed 2 years ago

allanlaal commented 2 years ago

brew config output

allan@L4:~$ brew config
HOMEBREW_VERSION: 3.4.11
ORIGIN: https://github.com/Homebrew/brew
HEAD: 30e3d8883cde265cbc16ff94b49a3ac14137590e
Last commit: 6 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 6685b8c19702d32c5afa90f15972ebd363777adf
Core tap last commit: 3 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_DISPLAY: :0.0
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.8 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/bin/ruby
CPU: octa-core 64-bit haswell
Clang: 14.0.0
Git: 2.34.1 => /bin/git
Curl: 7.81.0 => /bin/curl
Kernel: Linux 5.17.2-051702-generic x86_64 GNU/Linux
OS: Ubuntu 22.04 LTS (jammy)
Host glibc: 2.35
/usr/bin/gcc: 11.2.0
/usr/bin/ruby: 3.0.2
glibc: N/A
gcc@5: N/A
xorg: N/A

brew doctor output

brew doctor
allan@L4:~$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  isl@0.18

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/gtk-layer-shell/gtk-layer-shell.h
allan@L4:~$

Verification

What were you trying to do (and why)?

duplicate of #12677 because of #13280 might be linked to #13170

note: those warnings do not affect this behaviour

I am running a normal Ubuntu Linux 22.04 system, but brew overwrites non brew installed binaries:

included in .bashrc:

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

which in this case is:

  export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew";
  export HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar";
  export HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew";
  export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}";
  export MANPATH="/home/linuxbrew/.linuxbrew/share/man${MANPATH+:$MANPATH}:";
  export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH:-}";

What happened (include all command output)?

  allan@L4:~$ which zip
  /home/linuxbrew/.linuxbrew/bin/zip

  allan@L4:~$ whereis zip
  zip: /usr/bin/zip /home/linuxbrew/.linuxbrew/bin/zip /usr/share/man/man1/zip.1.gz

What did you expect to happen?

I expect zip to be the more universal /usr/bin/zip

like in #12677 I would also suggest the brew binary dirs should be appended to $PATH, so it wouldn't wreck my bash terminals :)

my goal of including brew shellenv in my .bashrc is so that I would have access to brew installed custom apps

I can't think of any use case where one would want their entire distro overwritten:

  allan@L4:~$ l /home/linuxbrew/.linuxbrew/bin /home/linuxbrew/.linuxbrew/sbin | wc -l
  718

Aren't brew apps run in their own env that uses its own versions of common bins?

Step-by-step reproduction instructions (by running brew commands)

see above
allanlaal commented 2 years ago

current fix for Googlers:

run brew shellenv and get something like:

  export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew";
  export HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar";
  export HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew";
  export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}";
  export MANPATH="/home/linuxbrew/.linuxbrew/share/man${MANPATH+:$MANPATH}:";
  export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH:-}";

then copy that to your .bashrc .zhrc .whatevarc file, position does not matter, BUT change export PATH to append it instead:

old: export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}";
new: export PATH="$PATH:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin"

now common binaries have their proper path:

  allan@L4:~$ which zip
  /usr/bin/zip
  allan@L4:~$ whereis zip
  zip: /usr/bin/zip /home/linuxbrew/.linuxbrew/bin/zip /usr/share/man/man1/zip.1.gz

and custom brew installed apps still seem to run fine, although brew doctor is now angry:

  allan@L4:~$ brew doctor
  Please note that these warnings are just used to help the Homebrew maintainers
  with debugging if you file an issue. If everything you use Homebrew for is
  working fine: please don't worry or file an issue; just ignore this. Thanks!

  Warning: Some installed formulae are deprecated or disabled.
  You should find replacements for the following formulae:
    isl@0.18

  Warning: Unbrewed header files were found in /usr/local/include.
  If you didn't put them there on purpose they could cause problems when
  building Homebrew formulae, and may need to be deleted.

  Unexpected header files:
    /usr/local/include/gtk-layer-shell/gtk-layer-shell.h

  Warning: /usr/bin occurs before /home/linuxbrew/.linuxbrew/bin in your PATH.
  This means that system-provided programs will be used instead of those
  provided by Homebrew. Consider setting your PATH so that
  /home/linuxbrew/.linuxbrew/bin occurs before /usr/bin. Here is a one-liner:
    echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' >> ~/.profile

  The following tools exist at both paths:
    uuidgen
    gobject-query
    unxz
    gio
    gfortran
    jpackage
    jwebserver
    jpgicc
    pacmd
    unlz4
    yacc
    pyuic5
    bsdtar
    paplay
    lsblk
    jcmd
    cjpeg
    zipcloak
    dbus-run-session
    javadoc
    gdbus
    fc-scan
    bzegrep
    python3-config
    icuinfo
    jdeprscan
    xmlcatalog
    uuidparse
    linux64
    xzcat
    linux32
    dbus-cleanup-sockets
    dbus-send
    as
    flac
    bzdiff
    last
    gif2rgb
    parec
    genbrk
    mpif90
    bzmore
    findmnt
    ortecc
    hwloc-annotate
    ionice
    tificc
    libtoolize
    ul
    lastb
    orte-server
    pylupdate5
    msgcat
    fallocate
    infocmp
    bzgrep
    jconsole
    giffix
    msgcmp
    zstdcat
    pkgdata
    fc-cache
    lz4cat
    lzless
    toe
    reset
    java
    pasuspender
    gtester
    whereis
    hwloc-gather-topology
    flock
    colrm
    krb5-config
    ipcmk
    renice
    hwloc-info
    lsipc
    gdbus-codegen
    imagetops
    pactl
    getopt
    bzless
    lslocks
    glib-genmarshal
    mpv
    xzegrep
    gsettings
    zstdmt
    objdump
    mutagen-inspect
    gettext
    mutagen-pony
    gettext.sh
    gcov-dump-11
    keytool
    mid3iconv
    lzfgrep
    x86_64
    addr2line
    jhsdb
    script
    unlzma
    go
    rename
    jps
    rdjpgcom
    lzmore
    msgexec
    pamon
    dwp
    gencnval
    infotocap
    column
    lstopo-no-graphics
    g-ir-annotation-tool
    uclampset
    hwloc-compress-dir
    xzfgrep
    setsid
    unshare
    gio-querymodules
    mid3v2
    transicc
    jrunscript
    orted
    hexdump
    djpeg
    moggsplit
    mpifort
    derb
    bsdcpio
    ld
    setterm
    gtester-report
    psicc
    ompi-clean
    ipcrm
    msgfilter
    look
    mpif77
    nm
    mount
    tabs
    choom
    funzip
    trust
    sqlite3
    msgcomm
    mpic++
    bunzip2
    msgunfmt
    gfortran-11
    msggrep
    utmpdump
    gcov-tool-11
    tic
    linkicc
    jdb
    i386
    compile_et
    lzegrep
    gendict
    serialver
    nsenter
    msgmerge
    libpng-config
    ompi-server
    zip
    chrt
    mid3cp
    bzip2recover
    elfedit
    glib-mkenums
    gresource
    pngfix
    jlink
    msgfmt
    xzdiff
    ranlib
    xzcmp
    glib-compile-schemas
    prlimit
    rev
    glib-gettextize
    lzcmp
    jstatd
    lsns
    mpirun
    fc-validate
    gcc-nm-11
    gcc-11
    fc-match
    xzgrep
    msgattrib
    giftool
    pa-info
    p11-kit
    clear
    hwloc-calc
    orte-clean
    genrb
    jmap
    zipinfo
    lzma
    mpiCC
    g-ir-inspect
    setarch
    lto-dump-11
    ipcs
    g++-11
    mpicxx
    zstdless
    javac
    xgettext
    lz4
    lsmem
    ipptool
    lscpu
    ld.bfd
    mountpoint
    lslogins
    icuexportdata
    zstd
    dbus-daemon
    parecord
    g-ir-generate
    gofmt
    uconv
    wrjpgcom
    ncursesw6-config
    glib-compile-resources
    size
    lzcat
    bsdcat
    pyrcc5
    libtool
    xmllint
    lz4c
    yt-dlp
    openssl
    hwloc-diff
    mcookie
    scriptlive
    msgconv
    xinput
    sdl2-config
    unzipsfx
    hwloc-gather-cpuid
    dbus-monitor
    bzip2
    c++filt
    padsp
    hardlink
    dbus-launch
    pzstd
    ngettext
    jfr
    fc-pattern
    msgen
    captoinfo
    javap
    scriptreplay
    fc-query
    lzmainfo
    ompi_info
    zipnote
    autopoint
    namei
    g-ir-scanner
    libpng16-config
    zipsplit
    mesg
    recode-sr-latin
    bison
    opal_wrapper
    logger
    jstack
    taskset
    hwloc-bind
    hwloc-distrib
    pcre-config
    tset
    jmod
    cpp-11
    mpicc
    xml2-config
    wall
    zstdgrep
    pip3
    wdctl
    jpegtran
    gcov-11
    jshell
    jarsigner
    bzcat
    pulseaudio
    strings
    2to3
    ld.gold
    lzdiff
    png-fix-itxt
    dbus-update-activation-environment
    c_rehash
    gprof
    envsubst
    unzip
    unzstd
    gettextize
    fc-cat
    fc-conflist
    jinfo
    hwloc-ls
    dbus-uuidgen
    m4
    pydoc3
    col
    gcc-ar-11
    lstopo
    eject
    bzcmp
    srconv
    metaflac
    python3
    giftext
    zipgrep
    pkg-config
    jimage
    dmesg
    mpiexec
    gifbuild
    gold
    umount
    ar
    g-ir-compiler
    msguniq
    objcopy
    jdeps
    bzfgrep
    orterun
    jar
    orte-info
    pacat
    ncurses6-config
    msginit
    colcrt
    fincore
    hwloc-ps
    lzgrep
    fc-list
    strip
    rmiregistry
    xzmore
    readelf
    gcc-ranlib-11
    gapplication
    makeconv
    jstat
    xz
    hwloc-patch
    gifclrmp
    tput
    gencfu
    xzless
    more

  allan@L4:~$

with brew config of:

  allan@L4:~$ brew config
  HOMEBREW_VERSION: 3.4.11
  ORIGIN: https://github.com/Homebrew/brew
  HEAD: 30e3d8883cde265cbc16ff94b49a3ac14137590e
  Last commit: 6 days ago
  Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
  Core tap HEAD: 6685b8c19702d32c5afa90f15972ebd363777adf
  Core tap last commit: 3 hours ago
  Core tap branch: master
  HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
  HOMEBREW_CASK_OPTS: []
  HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
  HOMEBREW_DISPLAY: :0.0
  HOMEBREW_MAKE_JOBS: 8
  Homebrew Ruby: 2.6.8 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/bin/ruby
  CPU: octa-core 64-bit haswell
  Clang: 14.0.0
  Git: 2.34.1 => /bin/git
  Curl: 7.81.0 => /bin/curl
  Kernel: Linux 5.17.2-051702-generic x86_64 GNU/Linux
  OS: Ubuntu 22.04 LTS (jammy)
  Host glibc: 2.35
  /usr/bin/gcc: 11.2.0
  /usr/bin/ruby: 3.0.2
  glibc: N/A
  gcc@5: N/A
xorg: N/A
Bo98 commented 2 years ago

This is largely personal preference. The default behaviour of shellenv is unlikely to change because there are equally a number of people who want the current behaviour. Some people install Homebrew for the very reason of wanting to use newer packages than what the system ships, or in some cases because they can't modify what the system ships.

although brew doctor is now angry

This is fine as it's just a debugging help tool useful for tracking down issues. Not everyone will have a fully clear output.

allanlaal commented 2 years ago

@Bo98 @kevincianfarini @MikeMcQuaid

how about branching brew shellenv into a second use case to solve this somewhat smaller use case, where users want linuxbrew only to install apps they cant install with other package managers (mainly MacOS apps)

MikeMcQuaid commented 2 years ago

Sorry, not interested in changing the default behaviour here. As @Bo98 mentioned this is personal preference that you can handle yourself and ignore the brew doctor complaints.

Natr1x commented 2 years ago

I very much question the decision of overriding system applications by default.

The kind of person who wants to use brew for everything is also likely to be the kind of person who have no trouble configuring brew themselves. Wheras someone who uses it for some one-of applications is probably less likely to know how/want to configure them.

I know at least I personally was very confused to no longer have man pages for the binutils.

Bo98 commented 2 years ago

I know at least I personally was very confused to no longer have man pages for the binutils.

That's a bug rather than anything here.

brew shellenv does not hide system manpages, but it looks like you might actually have Homebrew's binutils installed and it appears that unintentionally contains empty manpages. I'll get them fixed or removed.

Natr1x commented 2 years ago

I know at least I personally was very confused to no longer have man pages for the binutils.

That's a bug rather than anything here.

brew shellenv does not hide system manpages, but it looks like you might actually have Homebrew's binutils installed and it appears that unintentionally contains empty manpages. I'll get them fixed or removed.

Well that would be nice of you, I was not entirely certain who was responsible for the package so I did not really know where I was supposed to submit an issue. Though admittedly I haven't exactly looked very hard.

It was more an example of how someone who did not plan on replacing apt may find brew shellenv's current defaults to be more confusing than it would be for someone who did plan on replacing apt if they were changed.

MikeMcQuaid commented 2 years ago

I very much question the decision of overriding system applications by default.

The kind of person who wants to use brew for everything is also likely to be the kind of person who have no trouble configuring brew themselves.

If these people have no trouble configuring brew themselves: they can decide to put brew at the end of their PATH.

allanlaal commented 2 years ago

@MikeMcQuaid if I add an extra command flag (to https://github.com/Homebrew/brew/blob/master/Library/Homebrew/cmd/shellenv.sh#L13 ) for us weird people preferring our own Distros, will you accept the PR? :)

note: the "normal" use case would get a comment line inserted as the last line that explains #THIS and gives an alternative brew shellenv secondary or sth command for us. I think most of weird people like us will prolly check their shells rc file

allanlaal commented 2 years ago

to be fair, it took me ≥1year to figure out whats going on, so would've been awesome if brew installer would've asked me if I want brew to be my secondary or primary almost-distro-like-package-provider

kevincianfarini commented 2 years ago

It also took me an incredibly long time to figure out what was going on when I was experiencing this issue. The main symptom was that applications like Slack, Postman, and Geary wouldn't be able to establish an SSL connection. It took a long time to even figure out it was something related to brew.

I imagine that a lot of people who use linuxbrew are going to experience similar issues and not know what's going on.

MikeMcQuaid commented 2 years ago

@MikeMcQuaid if I add an extra command flag (to https://github.com/Homebrew/brew/blob/master/Library/Homebrew/cmd/shellenv.sh#L13 ) for us weird people preferring our own Distros, will you accept the PR? :)

No. Just set your PATH yourself rather than using brew shellenv if that's what you want.