ustclug / discussions

Issue Tracker for USTC LUG
47 stars 4 forks source link

A issue that latexindent may not be installed correctly in homebrew. #382

Open Wongboo opened 2 years ago

Wongboo commented 2 years ago

https://github.com/Homebrew/homebrew-core/issues/91974

taoky commented 2 years ago

Sorry but I think that this problem has already been fixed :)

$ wget https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/latexindent-3.13.4.catalina.bottle.tar.gz
$ sha256sum latexindent-3.13.4.catalina.bottle.tar.gz
b945407561004b4c22fe6d754a354080b03c94456f65be8044857d8bb555592c  latexindent-3.13.4.catalina.bottle.tar.gz

And https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/latexindent.rb#L13:

    sha256 cellar: :any_skip_relocation, catalina:       "b945407561004b4c22fe6d754a354080b03c94456f65be8044857d8bb555592c"
$ unar latexindent-3.13.4.catalina.bottle.tar.gz
$ head -3 latexindent/3.13.4/bin/latexindent
#!/bin/bash
PERL5LIB="@@HOMEBREW_CELLAR@@/latexindent/3.13.4/libexec/lib/perl5" exec "@@HOMEBREW_CELLAR@@/latexindent/3.13.4/libexec/bin/latexindent.pl"  "$@"
Wongboo commented 2 years ago

what is your result of

head -3 /usr/local/Cellar/latexindent/3.13.4/libexec/bin/latexindent.pl 

after installation, it's not problem of bottle, it's a problem after bottling(install from bottle)?

taoky commented 2 years ago

It is:

#!/usr/bin/perl
#   latexindent.pl, version 3.13.4, 2021-12-22
#

However, I don't think that it is our fault, as we are providing same brew.sh, formulas and bottles as upstream.

Wongboo commented 2 years ago

@taoky , it means our mirror may be broken, look at the issue, it should be

#!/usr/local/opt/perl/bin/perl
#   latexindent.pl, version 3.13.4, 2021-12-22
#
taoky commented 2 years ago

I have confirmed on my Mac that brew will not download corresponding bottle_manifest.json file when HOMEBREW_BOTTLE_DOMAIN env is set, thus missing required changed_files array (in sh.brew.tab) when installing.

It may require further discussion between mirror maintainers and brew developers to fix this bug.

taoky commented 1 year ago

It seems that this bug still exists in latest brew, and can be resolved only by a pull request by someone who knows brew internal.

Ref: https://github.com/Homebrew/brew/issues/12759

taoky commented 1 year ago

@XuehaiPan any interest in investigating this issue? This bug seems to affect all homebrew bottles mirrors.

XuehaiPan commented 1 year ago

Homebrew refuses to download bottle_manifest.json from a third-party domain because the download strategy for them is CurlDownloadStrategy rather than CurlGitHubPackagesDownloadStrategy. Relevant code here at line 460:

https://github.com/Homebrew/brew/blob/6513d18440428cd85f8a78c5dea34c624051a810/Library/Homebrew/software_spec.rb#L459-L478

  def github_packages_manifest_resource
    return if @resource.download_strategy != CurlGitHubPackagesDownloadStrategy

    @github_packages_manifest_resource ||= begin
      resource = Resource.new("#{name}_bottle_manifest")

      version_rebuild = GitHubPackages.version_rebuild(@resource.version, rebuild)
      resource.version(version_rebuild)

      image_name = GitHubPackages.image_formula_name(@name)
      image_tag = GitHubPackages.image_version_rebuild(version_rebuild)
      resource.url(
        "#{root_url}/#{image_name}/manifests/#{image_tag}",
        using:   CurlGitHubPackagesDownloadStrategy,
        headers: ["Accept: application/vnd.oci.image.index.v1+json"],
      )
      resource.downloader.resolved_basename = "#{name}-#{version_rebuild}.bottle_manifest.json"
      resource
    end
  end

You could have:

-   return if @resource.download_strategy != CurlGitHubPackagesDownloadStrategy 
+   if @resource.download_strategy != CurlGitHubPackagesDownloadStrategy \
+       && Homebrew::EnvConfig.bottle_domain == HOMEBREW_BOTTLE_DEFAULT_DOMAIN
+     return
+   end

I wonder why the manifest file is not included in the bottle in the first place. I don't think the upstream would accept to change this, because it really depends on how the third-party site is mirrored. If the mirror site does not mirror the manifest files, the issue still occurs.

XuehaiPan commented 1 year ago

Maybe we should open a discussion to ask the upstream to ship the manifest file in the bottle archive rather than having two separate files.

Wongboo commented 1 year ago

I think similar issue occurs in atool and other perl script as well