# Reinstalling packages & dependencies



## Raul_BCN_ES (Nov 15, 2015)

Hi everybody,

Something wierd happened last night after updating and installing several packages (related with editors/lazarus and lang/fpc). The fact is that for some reason lots of system libraries has dissapeared. For instance, if I try to execute `mc` the midnight commander I get a message 
	
	



```
library libslang.so.1 is not installed
```
 It's a total chaos because I'm not able even to run again Xorg. It complains about lots of broken dependencies.

Few quick questions:

I've read that to reinstall the whole system you can do `# pkg upgrade -f`


I think that it does reinstall the packages but not it's dependencies. Can you confirm this please? If I try `pkg upgrade -f mc` it re-installs the midnight commander but as I see, not the Slang libraries it depends on. I am missing something? Removing misc/mc and installing it again doesn't solve the issue.
How do I *force reinstallation of a package AND all it's dependencies*, including X11 system libraries or whatever?
How do I guess what package includes "libslang.so.2" for example? is there a pkg(8) command to perform this query?
Thank you very much,

regards,
Raúl


----------



## ANOKNUSA (Nov 16, 2015)

Raul_BCN_ES said:


> Something wierd happened lastnight after updating and installing several packages (related with Lazarus/fpc).



Just to clarify, did you run a full package upgrade (`pkg upgrade`) or did you upgrade only specific packages? Only installing some updates while leaving out others can cause problems sometimes.


----------



## Raul_BCN_ES (Nov 16, 2015)

I am sure that it's my very own fault because now I see that I "manually" decided to force the installation of certain packages, but they affected to the whole system.

To keep fully updated my system I always run `# freebsd-update` to fetch patches and install them. Then I run `# pkg update/upgrade` and accept all upgrades. For hardware reasons (four monitors, 2 GT210 cards) I use the legacy nvidia driver, not the latest one, so the package nvidia-drivers has to be locked to avoid an unwanted upgrade.

It was not the latest update itself the problem (I guess), it was when installing fpc-units. For some reason, the free pascal compiler port (fpc) is not provided with the complete collection of units(*) so you must install fpc-units binary port afterwards. The problem comes when you try to install lang/fpc-units and other related packages: it complains and advises that the following packages will be *REMOVED* (pcbsd-meta-base, kde4, gcc, binutils...) I cannot understand the reason for such incompatibility. Maybe I shall talk to the maintainer of the lang/fpc port or probably there's something somewhere that I didn't read and should had.

Yeah, you're right. I am so smart that I said *YES* and the show began. When I realized of what was going on it was to late. So I noted in a paper all the packages that were removed and I tried to reinstall them again. Don't panic, cake easy I thought.

When reinstalling the removed packages I was advised that lang/fpc-units has to be removed, so I decided to LOCK them, but if you do so pkg(8) is unable to reinstall the previously removed packages, so I decided to unlock them again, accept it's removal and proceed to reinstall devel/binutils, lang/gcc, x11/kde4, _pcbsd-meta-base_, etc. I actually use PCBSD though, so maybe it's not a real FreeBSD problem but anyway, the recovery of the broken dependencies theoretically shall be similar in both distributions.

The result is that during this procedure some libraries were lost, and many programs (like print/cups, www/nginx, x11/xorg, misc/mc, etc) now complain of broken dependencies. So this is the real question:  how can I force the reinstall  of  the installed packages and ALL their dependencies? `pkg upgrade -f` doesn't.

(*) This is solved installing the FreeBSD binaries & source from the SourceForge project's homepage instead of using the official binary package from the FreeBSD repositories.

Thanks ANOKNUSA,

Regards,
Raúl


----------



## protocelt (Nov 16, 2015)

Raul_BCN_ES said:


> [...]
> (*) This is solved installing the freebsdFreeBSD binaries & source from the SourceForge project's homepage instead of using the official binary package from the freebsdFreeBSD repositories.
> [...]


This is likely a very bad idea. By installing applications outside the ports tree pkg(8) can't track them now and will likely clobber/overwrite some of those and/or other files the first time you try to update anything. At the very least you'll likely end up with mysterious issues down the road.

If there was a valid dependency issue, the right thing to do here would have been to file a problem report against the issue and have it fixed so no one else runs into this issue in the future.


----------



## Raul_BCN_ES (Nov 17, 2015)

Thanks protocelt

I finally managed to solve the situation booting into another zfs boot environment that was not corrupted and from there I was able to reinstall everything, removing the damaged one.

Using the command
`pkg upgrade -f mc` it reinstalls Midnight-Commander (shells/mc) and all it's dependencies authomatically like libslang.so and such.

To recover the full installation I used then (it works):
`pkg upgrade -f` This command reinstalls everything again, dependencies included.

What I don't understand is why this works in one environment and not in the other.

regards,
Raúl


----------



## protocelt (Nov 18, 2015)

It's hard to say what's going on, and I honestly don't know. I will say locking packages is a bad idea unless you really know what you are doing and know how and what to do when problems arise as a result which could be related. The pkg(8) database could possibly have been corrupted.

Keep in mind you are using PC-BSD, and there are differences from FreeBSD proper. What those differences are, I don't know as I haven't tried out PC-BSD in some time. That may or may not have been related to the problem here as well.


----------

