Linuxbrew / brew

:beer::penguin: The Homebrew package manager for Linux
https://linuxbrew.sh
BSD 2-Clause "Simplified" License
2.65k stars 235 forks source link

linuxbrew cripples itself when using an "external" ruby #566

Closed nega0 closed 6 years ago

nega0 commented 6 years ago

As mentioned in #565, a "clean" linuxbrew fails to build packages when ruby is installed outside of /usr/bin. Using the rh-ruby24 software collection ruby is installed as /opt/rh/rh-ruby24/root/usr/bin/ruby. This necessitates an LD_LIBRARY_PATH containing /opt/rh/rh-ruby24/root/usr/local/lib64:/opt/rh/rh-ruby24/root/usr/lib64. Linuxbrew picks up the Ruby executable fine, but when it tries to use it internally the LD_LIBRARY_PATH is sanitized. This results in an (autotools) build failure looking like:

configure:4959: checking for gcc
configure:4986: result: gcc-4.4
configure:5215: checking for C compiler version
configure:5224: gcc-4.4 --version >&5
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
configure:5235: $? = 127
configure:5224: gcc-4.4 -v >&5
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
configure:5235: $? = 127
configure:5224: gcc-4.4 -V >&5
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
configure:5235: $? = 127
configure:5224: gcc-4.4 -qversion >&5
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
configure:5235: $? = 127
configure:5255: checking whether the C compiler works
configure:5277: gcc-4.4    conftest.c  >&5
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
configure:5281: $? = 127
configure:5319: result: no
configure: failed program was:

This is fixed easily enough by adding the necessary paths to /etc/ld.so.conf, but it's not ideal as it requires root access.

Earlier while investigating other issues, I noticed "portable ruby" was auto-installed several times. For some reason it didn't auto-install with this clean/fresh clone; possibly because I'm forcing source builds. I'll provide a follow up if pre-installing "portable ruby" addresses this issue. The "fix" may then be just a documentation update.

sjackman commented 6 years ago

Linuxbrew includes its own portable-ruby 2.3.3. I'd recommend using this version of Ruby. If you don't have ruby in your PATH, it should get installed automatically the first time you run brew.

nega0 commented 6 years ago

tl;dr - gist-logs

Linuxbrew includes its own portable-ruby 2.3.3. I'd recommend using this version of Ruby. If you don't have ruby in your PATH, it should get installed automatically the first time you run brew.

It should, but it didn't.

I noticed "portable ruby" was auto-installed several times. For some reason it didn't auto-install with this clean/fresh clone;

here's a fresh run:

❯ ssh zinc
[nega@zinc ~] . /opt/rh/devtoolset-4/enable                                        
[nega@zinc ~] . /opt/rh/python27/enable                                            
[nega@zinc ~] . /opt/rh/rh-ruby24/enable                                           
[nega@zinc ~] . /opt/rh/git19/enable                                               
[nega@zinc ~] sudo rm -rf /build/linuxbrew
[nega@zinc ~] sudo git clone https://github.com/Linuxbrew/brew.git /build/linuxbrew
Initialized empty Git repository in /build/linuxbrew/.git/
remote: Counting objects: 105075, done.
remote: Compressing objects: 100% (344/344), done.
remote: Total 105075 (delta 372), reused 469 (delta 301), pack-reused 104413
Receiving objects: 100% (105075/105075), 23.94 MiB | 3.49 MiB/s, done.
Resolving deltas: 100% (76395/76395), done.
[nega@zinc ~]$ sudo chown -R nega:nega /build/linuxbrew/
[nega@zinc ~]$ brew update
Already up-to-date.
[nega@zinc ~]$ brew -v install -s --debug xz
/build/linuxbrew/bin/brew tap homebrew/core
==> Tapping homebrew/core
Cloning into '/build/linuxbrew/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 4680, done.
remote: Compressing objects: 100% (4480/4480), done.
remote: Total 4680 (delta 47), reused 328 (delta 10), pack-reused 0
Receiving objects: 100% (4680/4680), 3.95 MiB | 3.51 MiB/s, done.
Resolving deltas: 100% (47/47), done.
Checking connectivity... done.
Tapped 4469 formulae (4,719 files, 12.4MB)
/build/linuxbrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /build/linuxbrew/Library/Taps/homebrew/homebrew-core/Formula/xz.rb
/build/linuxbrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /build/linuxbrew/Library/Taps/homebrew/homebrew-core/Formula/glibc.rb
/build/linuxbrew/Library/Homebrew/build.rb (Formulary::FromPathLoader): loading /build/linuxbrew/Library/Taps/homebrew/homebrew-core/Formula/xz.rb
/build/linuxbrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /build/linuxbrew/Library/Taps/homebrew/homebrew-core/Formula/binutils.rb
/build/linuxbrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /build/linuxbrew/Library/Taps/homebrew/homebrew-core/Formula/make.rb
/build/linuxbrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /build/linuxbrew/Library/Taps/homebrew/homebrew-core/Formula/python.rb
/build/linuxbrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /build/linuxbrew/Library/Taps/homebrew/homebrew-core/Formula/gcc.rb
/build/linuxbrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /build/linuxbrew/Library/Taps/homebrew/homebrew-core/Formula/glibc.rb
==> Downloading https://downloads.sourceforge.net/project/lzmautils/xz-5.2.3.tar.gz
==> Downloading from https://astuteinternet.dl.sourceforge.net/project/lzmautils/xz-5.2.3.tar.gz
/usr/bin/curl --show-error --user-agent Linuxbrew/1.5.0-25-g34aa15b (Linux; x86_64 "Scientific Linux release 6.9 (Carbon)") curl/7.19.7 --fail --location --remote-time --continue-at - --output /home/nega/.cache/Homebrew/xz-5.2.3.tar.gz.incomplete https://astuteinternet.dl.sourceforge.net/project/lzmautils/xz-5.2.3.tar.gz --connect-timeout 5
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1455k  100 1455k    0     0  1038k      0  0:00:01  0:00:01 --:--:-- 1503k
==> Verifying xz-5.2.3.tar.gz checksum
tar xzf /home/nega/.cache/Homebrew/xz-5.2.3.tar.gz
==> ./configure --disable-debug --disable-dependency-tracking --disable-silent-rules --prefix=/build/linuxbrew/Cellar/xz/5.2.3

