# Deleting dependencies



## pennsatucky (Jan 3, 2015)

Hi friends.
So I have a very common question..how to remove package and all dependencies?
FreeBSD 10.1

I've tried `pkg autoremove` after deleting some port, but it is going to delete many packages. For example, I've removed icewm, `autoremove` wants to delete bash, zim etc. So I just "locked" them.

And now I'm frustrated...
So can someone tell me, how I should properly delete dependencies without my system getting broken?


----------



## junovitch@ (Jan 3, 2015)

`pkg autoremove` is the correct way to go about this.  Any packages that were automatically installed and no longer needed will get removed.  For whatever reason, some packages you rely on look to be marked as automatically installed.  You may want to review the lists and set the packages you want to be non-automatic so `pkg autoremove` won't touch them.

List non-automatic, explicitly installed, packages:
`pkg query -e '%a=0' %o`

List automatic packages:
`pkg query -e '%a=1' %o`

Set a package to be non-automatic:
`pkg set -A 0 bash`

See `pkg help query` and `pkg help set`.


----------



## Luca79 (Sep 20, 2015)

I wish to know if the command `portmaster -s` is a good solution for clean dependencies...
Seem nobody have mentioned this way in the forum.


----------



## junovitch@ (Sep 20, 2015)

Luca79 said:


> I wish to know if the command `portmaster -s` is a good solution for clean dependencies...
> Seem nobody have mentioned this way in the forum.


Just use the native tool for the job.  portmaster(8) just calls pkg(8) anyway so just use `pkg autoremove` to remove unused dependencies.


----------



## Luca79 (Sep 21, 2015)

junovitch@ said:


> Just use the native tool for the job.  portmaster(8) just calls pkg(8) anyway so just use `pkg autoremove` to remove unused dependencies.



I not knew about `pkg autoremove`. Thanks for the reply!


----------



## KoMa350 (Oct 17, 2018)

Hello everybody,

I have a question regarding the works of `pkg autoremove`:
Once I install a package it wants to delete the dependencies needed for installation. Here is an example:
`# pkg install ninja
New packages to be INSTALLED:
        ninja: 1.8.2,2 [FreeBSD]
        compat10x-amd64: 10.3.1003000.20170608 [Synth]
        svgalib: 1.4.3_7 [FreeBSD]
        lapack: 3.5.0_5 [FreeBSD]
        blas: 3.5.0_4 [FreeBSD]

Number of packages to be installed: 5

The process will require 40 MiB more space.

Proceed with this action? [y/N]: y
[1/5] Installing blas-3.5.0_4...
[1/5] Extracting blas-3.5.0_4: 100%
[2/5] Installing ninja-1.8.2,2...
[2/5] Extracting ninja-1.8.2,2: 100%
[3/5] Installing compat10x-amd64-10.3.1003000.20170608...
[3/5] Extracting compat10x-amd64-10.3.1003000.20170608: 100%
[4/5] Installing svgalib-1.4.3_7...
[4/5] Extracting svgalib-1.4.3_7: 100%
[5/5] Installing lapack-3.5.0_5...
[5/5] Extracting lapack-3.5.0_5: 100%`

and now:

`# pkg autoremove

Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 4 packages:

Installed packages to be REMOVED:
        lapack-3.5.0_5
        blas-3.5.0_4
        compat10x-amd64-10.3.1003000.20170608
        svgalib-1.4.3_7

Number of packages to be removed: 4

The operation will free 40 MiB.

Proceed with deinstalling packages? [y/N]:`

aren't those packages dependencies for ninja?


----------



## SirDice (Oct 17, 2018)

None of them are dependencies of devel/ninja:

```
root@molly:/usr/ports/devel/ninja # make {run,lib}-depends
===>   ninja-1.8.2,2 depends on file: /usr/local/bin/python2.7 - found
```
There's also a irc/ninja but it has 0 (zero) dependencies:

```
root@molly:/usr/ports/irc/ninja # make {run,lib}-depends
root@molly:/usr/ports/irc/ninja #
```

Both end up having a package named ninja. But judging by the version, you're dealing with devel/ninja.


----------



## KoMa350 (Oct 17, 2018)

thanks for your quick reply. indeed devel/ninja, sorry for not having clarified.

haven't thought about checking it out this way, actually pkg itself shows the same:
`# pkg info -d devel/ninja

ninja-1.8.2,2:
python27-2.7.15`

so something fishy is going on when installing devel/ninja with pkg, for some reason it installs 4 ports that don't seem to be necessary. well, i won't think about it too much, `pkg autoremove` works seemingly alright, and that was the issue in the first place.

thanks again for your help, cheers!


----------



## ShelLuser (Oct 17, 2018)

KoMa350 said:


> so something fishy is going on when installing devel/ninja with pkg


I couldn't help notice mention of Synth in your first post, are you perhaps installing both ports and binary packages at the same time? Because that could definitely explain a thing or two, and it's usually not the best of ideas because it can cause dependency conflicts.


----------



## KoMa350 (Oct 20, 2018)

well, here's how i approach ports/packages:
for a new install i normally use pkg, except when there's a config i want to change, e.g. with multimedia/ffmpeg. then i'd build from ports. i use Synth for updating the installed ports/packages, and in the mentioned case compat10x-amd64 was found in the synth repository, i guess.
so probably yes, i'm mixing ports and packages...


----------

