riff
riff copied to clipboard
Build for Homebrew
I am currently working on packaging riff
for Homebrew-Core and since I am not familiar with Rust, I would need some assistance. Initial try with formula:
class Riffdiff < Formula
desc "Diff filter highlighting which line parts have changed"
homepage "https://github.com/walles/riff"
url "https://github.com/walles/riff/archive/refs/tags/2.9.tar.gz"
license "MIT"
depends_on "rust" => :build
def install
system "cargo", "install", *std_cargo_args
end
...
and brew install --verbose --build-from-source riffdiff
:
...
Compiling git-version-macro v0.3.4
Compiling git-version v0.3.4
Compiling riff v0.1.0 (/private/tmp/riffdiff-20210611-71464-14uq6on/riff-2.9)
error: git describe failed with status 128: fatal: not a git repository (or any of the parent directories): .git
--> src/main.rs:62:27
|
62 | const GIT_VERSION: &str = git_version!();
| ^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
error: failed to compile `riff v0.1.0 (/private/tmp/riffdiff-20210611-71464-14uq6on/riff-2.9)`, intermediate artifacts can be found at `/private/tmp/riffdiff-20210611-71464-14uq6on/riff-2.9/target`
Caused by:
could not compile `riff`
...
Second try with this install
section:
def install
system "cargo", "build", "--release", *std_cargo_args
end
...
/usr/bin/sandbox-exec -f /private/tmp/homebrew20210611-73336-orsj1b.sb nice ruby -W1 -- /usr/local/Homebrew/Library/Homebrew/build.rb /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/riffdiff.rb --verbose
tar --extract --no-same-owner --file /Users/admin/Library/Caches/Homebrew/downloads/b4cc31a19bf3e1cddff4bd171f148c6281f2f4ff6c202f77c37bab27964cf6bd--riff-2.9.tar.gz --directory /private/tmp/d20210611-73337-1dfmvfi
cp -pR /private/tmp/d20210611-73337-1dfmvfi/riff-2.9/. /private/tmp/riffdiff-20210611-73337-14teoag/riff-2.9
chmod -Rf +w /private/tmp/d20210611-73337-1dfmvfi
==> cargo build --release --locked --root /usr/local/Cellar/riffdiff/2.9 --path .
error: Found argument '--root' which wasn't expected, or isn't valid in this context
USAGE:
cargo build --locked --release
...
I grepped for cargo
in /usr/local/Homebrew/Library/Taps
and what everybody seems to be doing is this:
system "cargo", "install", *std_cargo_args
That is also what I'm doing in here: https://github.com/walles/homebrew-johan/blob/main/Formula/riffdiff.rb
The git_version()
macro does git describe
at compile time, which is why I'm getting the sources using git
in my formula. This makes the git_version()
problem go away for me.
Also, there's already a (deprecated, but still) formula for another unrelated riff
in Homebrew Core, which is why I choose to call mine riffdiff
.
Not sure if any of this helped, I'm not super great at rust
either unfortunately. Did it help?
The git_version() macro does git describe at compile time
I looked into the not particularly well documented git_version macro library and they have a fallback option if git cannot be executed: https://github.com/fusion-engineering/rust-git-version/pull/12
which is why I'm getting the sources using git in my formula.
That was the first thing the reviewer admonished when I submitted the moar formula. Indeed, when I search all formulas in Homebrew-core, not a single one uses the git strategy to download the sources. I can try submitting it that way but I doubt that it will be accepted.
Also, there's already a (deprecated, but still) formula for another unrelated riff in Homebrew Core, which is why I choose to call mine riffdiff.
I am aware of that. Let's see if they accept the executable name riff
. Fortunately, the old riff is already marked as deprecated but they seem to be keeping the formula around: https://github.com/Homebrew/homebrew-core/pull/73183
which is why I'm getting the sources using git in my formula.
That was the first thing the reviewer admonished when I submitted the moar formula. Indeed, when I search all formulas in Homebrew-core, not a single one uses the git strategy to download the sources. I can try submitting it that way but I doubt that it will be accepted.
Interesting finding that "not a single one uses the git strategy", I am surprised.
Under the circumstances though, I'd say try it with git
, and a comment in the formula with an explanation and possibly a link to this thread.
Either it passes review and then 🥳.
Or it does not pass review, but then you should hopefully get some rationale for not-git
, and at best even an explanation of what to do instead.
This unfortunately is a goal blocker: 😞
% brew audit --new-formula riffdiff
riffdiff:
* GitHub repository not notable enough (<30 forks, <30 watchers and <75 stars)
Error: 1 problem in 1 formula detected
(That issue is independent of the download strategy.)
Well, I guess that kind of settles it then, seems like riff
will have to stay in my tap until that changes.
px
is the only other tool I've done that has enough stars by this metric.
Thanks for spending effort on this Fabian!
I will work on submitting px
as soon as I can. Looking forward to getting rid of my pgrep hack. 😸
I have the riff formula stored in my fork of homebrew-core: https://github.com/ritzmann/homebrew-core/blob/riff/Formula/riffdiff.rb. I expect popularity of riff to grow when people discover your tools through Homebrew.
Hello @ritzmann!
riff
is now at 94 stars so it should be good to go if you want to have another go at it.
The formula has been renamed to just riff
, and it now builds from a tarfile rather than from Git.
I think just submitting the current formula to upstream should be fine: https://github.com/walles/homebrew-johan/blob/main/Formula/riff.rb
Alrighty, I'll make some time to look at it as soon as possible, not in the next few days however.
Done: https://github.com/Homebrew/homebrew-core/pull/139465
Wait, what, it's already done?! Very cool. Looks like you found a former colleague to help you out. 😸