XZ Utils 5.2.3

System type:
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu

Configure options:
checking if debugging code should be compiled... no
checking which encoders to build... lzma1 lzma2 delta x86 powerpc ia64 arm armthumb sparc
checking which decoders to build... lzma1 lzma2 delta x86 powerpc ia64 arm armthumb sparc
checking which match finders to build... hc3 hc4 bt2 bt3 bt4
checking which integrity checks to build... crc32 crc64 sha256
checking if external SHA-256 should be used... no
checking if assembler optimizations should be used... x86_64
checking if small size is preferred over speed... no
checking if threading support is wanted... yes, posix
checking how much RAM to assume if the real amount is unknown... 128 MiB
checking if library symbol versioning should be used... yes
checking if sandboxing should be used... no

checking for a shell that conforms to POSIX... /bin/sh

Initializing Automake:
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether ln -s works... yes
checking for style of include used by make... GNU
checking for gcc... gcc-4.4
checking whether the C compiler works... no
configure: error: in `/tmp/xz-20180125-28411-1r5us3p/xz-5.2.3':
configure: error: C compiler cannot create executables
See `config.log' for more details
/build/linuxbrew/Library/Homebrew/debrew.rb:11:in `raise'
FormulaUnavailableError: No available formula with the name "xorg" 
1. raise
2. ignore
3. backtrace
4. irb
5. shell
Choose an action: 

[... blah blah skip blah blah ...]

Error: xz 5.2.3 did not build
Logs:
     /home/nega/.cache/Homebrew/Logs/xz/01.configure
     /home/nega/.cache/Homebrew/Logs/xz/00.options.out
     /home/nega/.cache/Homebrew/Logs/xz/config.log
READ THIS: https://github.com/Linuxbrew/brew/blob/master/docs/Troubleshooting.md#troubleshooting
Please do not report this issue to Homebrew/brew or Homebrew/core, which support macOS only.

[nega@zinc ~]$ brew gist-logs xz
https://gist.github.com/a360b8cd893e1d3a9778e5daa90059e3
nega0 commented 6 years ago

and for some extra info...

[nega@zinc ~]$ brew install portable-ruby
Error: No available formula with the name "portable-ruby" 
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
==> Searching local taps...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
[nega@zinc ~]$ which cc
/opt/rh/devtoolset-4/root/usr/bin/cc
[nega@zinc ~]$ which gcc
/opt/rh/devtoolset-4/root/usr/bin/gcc
[nega@zinc ~]$ brew search ruby
==> Searching local taps...
chruby                          mruby-cli                       ruby-install                    ruby@2.2
chruby-fish                     rbenv-bundler-ruby-version      ruby@1.8                        ruby@2.3
imessage-ruby                   ruby                            ruby@1.9
jruby                           ruby-build                      ruby@2.0
mruby                           ruby-completion                 ruby@2.1
==> Searching taps on GitHub...
homebrew/portable-ruby/portable-ruby
==> Searching blacklisted, migrated and deleted formulae...
[nega@zinc ~]$ brew tap homebrew/portable-ruby
==> Tapping homebrew/portable-ruby
Cloning into '/build/linuxbrew/Library/Taps/homebrew/homebrew-portable-ruby'...
remote: Counting objects: 19, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 19 (delta 1), reused 10 (delta 0), pack-reused 0
Unpacking objects: 100% (19/19), done.
Checking connectivity... done.
Tapped 6 formulae (53 files, 226.0KB)
[nega@zinc ~]$ brew install -s portable-ruby
==> Installing portable-ruby from homebrew/portable-ruby
==> Installing dependencies for homebrew/portable-ruby/portable-ruby: bzip2, pkg-config, makedepend, xz, gpatch, portable-ncurses, portable-readline, portable-libyaml, portable-zlib, portable-openssl
==> Installing homebrew/portable-ruby/portable-ruby dependency: bzip2
==> Downloading http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
Already downloaded: /home/nega/.cache/Homebrew/bzip2-1.0.6.tar.gz
==> make install PREFIX=/build/linuxbrew/Cellar/bzip2/1.0.6_1
Last 15 lines from /home/nega/.cache/Homebrew/Logs/bzip2/01.make:
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
make: *** [huffman.o] Error 127
make: *** Waiting for unfinished jobs....
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
make: *** [blocksort.o] Error 127
make: *** [crctable.o] Error 127
make: *** [compress.o] Error 127
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
make: *** [randtable.o] Error 127
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
make: *** [decompress.o] Error 127
/opt/rh/rh-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
make: *** [bzlib.o] Error 127

READ THIS: https://github.com/Linuxbrew/brew/blob/master/docs/Troubleshooting.md#troubleshooting
Please do not report this issue to Homebrew/brew or Homebrew/core, which support macOS only.

[nega@zinc ~]$ 
nega0 commented 6 years ago

It seems that unsetting HOMEBREW_NO_ENV_FILTERING allows the portable-ruby bottle to be poured. (Which makes sense, as there's no ruby on the path.)

[nega@zinc ~]$ env -u HOMEBREW_NO_ENV_FILTERING brew update
error: unknown option `list'
usage: git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]
   or: git tag -d <tagname>...
   or: git tag -l [-n[<num>]] [<pattern>]
   or: git tag -v <tagname>...

    -l                    list tag names
    -n[<n>]               print <n> lines of each tag message
    -d                    delete tags
    -v                    verify tags

Tag creation options
    -a                    annotated tag, needs a message
    -m <msg>              message for the tag
    -F <FILE>             message in a file
    -s                    annotated and GPG-signed tag
    -u <key-id>           use another key to sign the tag
    -f, --force           replace the tag if exists

Tag listing options
    --contains <commit>   print only tags that contain the commit

error: unknown option `list'
usage: git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]
   or: git tag -d <tagname>...
   or: git tag -l [-n[<num>]] [<pattern>]
   or: git tag -v <tagname>...

    -l                    list tag names
    -n[<n>]               print <n> lines of each tag message
    -d                    delete tags
    -v                    verify tags

Tag creation options
    -a                    annotated tag, needs a message
    -m <msg>              message for the tag
    -F <FILE>             message in a file
    -s                    annotated and GPG-signed tag
    -u <key-id>           use another key to sign the tag
    -f, --force           replace the tag if exists

Tag listing options
    --contains <commit>   print only tags that contain the commit

which: no ruby in (/usr/bin:/bin:/usr/sbin:/sbin)
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.3.3.x86_64_linux.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.3.3.x86_64_linux.bottle.1.tar.gz
==> Homebrew has enabled anonymous aggregate user behaviour analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics.html

error: unknown option `local'
usage: git config [options]

Config file location
    --global              use global config file
    --system              use system config file
    -f, --file <FILE>     use given config file

Action
    --get                 get value: name [value-regex]
    --get-all             get all values: key [value-regex]
    --get-regexp          get values for regexp: name-regex [value-regex]
    --replace-all         replace all matching variables: name value [value_regex]
    --add                 adds a new variable: name value
    --unset               removes a variable: name [value-regex]
    --unset-all           removes all matches: name [value-regex]
    --rename-section      rename section: old-name new-name
    --remove-section      remove a section: name
    -l, --list            list all
    -e, --edit            opens an editor
    --get-color <slot>    find the color configured: [default]
    --get-colorbool <slot>
                          find the color setting: [stdout-is-tty]

Type
    --bool                value is "true" or "false"
    --int                 value is decimal number
    --bool-or-int         value is --bool or --int
    --path                value is a path (file or directory name)

Other
    -z, --null            terminate values with NUL byte

Error: Failure while executing: git config --local --replace-all homebrew.analyticsmessage true
[nega@zinc ~]$ HOMEBREW_NO_ENV_FILTERING=1 brew update
Already up-to-date.
[nega@zinc ~]$ brew install -s xz
==> Downloading https://downloads.sourceforge.net/project/lzmautils/xz-5.2.3.tar.gz
Already downloaded: /home/nega/.cache/Homebrew/xz-5.2.3.tar.gz
==> ./configure --disable-silent-rules --prefix=/build/linuxbrew/Cellar/xz/5.2.3
==> make check
==> make install
🍺  /build/linuxbrew/Cellar/xz/5.2.3: 99 files, 3.4MB, built in 36 seconds
[nega@zinc ~]$ brew gist-logs xz
https://gist.github.com/bd93a41e57acc936e2e21ba7bf613122
[nega@zinc ~]$ 

https://gist.github.com/anonymous/bd93a41e57acc936e2e21ba7bf613122