buo / homebrew-cask-upgrade

A command line tool for upgrading every outdated app installed by Homebrew Cask
MIT License
2.39k stars 89 forks source link

Undefinded method for nil:NilClass #221

Closed nercolaszerg closed 1 year ago

nercolaszerg commented 1 year ago

Get this error message:

$ brew cu 
==> Options
Include auto-update (-a): true
Include latest (-f): false
==> Updating Homebrew
Already up-to-date.
Error: undefined method `before_separators' for nil:NilClass
/usr/local/Homebrew/Library/Taps/buo/homebrew-cask-upgrade/lib/extend/cask.rb:23:in `block in installed_apps'
/usr/local/Homebrew/Library/Taps/buo/homebrew-cask-upgrade/lib/extend/cask.rb:13:in `map'
/usr/local/Homebrew/Library/Taps/buo/homebrew-cask-upgrade/lib/extend/cask.rb:13:in `installed_apps'
/usr/local/Homebrew/Library/Taps/buo/homebrew-cask-upgrade/lib/bcu/command/upgrade.rb:29:in `run_process'
/usr/local/Homebrew/Library/Taps/buo/homebrew-cask-upgrade/lib/bcu/command/upgrade.rb:8:in `process'
/usr/local/Homebrew/Library/Taps/buo/homebrew-cask-upgrade/lib/bcu.rb:25:in `process'
/usr/local/Homebrew/Library/Taps/buo/homebrew-cask-upgrade/cmd/brew-cu.rb:72:in `<top (required)>'
/usr/local/Homebrew/Library/Homebrew/utils.rb:92:in `require'
/usr/local/Homebrew/Library/Homebrew/utils.rb:92:in `require?'
/usr/local/Homebrew/Library/Homebrew/brew.rb:99:in `<main>'

I'm not really found any solution in the world wide web.

System: MacOS Mojave 10.14.6 Shell: zsh

ondrejfuhrer commented 1 year ago

Hey @d4nt3-n1375ch3-f4u5t , that's weird. Would you try running following?

brew update-reset && brew update

That should reset your brew instance. However I'm not sure if we still can support Mojave 🤔 Unfortunately I don't have a way for test that right now.

Anyone else with Mojave that can test this?

ondrejfuhrer commented 1 year ago

Also, maybe can you share what's your brew version?

brew --version
nercolaszerg commented 1 year ago

Hey @ondrejfuhrer, the update reset doesn't help. Here my brew version:

$ brew --version
Homebrew 3.6.15-31-g82d89bb
Homebrew/homebrew-core (git revision d6bda094c25; last commit 2022-12-15)
Homebrew/homebrew-cask (git revision d2c16cb7a3; last commit 2022-12-15)
muescha commented 1 year ago

I guess it depends on a cask definition of one of your installed casks:

https://github.com/buo/homebrew-cask-upgrade/blob/a0b6217a5b6b2a1e996ef0e4474fa60904704fd3/lib/extend/cask.rb#L23

and i guess there is the .version missing because of for nil:NilClass

muescha commented 1 year ago

you can list your current installed casks with this command:

brew list --cask

and then check step by step if they have a version

muescha commented 1 year ago

or to pint all casks as a oneliner:

brew list --cask | xargs -I {} sh -c "echo '\n\ncask: "{}"\n'; brew cat {}"
nercolaszerg commented 1 year ago

Thank you. I will report if I find the missing version.

nercolaszerg commented 1 year ago

These three packages did not have a version specification. The flux formula looks very strange because the git URL refers to a "scripting language" for a specifc DB.

cask: handbrake

class Handbrake < Formula
  desc "Open-source video transcoder available for Linux, Mac, and Windows"
  homepage "https://handbrake.fr/"
  url "https://github.com/HandBrake/HandBrake/releases/download/1.5.1/HandBrake-1.5.1-source.tar.bz2"
  sha256 "3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0"
  license "GPL-2.0-only"
  revision 1
  head "https://github.com/HandBrake/HandBrake.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "9c43a4e34f777a4c26fe6c415abac2f803522abf083ded04d830c247b0fe9118"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "4046c86ec7f3bee73f9ca050dbc3338e61aa9a48e1d08e28a2b78e6c2d574506"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "96ffdb5a88e0c04e281c11d6c16543950ccf4ad6355f621822ddc5c58f0558af"
    sha256 cellar: :any_skip_relocation, ventura:        "55b5028b010ccd747b76081208c519904fc6366b1652b566f004d2740404ead4"
    sha256 cellar: :any_skip_relocation, monterey:       "9ebce80e9b5b7149aa18b19eef3657a84a04bab20dafd521e3658fcb90a2a0df"
    sha256 cellar: :any_skip_relocation, big_sur:        "e13914d989020a6592a40c08dcd10fc4288db93abafa1b9fbba3b54628a3e78d"
    sha256 cellar: :any_skip_relocation, catalina:       "7d4c30c6b4be84e80b3f2333e44e951805e38a0b3b76c05dd0968f9f58b0a697"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "e88d97354c37e76b8eb86afa2300a22b409ac0a41810d5e15039234974710760"
  end

  depends_on "autoconf" => :build
  depends_on "automake" => :build
  depends_on "cmake" => :build
  depends_on "libtool" => :build
  depends_on "meson" => :build
  depends_on "nasm" => :build
  depends_on "ninja" => :build
  depends_on "pkg-config" => :build
  depends_on "python@3.10" => :build
  depends_on xcode: ["10.3", :build]
  depends_on "yasm" => :build

  uses_from_macos "m4" => :build
  uses_from_macos "bzip2"
  uses_from_macos "libxml2"
  uses_from_macos "zlib"

  on_linux do
    depends_on "jansson"
    depends_on "jpeg-turbo"
    depends_on "lame"
    depends_on "libass"
    depends_on "libvorbis"
    depends_on "libvpx"
    depends_on "numactl"
    depends_on "opus"
    depends_on "speex"
    depends_on "theora"
    depends_on "x264"
    depends_on "xz"
  end

  def install
    inreplace "contrib/ffmpeg/module.defs", "$(FFMPEG.GCC.gcc)", "cc"

    ENV.append "CFLAGS", "-I#{Formula["libxml2"].opt_include}/libxml2" if OS.linux?

    system "./configure", "--prefix=#{prefix}",
                          "--disable-xcode",
                          "--disable-gtk"
    system "make", "-C", "build"
    system "make", "-C", "build", "install"
  end

  test do
    system bin/"HandBrakeCLI", "--help"
  end
end

cask: flux

class Flux < Formula
  desc "Lightweight scripting language for querying databases"
  homepage "https://www.influxdata.com/products/flux/"
  url "https://github.com/influxdata/flux.git",
      tag:      "v0.191.0",
      revision: "b9d6eb68390c18de9f4e33f176337656babfc8cf"
  license "MIT"
  head "https://github.com/influxdata/flux.git", branch: "master"

  livecheck do
    url :stable
    strategy :github_latest
  end

  bottle do
    sha256 cellar: :any,                 arm64_ventura:  "0cddab0ca727689538c2bc2b4e4ddf89a7d7969dbca45f1651323bf0b5148756"
    sha256 cellar: :any,                 arm64_monterey: "67a6871ed6d551fcce1aff292e32d81eb77366de330b23f18ae113b374c04c62"
    sha256 cellar: :any,                 arm64_big_sur:  "41a55889deb832edf1aa16597b41f5d661d6d466776462d5a76e7e0dce624b6a"
    sha256 cellar: :any,                 ventura:        "dd1671d27a302bb6bf76209dd6f82f185dfd90409217e70ee60fd9b784efe4e8"
    sha256 cellar: :any,                 monterey:       "c0fdf7c2d0d7983faf4746132eab29ce4417e4825a88b5b2417a50ddb8d414ac"
    sha256 cellar: :any,                 big_sur:        "b9bf48060d62101dd49a45ca78d10c02e4fbcd066e9c1a0163da293f31fbdfbb"
    sha256 cellar: :any,                 catalina:       "d4f054e77c15e141fed3c1c8f9ed31b6f92dce18f76f6f3bb0df30fb1a2033fe"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "b2907ae7ca3ec9d49abb5b7e41ecb2cbb647845c3a748471b389bc2f7ef89e43"
  end

  depends_on "go" => :build
  depends_on "rust" => :build

  on_linux do
    depends_on "pkg-config" => :build
  end

  # NOTE: The version here is specified in the go.mod of influxdb.
  # If you're upgrading to a newer influxdb version, check to see if this needs upgraded too.
  resource "pkg-config-wrapper" do
    url "https://github.com/influxdata/pkg-config/archive/v0.2.12.tar.gz"
    sha256 "23b2ed6a2f04d42906f5a8c28c8d681d03d47a1c32435b5df008adac5b935f1a"

    livecheck do
      url "https://raw.githubusercontent.com/influxdata/flux/v#{LATEST_VERSION}/go.mod"
      regex(/pkg-config\s+v?(\d+(?:\.\d+)+)/i)
    end
  end

  def install
    # Set up the influxdata pkg-config wrapper to enable just-in-time compilation & linking
    # of the Rust components in the server.
    resource("pkg-config-wrapper").stage do
      system "go", "build", *std_go_args(output: buildpath/"bootstrap/pkg-config")
    end
    ENV.prepend_path "PATH", buildpath/"bootstrap"

    system "make", "build"
    system "go", "build", *std_go_args(ldflags: "-s -w"), "./cmd/flux"
    include.install "libflux/include/influxdata"
    lib.install Dir["libflux/target/*/release/libflux.{dylib,a,so}"]
  end

  test do
    (testpath/"test.flux").write <<~EOS
      1.0   + 2.0
    EOS
    system bin/"flux", "fmt", "--write-result-to-source", testpath/"test.flux"
    assert_equal "1.0 + 2.0\n", (testpath/"test.flux").read
  end
end

cask: neovide

class Neovide < Formula
  desc "No Nonsense Neovim Client in Rust"
  homepage "https://github.com/neovide/neovide"
  url "https://github.com/neovide/neovide/archive/tags/0.10.3.tar.gz"
  sha256 "ea5a78caa7b87036950e4124e49e50f17b83677a29c251ffbbdc942a6768f022"
  license "MIT"
  head "https://github.com/neovide/neovide.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "b9f0ee8191ec79f9fbd3438d10c5ae0493863c7c2c680caab4fc967fc168148a"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "52e1a6e4f4f2a2e918e365e0105cac14e241f64de52a46f406df9955377bc470"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "e51d21a37542931d1fbdbfb8d14ee678620a125231e23e896b1ba2e5bd7fcc8e"
    sha256 cellar: :any_skip_relocation, ventura:        "93ea527c2ae7cd5fc549c337afbea69bcd9e11cd5f4cb03ef365e55b0edec9ee"
    sha256 cellar: :any_skip_relocation, monterey:       "7dba3e47469e140aefc423a6d82f5e3123052577973c0569cfbb648d3c379504"
    sha256 cellar: :any_skip_relocation, big_sur:        "a037d1e850fd22743a0a0c2df4a7d698721d7a1777c08d5ec31101fbe2262503"
    sha256 cellar: :any_skip_relocation, catalina:       "a216d673f01cedf9ee649425df9433e0882465f7cdfd6a5afca3a91ccb81f9da"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "9f0d267c95c4cdd59f9054ad1ed28727b0dd89cc53a77988d77dfad49e3f95a3"
  end

  depends_on "rust" => :build
  depends_on "neovim"

  uses_from_macos "python" => :build, since: :catalina

  on_macos do
    depends_on "cargo-bundle" => :build
  end

  on_linux do
    depends_on "fontconfig"
    depends_on "freetype"
    depends_on "libxcb"
  end

  def install
    system "cargo", "install", *std_cargo_args

    return unless OS.mac?

    # https://github.com/burtonageo/cargo-bundle/issues/118
    with_env(TERM: "xterm") { system "cargo", "bundle", "--release" }
    prefix.install "target/release/bundle/osx/Neovide.app"
    bin.install_symlink prefix/"Neovide.app/Contents/MacOS/neovide"
  end

  test do
    assert_match version.to_s, shell_output("#{bin}/neovide --version")

    test_server = "localhost:#{free_port}"
    nvim_pid = spawn "nvim", "--headless", "--listen", test_server
    sleep 10
    neovide_pid = spawn bin/"neovide", "--nofork", "--remote-tcp=#{test_server}"
    sleep 10
    system "nvim", "--server", test_server, "--remote-send", ":q<CR>"

    Process.wait nvim_pid
    Process.wait neovide_pid
  end
end

I uninstall all of these but the issue still exists.

yurikoles commented 1 year ago

The issue most likely resides in some third-party tap that is outdated. Please post your taps from brew tap.

nercolaszerg commented 1 year ago
$ brew tap
buo/cask-upgrade
cartr/qt4
d12frosted/emacs-plus
darelover/ntfs-3g
ethereum/ethereum
gcenx/wine
gromgit/fuse
homebrew/bundle
homebrew/cask
homebrew/cask-fonts
homebrew/cask-versions
homebrew/core
homebrew/services
kde-mac/kde
matt-chapman/python2
mongodb/brew
wez/wezterm
ondrejfuhrer commented 1 year ago

These three packages did not have a version specification. The flux formula looks very strange because the git URL refers to a "scripting language" for a specifc DB.

...

I uninstall all of these but the issue still exists.

Yes, those are formulas and not casks, therefore uninstalling those makes no difference.

muescha commented 1 year ago

mhh the normal formulas are also listed with the brew list --cask?

ondrejfuhrer commented 1 year ago

mhh the normal formulas are also listed with the brew list --cask?

No they aren't. Those above are probably both cask and formulae at the same time. I know handbrake is.

> brew search handbrake
==> Formulae
handbrake

==> Casks
handbrake ✔                             handbrakebatch                          handshaker
nercolaszerg commented 1 year ago

I did like here #issuecomment-1364075097 requested brew cat {} give me back the formulas.

I think I found the bug, in the cask for Suspicious Package there is no condition for Mojave, I uninstall it and brew cu works like before.

cask: suspicious-package

cask "suspicious-package" do
  on_sierra :or_older do
    version "3.4.1"
    sha256 "e4673a0c590e7dcb711789d98fcadd2283c2152d262b7809dfd8c8a1b3e9094b"

    url "https://www.mothersruin.com/software/downloads/SuspiciousPackage-#{version}.dmg"

    livecheck do
      skip "Legacy version"
    end
  end
  on_high_sierra do
    version "3.5.3"
    sha256 "fad69db99a60058f8136954653fa2de81667f12cb731957a6d921d36ceaf195d"

    url "https://www.mothersruin.com/software/downloads/SuspiciousPackage-#{version}.dmg"

    livecheck do
      skip "Legacy version"
    end
  end
  on_catalina do
    version "4.0"
    sha256 "844708fb75f8aa102f3ede8ddef3c20180f469b7bc8ec65bbc0370ce9f7db33c"

    url "https://www.mothersruin.com/software/downloads/SuspiciousPackage-#{version}.dmg"

    livecheck do
      skip "Legacy version"
    end

    depends_on macos: ">= :mojave"
  end
  on_big_sur :or_newer do
    version "4.3.1,999"
    sha256 :no_check

    url "https://www.mothersruin.com/software/downloads/SuspiciousPackage.dmg"

    livecheck do
      url "https://www.mothersruin.com/software/SuspiciousPackage/data/SuspiciousPackageVersionInfo.plist"
      regex(/CFBundleShortVersionString.*?\n.*?(\d+(?:\.\d+)*).*?\n.*?CFBundleVersion.*?\n.*?(\d+(?:\.\d+)*)/i)
      strategy :page_match do |page, regex|
        page.scan(regex).map { |match| "#{match[0]},#{match[1]}" }
      end
    end
  end

  name "Suspicious Package"
  desc "Application for inspecting installer packages"
  homepage "https://www.mothersruin.com/software/SuspiciousPackage/"

  app "Suspicious Package.app"
  binary "#{appdir}/Suspicious Package.app/Contents/SharedSupport/spkg"

  zap trash: [
    "~/Library/Application Scripts/com.mothersruin.SuspiciousPackageApp.QLPreview",
    "~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.mothersruin.suspiciouspackageapp.sfl*",
    "~/Library/Caches/com.mothersruin.SuspiciousPackageApp",
    "~/Library/Caches/com.mothersruin.XPCService.UpdateChecker",
    "~/Library/Containers/com.mothersruin.SuspiciousPackageApp.QLPreview",
    "~/Library/Preferences/com.mothersruin.SuspiciousPackage.plist",
    "~/Library/Preferences/com.mothersruin.SuspiciousPackageApp.plist",
    "~/Library/Saved Application State/com.mothersruin.SuspiciousPackageApp.savedState",
    "~/Library/WebKit/com.mothersruin.SuspiciousPackageApp",
  ]
end

Where and how do I report that?

Edit: I don't know ruby, but now I see the depends_on macos: ">= :mojave" and can't say why this code could be a problem or not. But after I uninstall it brew cu works again.

yurikoles commented 1 year ago

This cask is suspicious ;) I sent a fix https://github.com/Homebrew/homebrew-cask/pull/138475

muescha commented 1 year ago

Oh yes. My script was wrong. There was missing a --cask to show the cask formula. Sorry.

brew list --cask | xargs -I {} sh -c "echo '\n\ncask: "{}"\n'; brew cat —cask {}"
nercolaszerg commented 1 year ago

If I have to close the issue? Thank you all very very much.

ondrejfuhrer commented 1 year ago

If I have to close the issue? Thank you all very very much.

Thanks for confirming it all works 🙂 I'll add a bit more resiliency and options to debug things in the linked PR. Will close the issue with that, but have to fix some things first.