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

Possible issue with outdated formulae #28

Closed
airdrummingfool opened this issue Mar 13, 2018 · 5 comments
Closed

Possible issue with outdated formulae #28

airdrummingfool opened this issue Mar 13, 2018 · 5 comments
Assignees
Labels

Comments

@airdrummingfool
Copy link

Hello,
Thanks for this very useful tool! I usually think to prune my old formulae when they show up in brew outdated (i.e. when they need to be upgraded). I tried to rmtree an outdated version of highlight, which depends on lua (which I have an outdated version of as well), but rmtree failed to detect/remove lua:

Tommy:~
$ brew outdated
[snip]
highlight (3.39) < 3.42
[snip]
lua (5.2.4_4) < 5.3.4_2
[snip]
Tommy:~
$ brew rmtree highlight
==> Examining installed formulae required by highlight...
 /

Can safely be removed
----------------------
highlight

Proceed?[y/N]: y
==> Cleaning up packages safe to remove
Warning: Skipping highlight: most recent version 3.42 not installed

Uninstalling /usr/local/Cellar/highlight/3.39... (381 files, 2.5MB)
Tommy:~

at this point, highlight was successfully uninstalled (thought it did give a warning saying it was "skipping" highlight since it wasn't the newest version). but lua was not uninstalled, which it should have been, since only highlight depended on it - proven by brew uninstall lua not complaining:

$ brew uninstall lua
Uninstalling /usr/local/Cellar/lua/5.2.4_4... (144 files, 705.1KB)
Tommy:~

I tried rmtree with a fresh install of highlight/lua, and it worked fine.

$ brew install highlight
==> Installing dependencies for highlight: lua
==> Installing highlight dependency: lua
==> Downloading https://homebrew.bintray.com/bottles/lua-5.3.4_2.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring lua-5.3.4_2.high_sierra.bottle.tar.gz
==> Caveats
Please be aware due to the way Luarocks is designed any binaries installed
via Luarocks-5.3 AND 5.1 will overwrite each other in /usr/local/bin.

This is, for now, unavoidable. If this is troublesome for you, you can build
rocks with the `--tree=` command to a special, non-conflicting location and
then add that to your `$PATH`.
==> Summary
🍺  /usr/local/Cellar/lua/5.3.4_2: 147 files, 752.9KB
==> Installing highlight
==> Downloading https://homebrew.bintray.com/bottles/highlight-3.42.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring highlight-3.42.high_sierra.bottle.tar.gz
🍺  /usr/local/Cellar/highlight/3.42: 396 files, 2.7MB
2018-03-12 23:52:46 Tommy:~
$ brew rmtree highlight
==> Examining installed formulae required by highlight...
 /

Can safely be removed
----------------------
highlight
lua

Proceed?[y/N]: y
==> Cleaning up packages safe to remove

Uninstalling /usr/local/Cellar/highlight/3.42... (396 files, 2.7MB)

Uninstalling /usr/local/Cellar/lua/5.3.4_2... (147 files, 752.9KB)
@beeftornado
Copy link
Owner

Interesting. I'll definitely take a look. Seems like it could be tricky to find the root cause though. Thanks for the report!

@beeftornado beeftornado self-assigned this Apr 23, 2018
@beeftornado
Copy link
Owner

I believe the issue is as you stated, with outdated dependencies. It seems as though when, in your example, lua is outdated, rmtree is not considering it installed and then gets excluded from subsequent operations. Should be pretty straightforward to fix.

@beeftornado
Copy link
Owner

And it looks like I have my very own test case. On my computer, brew uses node only prints out yarn. But when I try and fake remove yarn,

$ brew rmtree --dry-run yarn
This is a dry-run, nothing will be deleted
==> Examining installed formulae required by yarn...
 /

Can safely be removed
----------------------
yarn

Won't be removed
-----------------


Order of operations
-------------------
yarn
Would have removed yarn

It should have also removed node. Both node and yarn are outdated.

@beeftornado
Copy link
Owner

Ah, ok. Specifically the issue is with how we get the formula instance of what you want to remove. In my case, I have yarn 1.5, but rmtree is using the formula for yarn 1.6, which depends on node latest, which I don't have installed, which is why it isn't getting removed.

$ brew info yarn
yarn: stable 1.6.0
JavaScript package manager
https://yarnpkg.com/
Conflicts with:
  hadoop (because both install `yarn` binaries)
/usr/local/Cellar/yarn/1.5.1_1 (14 files, 4.1MB) *
  Built from source on 2018-03-20 at 15:53:57
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/yarn.rb
==> Dependencies
Recommended: node ✘
==> Options
--without-node
        Build without node support

@beeftornado
Copy link
Owner

Ok, I think I found a solution. Now when I try and remove yarn, it correctly looks at installed dependencies.

$ brew rmtree --dry-run yarn
This is a dry-run, nothing will be deleted
==> Examining installed formulae required by yarn...
 /

Can safely be removed
----------------------
yarn
node

Won't be removed
-----------------
icu4c is used by harfbuzz, sqlite

Order of operations
-------------------
yarn
node
Would have removed yarn
Would have removed node

I'll publish the fix for this shortly. Thanks again for finding this and including all that helpful info @airdrummingfool

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

No branches or pull requests

2 participants