Homebrew / homebrew-cask

🍻 A CLI workflow for the administration of macOS applications distributed as binaries
https://brew.sh
BSD 2-Clause "Simplified" License
20.97k stars 10.75k forks source link

Bitcoin-core is failing #9667

Closed christopherkeller closed 9 years ago

christopherkeller commented 9 years ago

Installation fails before the package gets installed in the Caskroom directory, but opening it manually and dragging and dropping in /Applications seems to work just fine.

$ brew cask install --debug bitcoin-core
==> Creating directories
==> Loading Cask definitions
==> Translating 'bitcoin-core' into a valid Cask source
==> Testing source class Hbc::Source::URI
==> Testing source class Hbc::Source::PathSlashRequired
==> Testing source class Hbc::Source::TappedQualified
==> Testing source class Hbc::Source::UntappedQualified
==> Testing source class Hbc::Source::Tapped
==> Success! Using source class Hbc::Source::Tapped
==> Resolved Cask URI or file source to '/usr/local/Library/Taps/caskroom/homebrew-cask/Casks/bitcoin-core.rb'
==> Cask instance dumps in YAML:
==> Cask instance toplevel:
--- !ruby/object:KlassPrefixBitcoinCore
sourcefile_path: !ruby/object:Pathname
  path: /usr/local/Library/Taps/caskroom/homebrew-cask/Casks/bitcoin-core.rb
token: bitcoin-core
==> Cask instance method 'name':

---
- Bitcoin
- Bitcoin Core
==> Cask instance method 'homepage':
--- https://bitcoin.org/
...
==> Cask instance method 'url':
--- !ruby/object:Hbc::URL
uri: !ruby/object:URI::HTTPS
  scheme: https
  user:
  password:
  host: bitcoin.org
  port: 443
  path: /bin/0.10.0/bitcoin-0.10.0-osx.dmg
  query:
  opaque:
  registry:
  fragment:
  parser:
user_agent:
cookies:
referer:
using:
revision:
trust_cert:
data:
==> Cask instance method 'appcast':

---
...
==> Cask instance method 'version':
--- 0.10.0
...
==> Cask instance method 'license':
--- !ruby/object:Hbc::DSL::License
value: :mit
==> Cask instance method 'tags':

---
...
==> Cask instance method 'sha256':
--- ccb80a8476a8d6cee6378784efeb199357f7c34ae11a96c0f2af9a6c9a16d1a1
...
==> Cask instance method 'artifacts':

---
:app: !ruby/object:Set
  hash:
    ? - Bitcoin-Qt.app
      - :target: Bitcoin Core.app
    : true
==> Cask instance method 'caveats':
--- []
==> Cask instance method 'depends_on':

---
...
==> Cask instance method 'conflicts_with':

---
...
==> Cask instance method 'container':

---
...
==> Cask instance method 'gpg':

---
...
==> Cask instance method 'accessibility_access':

---
...
==> Hbc::Installer.install
==> Printing caveats
==> Downloading
==> Downloading https://bitcoin.org/bin/0.10.0/bitcoin-0.10.0-osx.dmg
Already downloaded: /Library/Caches/Homebrew/bitcoin-core-0.10.0.dmg
==> SHA256 checksums match
==> Downloaded to -> /Library/Caches/Homebrew/bitcoin-core-0.10.0.dmg
==> SHA256 checksums match
==> Extracting primary container
==> Determining which containers to use based on filetype
==> Checking container class Hbc::Container::Pkg
==> Checking container class Hbc::Container::Ttf
==> Checking container class Hbc::Container::Otf
==> Checking container class Hbc::Container::Air
==> Checking container class Hbc::Container::Cab
==> Executing: ["/usr/bin/file", "-Izb", "--", "#"]
==> Checking container class Hbc::Container::Dmg
==> Executing: ["/usr/bin/hdiutil", "imageinfo", "#"]
==> Using container class Hbc::Container::Dmg for /Library/Caches/Homebrew/bitcoin-core-0.10.0.dmg
==> Executing: ["/usr/bin/hdiutil", "mount", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", "/tmp", "#"]
==> Executing: ["/usr/bin/ditto", "--", "/private/tmp/dmg.Q0VQgH", "#"]
==> Executing: ["/usr/sbin/diskutil", "eject", "#"]
==> Installing artifacts
==> Determining which artifacts are present in Cask bitcoin-core
==> Checking for artifact class Hbc::Artifact::PreflightBlock
==> Checking for artifact class Hbc::Artifact::NestedContainer
==> Checking for artifact class Hbc::Artifact::Installer
==> Checking for artifact class Hbc::Artifact::App
==> Checking for artifact class Hbc::Artifact::Suite
==> Checking for artifact class Hbc::Artifact::Artifact
==> Checking for artifact class Hbc::Artifact::Colorpicker
==> Checking for artifact class Hbc::Artifact::Pkg
==> Checking for artifact class Hbc::Artifact::Prefpane
==> Checking for artifact class Hbc::Artifact::Qlplugin
==> Checking for artifact class Hbc::Artifact::Font
==> Checking for artifact class Hbc::Artifact::Service
==> Checking for artifact class Hbc::Artifact::StageOnly
==> Checking for artifact class Hbc::Artifact::Binary
==> Checking for artifact class Hbc::Artifact::InputMethod
==> Checking for artifact class Hbc::Artifact::InternetPlugin
==> Checking for artifact class Hbc::Artifact::ScreenSaver
==> Checking for artifact class Hbc::Artifact::Uninstall
==> Checking for artifact class Hbc::Artifact::PostflightBlock
==> Checking for artifact class Hbc::Artifact::Zap
==> 1 artifact/s defined
Hbc::Artifact::App
==> Installing artifact of class Hbc::Artifact::App
==> Symlinking App 'Bitcoin-Qt.app' to '/Applications/Bitcoin Core.app'
==> Executing: ["/bin/ln", "-hfs", "--", "#", "#"]
==> Adding com.apple.metadata:kMDItemAlternateNames metadata
==> Executing: ["/usr/bin/xattr", "-p", "com.apple.metadata:kMDItemAlternateNames", "#"]
==> Existing metadata is: ''
==> Executing: ["/usr/bin/xattr", "-w", "com.apple.metadata:kMDItemAlternateNames", "(\\\"Bitcoin Core.app\\\")", "#"]
==> Purging files for version 0.10.0 of Cask bitcoin-core
==> Executing: ["/usr/bin/chflags", "-R", "--", "000", "#"]
==> Executing: ["/bin/chmod", "-R", "--", "u+rwx", "#"]
==> Executing: ["/bin/chmod", "-R", "-N", "#"]
Error: Command failed to execute!

==> Failed command:
["/usr/bin/xattr", "-w", "com.apple.metadata:kMDItemAlternateNames", "(\\\"Bitcoin Core.app\\\")", "#"]

==> Output of failed command:

==> Exit status of failed command:
#
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/system_command.rb:56:in `_assert_success'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/system_command.rb:33:in `run'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/system_command.rb:39:in `run!'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/artifact/symlinked.rb:30:in `add_altname_metadata'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/artifact/symlinked.rb:13:in `create_filesystem_link'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/artifact/symlinked.rb:64:in `link'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/artifact/symlinked.rb:87:in `block in install_phase'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/artifact/symlinked.rb:87:in `each'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/artifact/symlinked.rb:87:in `install_phase'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/installer.rb:119:in `block in install_artifacts'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/installer.rb:117:in `each'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/installer.rb:117:in `install_artifacts'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/installer.rb:66:in `install'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/cli/install.rb:20:in `block in install_casks'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/cli/install.rb:17:in `each'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/cli/install.rb:17:in `install_casks'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/cli/install.rb:6:in `run'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/cli.rb:79:in `run_command'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/hbc/cli.rb:119:in `process'
/usr/local/Cellar/brew-cask/0.53.3/rubylib/brew-cask-cmd.rb:18:in `
'
rolandwalker commented 9 years ago

Hi! Thanks for the report!

This is similar to some other reports we have seen lately, and is likely an unintended downstream consequence of #8089. I plan to look into this tomorrow.

rolandwalker commented 9 years ago

@christopherkeller could you post the output of brew cask doctor ?

rolandwalker commented 9 years ago

==> Executing: ["/usr/bin/hdiutil", "imageinfo", "#"] ==> Using container class Hbc::Container::Dmg for /Library/Caches/Homebrew/bitcoin-core-0.10.0.dmg

@phinze, @radeksimko, @ndr-qef, @claui (if you are around) I can't duplicate this issue, and it seems like more than one thing is going wrong simultaneously on the user's system, which makes it tough to reason out. Suggestions welcome.

The debug output quoted above indicates that the correct hdiutil command did run (the argument wasn't really #). That suggests something is wrong with inspect. We actually called utf8_inspect here which was a workaround for Ruby UTF-8 oddities. We also preserved a monkeypatch on inspect from Homebrew which is likely intended to address the same issue.

And all of that would seem to be irrelevant to why the point of failure would be xattr. I do have some memory that xattr just happens to be the point in the process at which a permissions problem can sometimes manifest itself.

And, the exit status in the user's output is also rendered as #. That's not a Pathname, but should be a Process::Status instance, and is rendered with plain inspect

tapeinosyne commented 9 years ago

For what is worth, I could reproduce in both my Mavericks and Yosemite VMs (which is why I labelled the issue). However, my inspect output is fine.

Interestingly, cursory testing failed to find another :target cask which fails on xattr.

tapeinosyne commented 9 years ago

Printing stderr suggests permission issues, as @rolandwalker guessed:

==> Executing: ["/usr/bin/xattr", "-w", "com.apple.metadata:kMDItemAlternateNames", "(\\\"Bitcoin Core.app\\\")", "#<Pathname:/Applications/Bitcoin Core.app>"]
==> xattr: [Errno 13] Permission denied: '/Applications/Bitcoin Core.app'
christopherkeller commented 9 years ago

Permissions are possible I suppose, but it still fails if I install the symlink to /tmp via --appdir. Additionally, I can create files under /Applications via the command liine.

$ touch /Applications/foo
$ ls -l /Applications/foo
-rw-r--r--  1 macadmin  admin  0 Feb 21 13:51 /Applications/foo
$ rm /Applications/foo

Here is the requested output:

$ brew cask doctor
==> OS X Release:
10.10
==> OS X Release with Patchlevel:
10.10.2
==> Hardware Architecture:
intel-64
==> Ruby Version:
2.0.0-p481
==> Ruby Path:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
==> Homebrew Version:
0.9.5
==> Homebrew Executable Path:
/usr/local/bin/brew
==> Homebrew Cellar Path:
/usr/local/Cellar
==> Homebrew Repository Path:
/usr/local
==> Homebrew Origin:
https://github.com/Homebrew/homebrew
==> Homebrew-cask Version:
0.53.3
==> Homebrew-cask Install Location:
/usr/local/Cellar/brew-cask/0.53.3
==> Homebrew-cask Staging Location:
/opt/homebrew-cask/Caskroom
==> Homebrew-cask Cached Downloads:
/Library/Caches/Homebrew
/Library/Caches/Homebrew/Casks
4 files (warning: run "brew cask cleanup")
36.10 megs (warning: run "brew cask cleanup")
==> Homebrew-cask Default Tap Path:
/usr/local/Library/Taps/caskroom/homebrew-cask
==> Homebrew-cask Alternate Cask Taps:
/usr/local/Library/Taps/caskroom/homebrew-versions
==> Homebrew-cask Default Tap Cask Count:
2297
==> Contents of $LOAD_PATH:
/usr/local/Cellar/brew-cask/0.53.3/rubylib
/Library/Ruby/Site/2.0.0
/Library/Ruby/Site/2.0.0/x86_64-darwin14
/Library/Ruby/Site/2.0.0/universal-darwin14
/Library/Ruby/Site
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby/2.0.0
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby/2.0.0/x86_64-darwin14
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby/2.0.0/universal-darwin14
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/x86_64-darwin14
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin14
==> Contents of $RUBYLIB Environment Variable:

==> Contents of $RUBYOPT Environment Variable:

==> Contents of $RUBYPATH Environment Variable:

==> Contents of $RBENV_VERSION Environment Variable:

==> Contents of $CHRUBY_VERSION Environment Variable:

==> Contents of $GEM_HOME Environment Variable:

==> Contents of $GEM_PATH Environment Variable:

==> Contents of $BUNDLE_PATH Environment Variable:

==> Contents of $PATH Environment Variable:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/usr/texbin:/usr/local/Library/ENV/scm"
==> Contents of $SHELL Environment Variable:
SHELL="/bin/bash"
==> Contents of Locale Environment Variables:

==> Running As Privileged User:
No
rolandwalker commented 9 years ago

Thanks @christopherkeller!

We also confirmed in IRC that there are two apparently unrelated problems. The xattr error can happen without the inspect output mangling.

SuperHenkie commented 9 years ago

I recently ran into the same issue. Is there anything I can do to get bitcoin-core cask installer working?

deizel commented 9 years ago

Unfortunately, this is still an issue today it seems.

radeksimko commented 9 years ago

I just managed to reproduce that problem too in my Yosemite VM.

As mentioned above, permissions are really the reason:

==> Executing: ["/usr/bin/xattr", "-w", "com.apple.metadata:kMDItemAlternateNames", "(\"Bitcoin Core.app\")", "#<Pathname:/Users/vagrant/Applications/Bitcoin Core.app>"] ==> xattr: [Errno 13] Permission denied: '/Users/vagrant/Applications/Bitcoin Core.app'

this is output from ls -la:

lrwxr-xr-x 1 vagrant staff 62 May 14 00:14 /Users/vagrant/Applications/Bitcoin Core.app -> /opt/homebrew-cask/Caskroom/bitcoin-core/0.10.1/Bitcoin-Qt.app

and now :tada: surprise surprise, output from ls -la /opt/homebrew-cask/Caskroom/bitcoin-core/0.10.1/:

total 40
drwxr-xr-x  6 vagrant  staff    204 May 14 00:19 .
drwxr-xr-x  3 vagrant  staff    102 May 14 00:19 ..
-r-xr-xr-x  1 vagrant  admin  15364 May 31  2013 .DS_Store
dr-xr-xr-x  3 vagrant  admin    102 May 31  2013 .background
lrwxr-xr-x  1 vagrant  admin     13 May 14 00:19 Applications -> /Applications
dr-xr-xr-x  3 vagrant  admin    102 May 31  2013 Bitcoin-Qt.app

so as you can see, Bitcoin-Qt.app is shipped with r-xr-xr-x permissions, which means that even the owner cannot write into the file.

I managed to fix it like this:

diff --git a/lib/hbc/artifact/symlinked.rb b/lib/hbc/artifact/symlinked.rb
index bcaa1a3..2c57fa8 100644
--- a/lib/hbc/artifact/symlinked.rb
+++ b/lib/hbc/artifact/symlinked.rb
@@ -27,6 +27,9 @@ class Hbc::Artifact::Symlinked < Hbc::Artifact::Base
     altnames.concat(', ') if altnames.length > 0
     altnames.concat(%Q{"#{target.basename}"})
     altnames = %Q{(#{altnames})}
+
+    @command.run!('/bin/chmod', :args => ['u=rwx', source])
+
     @command.run!('/usr/bin/xattr',
                   :args => ['-w', attribute, altnames, target],
                   :print_stderr => false)

I will send a PR soon.

deizel commented 9 years ago

This patch works for me on a real Yosemite install - nice find! :clap:

$ vim /usr/local/Cellar/brew-cask/0.54.0/rubylib/hbc/artifact/symlinked.rb
$ rm -Rf ~/Applications/Bitcoin\ Core.app && brew cask install bitcoin-core
==> Downloading https://bitcoin.org/bin/bitcoin-core-0.10.1/bitcoin-0.10.1-osx.dmg
Already downloaded: /Library/Caches/Homebrew/bitcoin-core-0.10.1.dmg
==> Symlinking App 'Bitcoin-Qt.app' to '/Users/deizel/Applications/Bitcoin Core.app'
🍺  bitcoin-core staged at '/opt/homebrew-cask/Caskroom/bitcoin-core/0.10.1' (16 files, 24M)
rxacevedo commented 9 years ago

The above patch solves the issue for me as well - thanks! :+1:

deizel commented 9 years ago

FYI - still waiting on the patch to be merged (#11200). The temporary fix is to apply the patch manually.

vitorgalvao commented 9 years ago

Yes, I’m aware.

deizel commented 9 years ago

:+1:

jawshooah commented 9 years ago

11200 has been merged. Expect a new release with the fix later this evening.

wkentaro commented 9 years ago

I might have same problem, even after updating homebrew-cask.

% brew cask install mikogo
==> Downloading http://download.mikogo4.com/mikogo.dmg
######################################################################## 100.0%
==> Symlinking App 'Mikogo-host.app' to '/Users/ken/Applications/Mikogo.app'
Error: Command failed to execute!

==> Failed command:
["/usr/bin/xattr", "-w", "com.apple.metadata:kMDItemAlternateNames", "(\\\"Mikogo.app\\\")", "#<Pathname:/Users/ken/Applications/Mikogo.app>"]

==> Output of failed command:

==> Exit status of failed command:
#<Process::Status: pid 99190 exit 1>

I have same error on bitcoin-core, too.