Homebrew / brew

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

Brew no longer honour `brew edit` updates to the formulae. #14473

Closed snobb closed 1 year ago

snobb commented 1 year ago

brew doctor output

$ 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: You have uncommitted modifications to Homebrew/homebrew-core.
If this is a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
  cd /opt/homebrew/Library/Taps/homebrew/homebrew-core && git stash -u && git clean -d -f

Uncommitted files:
   M Formula/vim.rb

Verification

brew config output

HOMEBREW_VERSION: 3.6.20-167-g7a5f614
ORIGIN: https://github.com/Homebrew/brew
HEAD: 7a5f6143d3e7447a64255c548d2e51138c83acd3
Last commit: 23 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 25e0de0968e7e3030405f96068380cff94dc292f
Core tap last commit: 48 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: vim
HOMEBREW_INSTALL_FROM_API: set
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 14.0.0 build 1400
Git: 2.37.1 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.79.1 => /usr/bin/curl
macOS: 12.6.1-arm64
CLT: 14.2.0.0.1.1668646533
Xcode: N/A
Rosetta 2: false

What were you trying to do (and why)?

Normally I edit the vim formulae to not include ruby, lua, python support and add build flags that I prefer and brew install -s vim. In the formulae I remove depends_on commands and update the build flags and expect the vim to be build with the flags (and pretty sure it does not depend on anything extra and have been doing the same for many many years). Yet the brew install -s vim starts installing all the dependencies that I have removed from the formulae meaning that it no longer honouring brew edit updates. This used to work before as expected - brew would only install the dependencies listed as depends_on in the formulae and build from the source, but it stopped working recently.

  depends_on "gettext"
  depends_on "ncurses"

  conflicts_with "ex-vi",
    because: "vim and ex-vi both install bin/ex and bin/view"

  conflicts_with "macvim",
    because: "vim and macvim both install vi* binaries"

What happened (include all command output)?

$ brew install -s -n vim
==> Would install 1 formula:
vim
==> Would install 5 dependencies for vim:
lua berkeley-db perl libyaml ruby

What did you expect to happen?

I expected brew to NOT install the dependencies that are not in the formulae and build the vim from source. I did not run the install commands because I do not want the dependencies to be installed - clearly it misbehaves and ignores the updated formulae.

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

Update the formulate as follows:

class Vim < Formula
  desc "Vi 'workalike' with many additional features"
  homepage "https://www.vim.org/"
  # vim should only be updated every 50 releases on multiples of 50
  url "https://github.com/vim/vim/archive/v9.0.1250.tar.gz"
  sha256 "8d8c82de18b1539195ff1b1ba3e68ca0a5b3c7cd649270f771eacbde998bb505"
  license "Vim"
  head "https://github.com/vim/vim.git", branch: "master"

  # The Vim repository contains thousands of tags and the `Git` strategy isn't
  # ideal in this context. This is an exceptional situation, so this checks the
  # first page of tags on GitHub (to minimize data transfer).
  livecheck do
    url "https://github.com/vim/vim/tags"
    regex(%r{href=["']?[^"' >]*?/tag/v?(\d+(?:\.\d+)+)["' >]}i)
    strategy :page_match
  end

  bottle do
    sha256 arm64_ventura:  "52f32fbe651a67e835de9da1195f1e25a87e74af1307b90dfd21221746e1b7c6"
    sha256 arm64_monterey: "ca77787b8c6faa6f644538c8795985bf1926f8248ee9a95faf0cbc017faca686"
    sha256 arm64_big_sur:  "0e88238cf27264ab7e72b799f78463ee7b78235a075bd4fc25e7ba9caafd0e1c"
    sha256 ventura:        "302e13e711dd3385a60b07f5979fa9a932f9ccc2b86efcac7bfb8c99419390e9"
    sha256 monterey:       "f253a1f8e145cb9d5c41e2e051348c34635ee664ded8beeee0b5d457efa34e9b"
    sha256 big_sur:        "ac80b2dc5ba4c2aa1b06840d096021e57e7f9e22780cee7b9bf7a40d38120b88"
    sha256 x86_64_linux:   "b2700962e1aa8f0dd6120f803f3af14ada95f59de707c99903a7c10078d3a2e6"
  end

  depends_on "gettext"
  depends_on "ncurses"

  conflicts_with "ex-vi",
    because: "vim and ex-vi both install bin/ex and bin/view"

  conflicts_with "macvim",
    because: "vim and macvim both install vi* binaries"

  def install
    ENV.prepend_path "PATH", Formula["python@3.11"].opt_libexec/"bin"

    # https://github.com/Homebrew/homebrew-core/pull/1046
    ENV.delete("SDKROOT")

    # vim doesn't require any Python package, unset PYTHONPATH.
    ENV.delete("PYTHONPATH")

    # We specify HOMEBREW_PREFIX as the prefix to make vim look in the
    # the right place (HOMEBREW_PREFIX/share/vim/{vimrc,vimfiles}) for
    # system vimscript files. We specify the normal installation prefix
    # when calling "make install".
    # Homebrew will use the first suitable Perl & Ruby in your PATH if you
    # build from source. Please don't attempt to hardcode either.
    system "./configure", "--prefix=#{HOMEBREW_PREFIX}",
                          "--mandir=#{man}",
                          "--enable-multibyte",
                          "--with-tlib=ncurses",
                          "--disable-arabic",
                          "--disable-netbeans",
                          "--disable-mouse",
                          "--disable-sound",
                          "--enable-terminal",
                          "--with-compiledby=Homebrew",
                          "--enable-gui=no",
                          "--without-x"

    system "make"
    # Parallel install could miss some symlinks
    # https://github.com/vim/vim/issues/1031
    ENV.deparallelize
    # If stripping the binaries is enabled, vim will segfault with
    # statically-linked interpreters like ruby
    # https://github.com/vim/vim/issues/114
    system "make", "install", "prefix=#{prefix}", "STRIP=#{which "true"}"
    bin.install_symlink "vim" => "vi"
  end
end

run brew install -s vim which is supposed to build vim from source - that is what has been happening until recently.

gromgit commented 1 year ago

export HOMEBREW_NO_INSTALL_FROM_API=1, then brew install -s vim again.

snobb commented 1 year ago

That did the trick. Thanks - did not know about the variable. The bug can be closed then.