# Rebuilding System After Pkg Autoremove Obliterated It



## ThothK (Jul 20, 2019)

Hiya,

Like a fool I ran pkg autoremove -y. As a result many of the programs I use day to day are broken somehow. In the case of one ('digikam') the actual program was removed which is a surprise because I explicitly installed it with pkg. 
My understanding is that programs that I explicitly install with pkg install will not be removed. 

My question is "is there a way to undo the effects of pkg autoremove"?






The attached image should show:
- The version of FreeBSD I use.
- The output of 'which digikam' (nothing).
- List of the log file that was created when I installed digikam using pkg install
- The first several lines of the log file.

There are other programs that were removed that I explicitly installed with pkg install. I am still working my way through the items.

At any rate, is there a shortcut or do I have to manually reinstall everything? I ask because I encountered one package that failed because of a version difference and one that reports an undefined symbol.



=thoth=


----------



## rigoletto@ (Jul 20, 2019)

pkg-autoremove will just remove orphaned packages (aka automatic installed), and so that will not touch anything you installed or anything that some other installed package depends on. Thus, it looks like your installation is somehow messed or the dependencies of some package changed a lot - eventually a meta port.

I advise you to run `pkg check -Bsd` to find out if there is something broken, then `pkg prime-list > pkglist` to get the list of your origins (the packages you installed directly) in a file, have a look on it and remove anything you don't want as an origin file (something which should be only a dependence if anything). You can also add some packages you think is missing or you want to installed anyway (as a origin package).

Then, run `pkg del -fa` to remove all installed  packages, followed by `pkg ins `cat pkglist`` to install the packages of your list again.

This should put everything in order (if there is something messed), and better to do it logged as root because after all packages be removed you will not have sudo/doas anymore.  

*[EDIT]*

For KDE you probably want to install it using some meta ports like: x11/plasma5-plasma, x11/kde-baseapps etc.

You can use `pkg info [-a]` to get information of installed packages.


----------



## tingo (Jul 21, 2019)

Of course, it is always best to do a dry run first, like so `# pkg autoremove -n`. Then you can see whatever packages it wants to remove before something bad happens.


----------



## Phishfry (Jul 22, 2019)

rigoletto@ said:


> Then, run  pkg del -fa to remove all installed packages, followed by  pkg ins `cat pkglist` to install the packages of your list again.


Probably should run `pkg clean` in between these right?? Clear the pkg cache just in case.
I have never seen these type troubles.

This is a nice trick installing packages from a list. I know I needed this before and failed.


rigoletto@ said:


> pkg install `cat pkglist`


I grabbed my list this way but it does include versions.
`pkg leaf > build.list`
I believe `pkg` will take the arguments with the versions included.

`pkg prime-list` does make it easier to reuse the list.


----------



## rigoletto@ (Jul 22, 2019)

Phishfry said:


> Probably should run `pkg clean` in between these right?? Clear the pkg cache just in case.
> I have never seen these type troubles.
> 
> This is a nice trick installing packages from a list. I know I needed this before and failed.



Yes, not a bad idea in between to run `pkg clean`.


----------

