Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

font-m-plus install error #176

Closed
brian-c opened this issue Jul 10, 2014 · 10 comments · Fixed by #199
Closed

font-m-plus install error #176

brian-c opened this issue Jul 10, 2014 · 10 comments · Fixed by #199

Comments

@brian-c
Copy link

brian-c commented Jul 10, 2014

Received this error trying to install M+, which has been popping up on a bunch of sites the past couple days.

$ brew cask install font-m-plus
==> Downloading http://osdn.dl.sourceforge.jp/mplus-fonts/6650/mplus-TESTFLIGHT-050.tar.xz
######################################################################## 100.0%
Error: Uh oh, could not identify primary container for '/Library/Caches/Homebrew/font-m-plus-1.050.tar.xz'
@rolandwalker
Copy link
Contributor

Hi!

M+ installs fine for me. I can't remember if I had to upgrade any of the codebase to support the tar.xz container. Could you make sure you are running the latest release:

$ brew update && brew upgrade brew-cask && brew cleanup && brew cask cleanup

and let me know if your problem persists?

Another possibility is that the file was corrupted on download, in which case

$ rm /Library/Caches/Homebrew/font-m-plus-1.050.tar.xz

@brian-c
Copy link
Author

brian-c commented Jul 10, 2014

No change unfortunately.

The only thing brew doctor says is that my XQuartz is old, but I can't imagine that's affecting this.

The Unarchiver can extract the archive fine.

Another font (font-profontx) installed with no trouble.

@rolandwalker
Copy link
Contributor

Thanks for the feedback. I would like to see tar.xz files work correctly; there is no reason why they shouldn't.

Perhaps it is a difference between versions of OS X. I am on Mavericks. Homebrew-cask invokes the file utility to determine the filetype (ignoring the .tar.xz extension). So the internal command is like the following (expected result shown):

$ /usr/bin/file -Izb -- /Library/Caches/Homebrew/font-m-plus-1.050.tar.xz
application/x-tar; charset=binary compressed-encoding=application/x-xz; charset=binary; charset=binary

Which you can also see by running

$ brew cask install --debug font-m-plus

There is also a Cask doctor command brew cask doctor which unfortunately is not as advanced as brew doctor, though it might be helpful for us to see the output.

@brian-c
Copy link
Author

brian-c commented Jul 10, 2014

Here's what file gives me:

$ /usr/bin/file -Izb /Library/Caches/Homebrew/font-m-plus-1.050.tar.xz
application/x-empty compressed-encoding=application/x-xz; charset=binary; charset=binary

So that's not quite right.

I'm on 10.9.3 here. file --version reports 5.04, if that's any use.

@rolandwalker
Copy link
Contributor

application/x-empty indicates a bad download. This should also show a zero-length file:

$ ls -la /Library/Caches/Homebrew/font-m-plus-1.050.tar.xz

You should try

$ rm /Library/Caches/Homebrew/font-m-plus-1.050.tar.xz

and download it fresh.

On our end, we should definitely add a more helpful error message for the case of empty downloads.

@brian-c
Copy link
Author

brian-c commented Jul 10, 2014

Nah, the file's okay. I can extract it with the Unarchiver.

Different machine this time. Same OS, brew and cask are both up to date.

$ brew cask install font-m-plus
==> Downloading http://osdn.dl.sourceforge.jp/mplus-fonts/6650/mplus-TESTFLIGHT-050.tar.xz
######################################################################## 100.0%
Error: Uh oh, could not identify primary container for '/Library/Caches/Homebrew/font-m-plus-1.050.tar.xz'
$ ls -la /Library/Caches/Homebrew/font-m-plus-1.050.tar.xz
-rw-r--r--  1 brian  admin   8.0M Jul 10 18:35 /Library/Caches/Homebrew/font-m-plus-1.050.tar.xz

If I'm the only one this happens for (weird), it's totally not a big deal, there are other ways to install a font. But if you think this is something we can debug I'm happy to help.

Excerpt from a --debug install:

