Homebrew-cask: Unable to install virtualbox cask

Created on 4 Mar 2015  路  5Comments  路  Source: Homebrew/homebrew-cask

First ran initial troubleshooting step (replaced && with ;) :

$ brew update ; brew upgrade brew-cask ; brew cleanup ; brew cask cleanup
Already up-to-date.
Error: brew-cask 0.53.3 already installed
==> Removing dead symlinks
Nothing to do
==> Removing cached downloads
Nothing to do

Which seemed to be fine, next ran brew doctor:

$ brew doctor
Your system is ready to brew.

Finally, virtualbox:

$ brew cask install --verbose virtualbox
==> Downloading http://download.virtualbox.org/virtualbox/4.3.24/VirtualBox-4.3.24-98716-OSX.dmg
Already downloaded: /Library/Caches/Homebrew/virtualbox-4.3.24-98716.dmg
==> Running installer for virtualbox; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
==> sudo: sorry, you are not allowed to preserve the environment
Error: Command failed to execute!

==> Failed command:
["/usr/bin/sudo", "-E", "--", "/usr/sbin/installer", "-pkg", "#<Pathname:/opt/homebrew-cask/Caskroom/virtualbox/4.3.24-98716/VirtualBox.pkg>", "-target", "/", "-verboseR"]

==> Output of failed command:


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

My sudo environment details:

$ sudo -l
Matching Defaults entries for erikankrom on this host:
    env_reset, env_keep+=BLOCKSIZE, env_keep+="COLORFGBG COLORTERM", env_keep+=__CF_USER_TEXT_ENCODING, env_keep+="CHARSET LANG LANGUAGE LC_ALL LC_COLLATE
    LC_CTYPE", env_keep+="LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME", env_keep+="LINES COLUMNS", env_keep+=LSCOLORS, env_keep+=SSH_AUTH_SOCK, env_keep+=TZ,
    env_keep+="DISPLAY XAUTHORIZATION XAUTHORITY", env_keep+="EDITOR VISUAL", env_keep+="HOME MAIL"

User erikankrom may run the following commands on this host:
    (ALL) ALL
    (root) NOPASSWD: /usr/bin/createcert.bash, (root) /usr/bin/createplist.bash, (root) /usr/bin/update.bash, (root) /usr/bin/updater.bash, (root)
    /usr/bin/start.bash, (root) /usr/bin/stop.bash, (root) /usr/bin/restart.bash, (root) /usr/bin/status.bash, (root) /usr/bin/reboot.bash, (root)
    /usr/bin/removecerts.bash, (root) /usr/bin/createimovie.bash, (root) /usr/bin/createwsj.bash, (root) /usr/bin/lock.bash, (root) /usr/bin/trash.bash, (root)
    /usr/bin/updatewc.bash, (root) /usr/bin/pmsscan.bash, (root) /usr/bin/shutdown.bash, (root) /usr/bin/sleep.bash, (root) /usr/bin/itunes.bash, (root)
    /usr/bin/utorrent.bash, (root) /usr/bin/quititunes.bash, (root) /usr/bin/log.bash, (root) /usr/bin/who.bash, (root) /usr/bin/wake.bash, (root)
    /usr/bin/tv.bash, (root) /usr/bin/timemachine.bash, (root) /usr/bin/webconnect.bash, (root) /usr/bin/websharing.bash, (root) /usr/bin/uninstall.bash,
    (root) /usr/bin/sudoersfix.bash, (root) /usr/bin/install.bash, (root) /usr/bin/installphp.bash, (root) /usr/bin/createauto.bash, (root)
    /usr/bin/fixclone.bash, (root) /usr/bin/trashbase.bash, (root) /usr/bin/icon.bash, (root) /usr/bin/fixuser.bash, (root) /usr/bin/mod.bash, (root)
    /usr/bin/backup.bash, (root) /usr/bin/restore.bash, (root) /usr/bin/10.6.bash, (root) /usr/bin/10.10.bash, (root) /usr/bin/checker.bash, (root)
    /usr/bin/plexweb.bash, (root) /usr/bin/plexwebios.bash, (root) /usr/bin/plexwebioswan.bash, (root) /usr/bin/plexweblist.bash, (root)
    /usr/bin/plexweblistwan.bash, (root) /usr/bin/plexwebwan.bash
    (root) NOPASSWD: /usr/sbin/installer

More specifically:

$ /usr/bin/sudo -E -- /usr/sbin/installer 
sudo: sorry, you are not allowed to preserve the environment

It seems to be a problem with the -E option combined with /usr/bin/installer?

Most helpful comment

There is another way to get out of this issue by modifying the following line in sudoers file

%admin ALL=(root) NOPASSWD: /usr/sbin/installer *

to

%admin ALL=(root) NOPASSWD:SETENV: /usr/sbin/installer *

All 5 comments

It seems I solved the issue by commenting the following line in my /private/etc/sudoers file:

%admin ALL=NOPASSWD: /usr/sbin/installer

Modified to:

#%admin ALL=NOPASSWD: /usr/sbin/installer

Restart my terminal session, resolved. Not sure why that line existed specifically for that executable.

dont follow the last post verbatium
I just locked myself out of sudo....

There is another way to get out of this issue by modifying the following line in sudoers file

%admin ALL=(root) NOPASSWD: /usr/sbin/installer *

to

%admin ALL=(root) NOPASSWD:SETENV: /usr/sbin/installer *

Requesting this issue be re-opened. Myself and three other colleagues have all experienced this with the latest updates to homebrew cask. None of the above methods have helped.

@ihgann Open a new issue. Make sure to follow the reporting bugs guide.

Was this page helpful?
0 / 5 - 0 ratings