Homebrew / install

📥 Homebrew (un)installer
https://brew.sh
BSD 2-Clause "Simplified" License
2.15k stars 1.02k forks source link

Installation fails on Linux with snap installed curl #840

Closed orsenthil closed 5 months ago

orsenthil commented 5 months ago

What you were trying to do (and why)

I was trying to install homebrew on Ubuntu Linux 22.04 I realized it didn't come with curl, but recommended me to do snap install curl.

sudo snap install curl

It installed curl 8.1.2

$ /snap/bin/curl --version
curl 8.1.2 (x86_64-pc-linux-gnu) libcurl/8.1.2 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 zstd/1.4.4 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3 libgsasl/1.8.1
Release-Date: 2023-05-30
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli gsasl GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd

And with this curl version, the Homebrew installation fails in a reproducible manner.

What happened (include command output)

Switched to a new branch 'stable'
==> Tapping homebrew/core because `$HOMEBREW_NO_INSTALL_FROM_API` is set.
remote: Enumerating objects: 1918864, done.
remote: Counting objects: 100% (312/312), done.
remote: Compressing objects: 100% (153/153), done.
remote: Total 1918864 (delta 196), reused 263 (delta 159), pack-reused 1918552
Receiving objects: 100% (1918864/1918864), 722.60 MiB | 8.09 MiB/s, done.
Resolving deltas: 100% (1369295/1369295), done.
From https://github.com/Homebrew/homebrew-core
 * [new branch]              master     -> origin/master
HEAD is now at 0f8742774a7 Merge pull request #166913 from Homebrew/tests-stable-syntax
==> Updating Homebrew...
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:f7be167f7ac4f296b9f4c5874ceeea4aafd9999c3c7f2b0378cae7dd273e2322
Warning: Failed to open the file
Warning: /home/senthil/.cache/Homebrew/portable-ruby-3.1.4.x86_64_linux.bottle.
Warning: tar.gz.incomplete: Permission denied
                                                                                                                                                                                                                                                         0.0%curl: (23) Failure writing output to destination

==> Downloading https://github.com/Homebrew/homebrew-portable-ruby/releases/download/3.1.4/portable-ruby-3.1.4.x86_64_linux.bottle.tar.gz
Warning: Failed to open the file
Warning: /home/senthil/.cache/Homebrew/portable-ruby-3.1.4.x86_64_linux.bottle.
Warning: tar.gz.incomplete: Permission denied
                                                                                                                                                                                                                                                         0.0%curl: (23) Failure writing output to destination

Error: Failed to download ruby from the following locations:
  - https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:f7be167f7ac4f296b9f4c5874ceeea4aafd9999c3c7f2b0378cae7dd273e2322
  - https://github.com/Homebrew/homebrew-portable-ruby/releases/download/3.1.4/portable-ruby-3.1.4.x86_64_linux.bottle.tar.gz

Do not file an issue on GitHub about this; you will need to figure out for
yourself what issue with your internet connection restricts your access to
GitHub (used for Homebrew updates and binary packages).
Error: Failed to install Homebrew Portable Ruby and cannot find another Ruby 3.1!
If there's no Homebrew Portable Ruby available for your processor:
- install Ruby 3.1 with your system package manager (or rbenv/ruby-build)
- make it first in your PATH
- try again

Failed during: /home/linuxbrew/.linuxbrew/bin/brew update --force --quiet

Workaround / Fix

I fixed this by using apt-get install version of curl

which was

$ /usr/bin/curl --version
curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.17
Release-Date: 2022-01-05
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets zstd
SMillerDev commented 5 months ago

I don't think we can fix this since snaps are afaik separate from the rest of the OS by design

maxim-belkin commented 5 months ago

The error message is:

==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:f7be167f7ac4f296b9f4c5874ceeea4aafd9999c3c7f2b0378cae7dd273e2322 Warning: Failed to open the file Warning: /home/senthil/.cache/Homebrew/portable-ruby-3.1.4.x86_64_linux.bottle. Warning: tar.gz.incomplete: Permission denied 0.0%curl: (23) Failure writing output to destination

==> Downloading https://github.com/Homebrew/homebrew-portable-ruby/releases/download/3.1.4/portable-ruby-3.1.4.x86_64_linux.bottle.tar.gz Warning: Failed to open the file Warning: /home/senthil/.cache/Homebrew/portable-ruby-3.1.4.x86_64_linux.bottle. Warning: tar.gz.incomplete: Permission denied

0.0%curl: (23) Failure writing output to destination

It is very likely that this issue has nothing to do with Homebrew.

Bo98 commented 5 months ago

Snap curl is extremely limited and not supported. It breaks many things even outside of Homebrew (e.g. Nix, rustup, nvm, etc.).

This is because snap curl is heavily sandboxed. It can write to your home directory but even then the likes of ~/.cache are also restricted. If you want to use snap curl, you can probably create a non-hidden subdirectory in your home directory and set HOMEBREW_CACHE to that. Homebrew also respects XDG_CACHE_HOME should you wish to also use that cache for other applications.