==> Downloading
==> Downloading http://osdn.dl.sourceforge.jp/mplus-fonts/6650/mplus-TESTFLIGHT-050.tar.xz
Already downloaded: /Library/Caches/Homebrew/font-m-plus-1.050.tar.xz
==> Checksums match
==> Downloaded to -> /Library/Caches/Homebrew/font-m-plus-1.050.tar.xz
==> Extracting primary container
==> Determining which containers to use based on filetype
==> Checking container class Cask::Container::Air
==> Checking container class Cask::Container::Cab
==> Executing: ["/usr/bin/file", "-Izb", "--", "#<Pathname:/Library/Caches/Homebrew/font-m-plus-1.050.tar.xz>"]
==> Checking container class Cask::Container::Dmg
==> Executing: ["/usr/bin/hdiutil", "imageinfo", "#<Pathname:/Library/Caches/Homebrew/font-m-plus-1.050.tar.xz>"]
==> Checking container class Cask::Container::SevenZip
==> Checking container class Cask::Container::Sit
==> Checking container class Cask::Container::Tar
==> Checking container class Cask::Container::Rar
==> Checking container class Cask::Container::Zip
==> Checking container class Cask::Container::Bzip2
==> Checking container class Cask::Container::Naked
==> Purging files
Error: Uh oh, could not identify primary container for '/Library/Caches/Homebrew/font-m-plus-1.050.tar.xz'
/usr/local/Cellar/brew-cask/0.37.1/rubylib/cask/installer.rb:72:in `extract_primary_container'
/usr/local/Cellar/brew-cask/0.37.1/rubylib/cask/installer.rb:36:in `install'
/usr/local/Cellar/brew-cask/0.37.1/rubylib/cask/cli/install.rb:20:in `block in install_casks'
/usr/local/Cellar/brew-cask/0.37.1/rubylib/cask/cli/install.rb:17:in `each'
/usr/local/Cellar/brew-cask/0.37.1/rubylib/cask/cli/install.rb:17:in `install_casks'
/usr/local/Cellar/brew-cask/0.37.1/rubylib/cask/cli/install.rb:6:in `run'
/usr/local/Cellar/brew-cask/0.37.1/rubylib/cask/cli.rb:80:in `run_command'
/usr/local/Cellar/brew-cask/0.37.1/rubylib/cask/cli.rb:120:in `process'
/usr/local/bin/brew-cask.rb:42:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/Library/brew.rb:59:in `require?'
/usr/local/Library/brew.rb:137:in `<main>'

Possibly relevant:

$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]

@rolandwalker
Copy link
Contributor

I can extract it with the Unarchiver.

Sorry, missed that.

Sure, it's just one weird case, but homebrew-cask is more useful if it is robust against different cases.

I'm going to try duplicating this symptom using intentionally weird ACLs. You might double-check ACLs using Apple's ls:

$ /bin/ls -le /Library/Caches/Homebrew/font-m-plus-1.050.tar.xz

The only other thing I can think of that modifies the behavior of the file utility is the $MAGIC environment variable. Perhaps Homebrew-cask should unset that just to be safe.

Otherwise, I may add a fallback in the code to respect the downloaded file extension in cases where the file utility fails. Though it will be a little while before such a fix is merged and released.

Sorry I couldn't come up with an immediate workaround for you, but it is helpful data, thanks.

@ghost
Copy link

ghost commented Jul 19, 2014

You should try to brew install xz.

@brian-c
Copy link
Author

brian-c commented Jul 20, 2014

Hey, there ya go. Looks like xz was the missing bit. Thanks nanometre.

@rolandwalker
Copy link
Contributor

@nanometre, thanks for the analysis. The culprit is the -z flag to the file utility.

We use tar to unpack the archive, and Apple's tar knows how to unpack a .tar.xz file without any additional software. However, to determine the filetype, we invoke the following command

/usr/bin/file -Izb /Library/Caches/Homebrew/font-m-plus-1.050.tar.xz

The -z flag means "try to look inside compressed filetypes". Unlike the Apple-supplied tar, the Apple-supplied file utility does not have built-in xz support, and needs to invoke the xz utility in order to look inside and report the inner filetype.

Apple does not supply xz as a separate utility (which is odd, given that xz is the native format for pkg files).

The best solution for now is to add

depends_on_formula 'xz'

to the Cask.

rolandwalker added a commit to rolandwalker/homebrew-fonts that referenced this issue Aug 6, 2014
rolandwalker added a commit to rolandwalker/homebrew-fonts that referenced this issue Aug 6, 2014
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants