Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

puppet-brewcask does not create Caskroom. "Error: Unknown command: cask" #2

Closed
jalessio opened this issue Jul 17, 2013 · 10 comments
Closed

Comments

@jalessio
Copy link

I'm using puppet-brewcask to replace the one-repo-per-app model for Boxen. On a fresh Boxen install I am unable to successfully install using brewcask.

Doing this:

include brewcask
package { 'adium' : provider => 'brewcask' }

Results in:

Error: Unknown command: cask
Error: Could not set 'present' on ensure: Failed running sudo -E -u jamie /opt/boxen/homebrew/bin/brew cask install x-quartz at 109:/opt/boxen/repo/manifests/site.pp
Error: Could not set 'present' on ensure: Failed running sudo -E -u jamie /opt/boxen/homebrew/bin/brew cask install x-quartz at 109:/opt/boxen/repo/manifests/site.pp
Wrapped exception:
Failed running sudo -E -u jamie /opt/boxen/homebrew/bin/brew cask install x-quartz

I believe this error is occurring because this code, which creates the Caskroom, is not being executed in the puppet-brewcask workflow:
https://github.com/phinze/homebrew-cask/blob/master/lib/cask.rb#L44

I think the solution is to provide additional brewcask initialization code in one of these two locations:
https://github.com/phinze/puppet-brewcask/blob/master/manifests/init.pp#L4
https://github.com/phinze/puppet-brewcask/blob/master/lib/puppet/provider/package/brewcask.rb#L20

Could you provide guidance on the best place/method for ensuring the Caskroom is created and that homebrew registers the "cask" external command? Thanks!

@phinze
Copy link
Contributor

phinze commented Jul 17, 2013

Awkward! Let me take a look at this. Stupid bootstrapping problems. 😉 👢

@phinze
Copy link
Contributor

phinze commented Jul 17, 2013

So the init method is called pretty early in the stack,

https://github.com/phinze/homebrew-cask/blob/master/lib/cask/cli.rb#L20-L21

but it looks like this happens even earlier than that, when homebrew is looking for a brew-cask.rb executable.

Still investigating...

@sts
Copy link

sts commented Dec 8, 2013

Hi Guys.

I got the same error when the Caskroom directories where different in cask and in the puppet provider:

Error: Unknown command: cask
Error: Could not set 'present' on ensure: Failed running sudo -E -u sts /opt/boxen/homebrew/bin/brew cask install adium. at 56:/opt/boxen/modules/people/manifests/sts.pp
Error: Could not set 'present' on ensure: Failed running sudo -E -u sts /opt/boxen/homebrew/bin/brew cask install adium. at 56:/opt/boxen/modules/people/manifests/sts.pp
Wrapped exception:
Failed running sudo -E -u sts /opt/boxen/homebrew/bin/brew cask install adium.
Error: /Stage[main]/People::Sts/Package[adium]/ensure: change from absent to present failed: Could not set 'present' on ensure: Failed running sudo -E -u sts /opt/boxen/homebrew/bin/brew cask install adium. at 56:/opt/boxen/modules/people/manifests/sts.pp

I could resolve the issue by changing the Caskroom path in the provider to /opt/homebrew-cask/Caskroom.

Puppet uses /opt/boxen/homebrew/Caskroom
https://github.com/phinze/puppet-brewcask/blob/master/lib/puppet/provider/package/brewcask.rb#L31

Homebrew-casks sets the path to /opt/homebrew-cask/Caskroom
https://github.com/phinze/homebrew-cask/blob/master/lib/cask/locations.rb#L12

Are you trying to set the caskroom by environment variable as well?

@halo
Copy link

halo commented Dec 12, 2013

I ran into the same issue when playing around with this thing. Similarly to puppet, I simply ran a bash script using chef and I got the same error that you describe.

Funny enough, simply by making sure that the homebrew executables where in the PATH fixed the issue. So I just added this to the command and it worked:

export PATH="/custom/path/to/homebrew/bin:$PATH && brew cask ..."

@sts
Copy link

sts commented Dec 12, 2013

I guess this bug is related and we need a more general solution here boxen/puppet-vim#16 👋

@rbdixon
Copy link

rbdixon commented Jan 16, 2014

I hit this error as well.

@phinze
Copy link
Contributor

phinze commented Jan 16, 2014

Hey folks - unfortunately I'm not Boxening anymore, which means I'm not actively using this library. If anybody is interested in taking on this issue I'm happy to hand out commit rights to the project. Just ping me. 🐉

@joemaller
Copy link

Seeing the same issue trying to get Cask working from an Ansible playbook

update: Not a fix for this issue, but like @halo's comment, setting the task's environment path got Cask working from Ansible:

- name: Cask test
  environment: {PATH: '/usr/local/bin:{{ ansible_env["PATH"] }}'}
  shell: brew cask install kaleidoscope --appdir=/Applications

@phinze
Copy link
Contributor

phinze commented Jul 12, 2014

Thanks to @juniorz we have some progress on this in 0.0.4 - can anybody checkout this error and see if it's closed now?

@radeksimko
Copy link
Contributor

I can confirm that this was an issue with 0.0.3

Error: Unknown command: cask
Error: Could not set 'present' on ensure: Failed running sudo -E -u vagrant /opt/boxen/homebrew/bin/brew cask install adium at 74:/opt/boxen/repo/manifests/site.pp
Error: Could not set 'present' on ensure: Failed running sudo -E -u vagrant /opt/boxen/homebrew/bin/brew cask install adium at 74:/opt/boxen/repo/manifests/site.pp
Wrapped exception:
Failed running sudo -E -u vagrant /opt/boxen/homebrew/bin/brew cask install adium
Error: /Stage[main]/Main/Node[default]/Package[adium]/ensure: change from absent to present failed: Could not set 'present' on ensure: Failed running sudo -E -u vagrant /opt/boxen/homebrew/bin/brew cask install adium at 74:/opt/boxen/repo/manifests/site.pp

and that it is fixed in the latest version

Notice: /Stage[main]/Brewcask/File[/opt/homebrew-cask]/ensure: created
Notice: /Stage[main]/Brewcask/File[/opt/homebrew-cask/Caskroom]/ensure: created
Notice: /Stage[main]/Main/Node[default]/Package[adium]/ensure: created

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

7 participants