brew update and can still reproduce the problem?brew doctor, fixed all issues and can still reproduce the problem?brew config and brew doctor and included their output with your issue?I was trying to install custom formula with custom options. Actually, I found this issue on a formula with decent amount of options, but it can be reproduced with much smaller formula (basically, took it from the cookbook).
class Foo < Formula
desc ""
homepage ""
url "https://example.com/foo-0.1.tar.gz"
sha256 "85cc828a96735bdafcf29eb6291ca91bac846579bcef7308536e0c875d6c81d7"
# depends_on "cmake" => :build
option "with-ham", "Description of the option"
option "without-spam", "Another description"
if build.with? "ham"
puts ">>> with-ham"
else
puts ">>> without-ham"
end
def install
# ENV.deparallelize
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}"
# system "cmake", ".", *std_cmake_args
system "make", "install"
end
test do
system "false"
end
end
## What happened (include command output)
$ brew install Foo.rb --with-ham
$ brew install Foo.rb --with-ham \>>> without-ham \>>> without-ham ==> Downloading https://example.com/foo-0.1.tar.gz #=#=-# # curl: (22) The requested URL returned error: 404 Error: An exception occurred within a child process: DownloadError: Failed to download resource "Foo" Download failed: https://example.com/foo-0.1.tar.gz
$ brew config HOMEBREW_VERSION: 2.2.14-66-g53fe2c9 ORIGIN: https://github.com/Homebrew/brew HEAD: 53fe2c94dbfecf78192fd05b7c3adc245e67f8d6 Last commit: 56 minutes ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: 46b41b27375cff5e875c26df9c7f3576e88eccc8 Core tap last commit: 8 hours ago HOMEBREW_PREFIX: /usr/local HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.YAGwrukjae/org.macosforge.xquartz:0 HOMEBREW_EDITOR: emacsclient HOMEBREW_MAKE_JOBS: 8 CPU: octa-core 64-bit haswell Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby Clang: 11.0 build 1103 Git: 2.26.2 => /usr/local/bin/git Curl: 7.64.1 => /usr/bin/curl Java: 14.0.1 macOS: 10.15.4-x86_64 CLT: 11.4.1.0.1.1586360307 Xcode: N/A XQuartz: 2.7.11 => /opt/X11 $ 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: Putting non-prefixed coreutils in your path can cause gmp builds to fail. Warning: You have unlinked kegs in your Cellar. Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run `brew link` on these: haskell-stack
Option
--with-hamshould lead to>>> with-hamin the logs instead of>>> without-ham.
if build.with? "ham" only works as expected inside methods e.g. def install. This is a known issue with options that is a WONTFIX.
But it worked up until the latest changes in master.
Is there a way to conditionally install a patch?
@d12frosted Can you narrow it down to a specific commit? Can you see if build.with? behaves as expected in install?
If you can submit a PR that would be best but can consider reopening with more information. Thanks!
Sure, I've found an offending commit: 66ac96acd. If I revert it, everything works.
Regarding the install section it doesn't work on the latest HEAD as well:
class Foo < Formula
desc ""
homepage ""
url "https://ftp.gnu.org/gnu/emacs/emacs-26.3.tar.xz"
sha256 "4d90e6751ad8967822c6e092db07466b9d383ef1653feb2f95c93e7de66d3485"
# depends_on "cmake" => :build
option "with-ham", "Description of the option"
option "without-spam", "Another description"
if build.with? "ham"
puts "[pre] with-ham"
else
puts "[pre] without-ham"
end
def install
if build.with? "ham"
puts "[install] with-ham"
else
puts "[install] without-ham"
end
# ENV.deparallelize
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}"
# system "cmake", ".", *std_cmake_args
system "make", "install"
end
test do
system "false"
end
end
Output:
$ brew install Foo.rb --with-ham
[pre] without-ham
[pre] without-ham
==> Downloading https://ftp.gnu.org/gnu/emacs/emacs-26.3.tar.xz
Already downloaded: /Users/d12frosted/Library/Caches/Homebrew/downloads/35ddbf65249f3d4c38e087a1fa7606daaf8784b8445fa2c3b4d453ef9b92a18c--emacs-26.3.tar.xz
[install] without-ham
==> ./configure --prefix=/usr/local/Cellar/Foo/26.3
Last 15 lines from /Users/d12frosted/Library/Logs/Homebrew/Foo/01.configure:
checking for LIBSYSTEMD... no
checking sys/inotify.h usability... no
checking sys/inotify.h presence... no
checking for sys/inotify.h... no
checking for KQUEUE... no
checking for library containing kqueue... none required
checking for jpeglib 6b or later... -ljpeg
checking for LCMS2... no
checking for library containing inflateEnd... -lz
configure: error: The following required libraries were not found:
gnutls
Maybe some development libraries/packages are missing?
If you don't want to link with them give
--with-gnutls=no
as options to configure
Do not report this issue to Homebrew/brew or Homebrew/core!
As you can see, in both cases it's without-ham.
Should I just update this issue or open a new one? Or maybe two? :)
Thanks for the clarification! CC @GauthamGoli FYI
Most helpful comment
Thanks for the clarification! CC @GauthamGoli FYI