Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A command to upgrade all casks ? #13256

Closed
matthewharwood opened this issue Aug 13, 2015 · 13 comments
Closed

A command to upgrade all casks ? #13256

matthewharwood opened this issue Aug 13, 2015 · 13 comments

Comments

@matthewharwood
Copy link

What is the best method on updating and upgrading a cast? Say I have webstorm and I want to update to a new version? Is there a method to upgrade all casks at once?

@scribblemaniac
Copy link
Contributor

There is no official method for upgrading homebrew casks. This is currently being worked on, but it is still very far from completion. See #4678 for more details. That issue also has some examples of scripts that users use to upgrade all of their casks. The simplest way to upgrade a single cask would be to run brew cask install --force <cask_name>, but just know that there is a chance this may cause issues with your app since it won't be properly uninstalled first.

@vitorgalvao
Copy link
Member

After #13201 is done, we’ll be able to start working on an upgrade solution. Until then, @scribblemaniac’s answer is correct.

@szhu
Copy link
Contributor

szhu commented Aug 14, 2015

#!/bin/bash
# /usr/local/bin/brew-cask-reinstall
# Usage: brew cask-reinstall token1 token2 ...
for token in "$@"; do
    echo "==> Re-installing $token"
    brew cask uninstall --force "$token" && brew cask install "$token"
done

Sidenote: Will Homebrew Cask support external commands like brew does in the future? brew cask reinstall would look better than brew cask-reinstall.

@vitorgalvao
Copy link
Member

Actually, I recommend:

caskup() {
  rm -rf "$(brew --cache)"
  brew update
  brew cask uninstall --force "$@"
  brew cask install "$@"
}

If you don’t get rid of the cache and try to reinstall a cask with :latest, you risk getting an old version (known issue). Same is true if you don’t update first.

There are no plans for a reinstall command, no. Don’t really see a strong case for it, but could be convinced otherwise. Currently, though, it’d have a really low priority.

@szhu
Copy link
Contributor

szhu commented Aug 14, 2015

Ah I see. The thing is, flushing the cache and re-downloading are sometimes long operations so I save those for other invocations. Even from a less pragmatic standpoint, I don't think reinstall should do anything in addition to what install does – "reinstall" basically should be "remove and install".

Also my question about the external commands was, will Homebrew Cask support the invoking external commands that begin with brew-cask-? For example, if I have an executable in my PATH called git-testcommand, I can invoke it with git testcommand. Likewise, the brew-cask executable can be invoked with brew cask.

@scribblemaniac
Copy link
Contributor

If you don't like the look of the command, you can always just use alias to format it more to your liking.

@szhu
Copy link
Contributor

szhu commented Aug 14, 2015

No I can't. I want it to look like brew cask reinstall, with spaces in between. That necessarily requires the brew command to recognize it. Both git and brew have code specifically to allow these kind of external commands to be invoked in this way.

@vitorgalvao this discussion should be in a separate issue, huh

@scribblemaniac
Copy link
Contributor

Oh, I didn't realize alias names couldn't have spaces (I don't use them very often). Anyway, this should indeed be a separate issue.

@deinspanjer
Copy link
Contributor

I posted an answer to the stackoverflow, but figured it wouldn't hurt to put it here as well. I wanted a function that let me interactively choose which casks to re-install or not. I also put the --quick argument in to not have to blow away the cache and update if I had just done so but exited out.

brew-cask-upgrade() {
  if [ "$1" != '--quick' ]; then
    echo "Removing brew cache"
    rm -rf "$(brew --cache)"
    echo "Running brew update"
    brew update
  fi
  for c in $(brew cask list); do
    echo -e "\n\nInstalled versions of $c: "
    ls /opt/homebrew-cask/Caskroom/$c
    echo "Cask info for $c"
    brew cask info $c
    select ynx in "Yes" "No" "Exit"; do
      case $ynx in
        "Yes") echo "Uninstalling $c"; brew cask uninstall --force "$c"; echo "Re-installing $c"; brew cask install "$c"; break;;
        "No") echo "Skipping $c"; break;;
        "Exit") echo "Exiting brew-cask-upgrade"; return;;
      esac
    done
  done
}

@Yann-R
Copy link

Yann-R commented Oct 21, 2015

Is there a method to upgrade all casks at once?

Personally, I use

brew cask install `brew cask list`

It's not totally perfect (otherwise why would we wait for a built-in upgrade command ;-))
because I have to clean "obsolete" old versions from the Caskroom folder after upgrading... But in a sense it's OK and safe for my use since this way I'm sure the previous version is still there in case the new version would be disappointing...

@n0ts
Copy link
Contributor

n0ts commented Jan 12, 2017

Hi, I created brew-cask-upgrade.sh
https://gist.github.com/n0ts/94693a99756c1f47c94f5b2c005530e8

@vitorgalvao
Copy link
Member

There are tons of those scripts. Please stop posting them. There are more than enough, and they all suffer from the same issues.

@Homebrew Homebrew locked and limited conversation to collaborators Jan 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants