d12frosted / homebrew-emacs-plus

Emacs Plus formulae for the Homebrew package manager
MIT License
2.4k stars 187 forks source link

Install --with-native-comp fails #508

Closed briansniffen closed 3 months ago

briansniffen commented 2 years ago

brew install emacs-plus@29 --with-native-comp fails with the error:

Error: invalid option: --with-native-comp

And a Usage message for brew install listing of options that does not include the options from the brewfile.

brew install emacs-plus@29 --with-native-nonsense fails with the error:

Error: invalid option: --with-native-nonsense

And a Usage message for brew install listing of options that does include the options from the brewfile.

Here's a brew config; any ideas where I can look next to debug this? HOMEBREW_VERSION: 3.6.2-24-g3452176 ORIGIN: https://github.com/Homebrew/brew HEAD: 34521764a659fdce4861a2c1ff0662fe8186c446 Last commit: 5 hours ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: cc6abf752cdff1737a9c3856ee86c0bcdd1add13 Core tap last commit: 2 hours ago Core tap branch: master HOMEBREW_PREFIX: /Users/bsniffen/homebrew HOMEBREW_REPOSITORY: /Users/bsniffen/homebrew HOMEBREW_CELLAR: /Users/bsniffen/homebrew/Cellar HOMEBREW_CASK_OPTS: [] HOMEBREW_EDITOR: vim HOMEBREW_MAKE_JOBS: 10 Homebrew Ruby: 2.6.8 => /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.0 => /Library/Developer/CommandLineTools/usr/bin/git Curl: 7.79.1 => /usr/bin/curl macOS: 12.6-arm64 CLT: 14.0.0.0.1.1661618636 Xcode: N/A Rosetta 2: false

Thanks for your work on this amazingly useful project!

d12frosted commented 2 years ago

🤔 Might be some issue with brew. I will upgrade later this day and see what's wrong.

d12frosted commented 2 years ago

Upgraded and it works. Can you try with any other formula that has custom options? Though it's hard to find them, as the homebrew core doesn't allow options. You can create a file called Foo.rb with the following content:

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

And then install it with brew install --formula Foo.rb --with-ham. It should fail due to 404 error when downloading archive, but at least it should print >>> with ham instead of yelling at you regarding unknown option.

briansniffen commented 2 years ago

That works fine, printing >>> with ham and failing as you predict. brew install emacs-plus@29 --with-native-comp produces a Usage message ending with Error: invalid option: --with-native-comp. And I copied and pasted those strings to be sure. My brew installation is in my homedir for Reasons, and I wonder if that's related. Thanks for your help; I'll keep poking.

d12frosted commented 2 years ago

Not sure if related. As a workaround, clone this repository and install it using brew install --formula Formula/emacs-plus@29.rb --with-native-comp.

briansniffen commented 2 years ago

Thanks for the idea, but same error message. I did some more digging, and have a theory: brew was installing (upgrading) libgccjit, and the option was being passed to it also. Of course, it doesn't support any options. That, in turn, has been failing because of a linker error; see https://github.com/iains/gcc-12-branch/issues/6 — but neither of these is your problem. It looks like a reasonable workaround for installing formulae with options is to install dependencies first without options, then install the formula with options.

I spent an hour looking at Brew code to see where options were being propagated to dependencies, but haven't found it. Thanks for the support & for your work on this tap!

agzam commented 2 years ago

I don't get it, why then emacs-plus@28 ---with-native-comp works (if 29 doesn't)?

d12frosted commented 2 years ago

All I can say, brew position towards options is a twisted one. They keep them, but they advocate for not using them. Since official formulas don't have options, it's not a "well tested feature" that breaks time to time in unexpected ways. Not saying that this is the case, but it might be.

reasonable workaround for installing formulae with options is to install dependencies first without options, then install the formula with options.

I guess, in that case we can provide better instructions. The same way as we advocate for not using reinstall command ever.

agzam commented 2 years ago

The same way as we advocate for not using reinstall command ever.

Oh, really? So how do you update emacs installed from --HEAD?

d12frosted commented 2 years ago

Oh, really? So how do you update emacs installed from --HEAD?

You can find more some details in the README. In short, options do not properly propagate during reinstall. More or less it was fixed by not using external resources (e.g. patches, icons). Maybe if you are using only --HEAD, then you are fine.

agzam commented 2 years ago

Oh, I guess my question came out wrong. What's the proper/guranteed way of updating emacs-plus@29, so it fetches the latest from master and builds it? brew uninstall and then install again?

d12frosted commented 2 years ago

@agzam as far as I remember, reinstall handles fetching of the latest master. But there are troubles if you are using any options, that's why I advise to use combination of uninstall and install. That allows you to upgrade and properly propagate all options.

P.S. I feel like I need to taste this again, it's possible that they fixed the old behaviour.

agzam commented 2 years ago

Yeah, because I remember using reinstall and haven't noticed any problems, I dunno. Maybe I simply wasn't paying attention? My usual flags are --with-native-comp --with-xwidgets --with-modern-papirus-icon --verbose. But thank you for the heads up. Next time I'll keep a closer eye.

n14s commented 2 years ago

Got the same issue. Have you made any progress @briansniffen ?

briansniffen commented 2 years ago

Sure. Downgrade xcode-cli and then install libgccjit in a separate brew command. -- Brian SniffenOn Oct 5, 2022, at 11:22 AM, nik @.***> wrote: Got the same issue. Have you made any progress @briansniffen ?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

n14s commented 2 years ago

Thanks for your answer. I installed libgccjit without options in a seperate brew command as described in your earlier comment. That didn't do the trick, since following up with installing emacs with options fails with the same error.

I didn't downgrade xcode-cli, though, as I don't really know what exactly was mean't by that. Disclaimer: I'm new to MacOS, coming from Linux.

briansniffen commented 2 years ago

If it’s failing with an error about ld when installing libgccjit, download XCode command line tools from before Xcode 14 from developer.Apple.com. If it’s failing with an error about option processing when installing Emacs, you have not installed the proper gccjit or other dependencies. You might try installing Emacs without options to get the dependencies right, check that you have the right libgccjit (12?) and then remove emacs and install it with the native-comp option. -- Brian SniffenOn Oct 8, 2022, at 2:49 AM, nik @.***> wrote: Thanks for your answer @briansniffen . I installed libgccjit without options in a seperate brew command as described in your earlier comment. That didn't do the trick, since following up with installing emacs with options fails with the same error. I didn't downgrade xcode-cli, though, as I don't really know what exactly was mean't by that. Disclaimer: I'm new to MacOS, coming from Linux.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

d12frosted commented 3 months ago

Closing for lack of activity. And it's unclear if there is any actionable item. Besides, there was some effort to fix many issues related to building with native compilation.