Fix Broken Dependency on FreeBSD

Dunno about you but I update my packages often … and I have lots of them, more then 1000 actually.

% pkg info | wc -l

… but its not much, they are mostly dependencies to to software that I use.

For example I need Openbox and X11 but to use them I need 300+ dependencies in libraries and protocols, and its OK, that’s how it works … but sometimes after the upgrade one or two applications forbid to start because of missing dependency. I would sa that it happens one in twenty to thirty updates (1/20 – 1/30) which is very rare and even if it happens its very easy to solve. I also happened to me on Linux systems many times so its not FreeBSD only related, its just how open source desktop/laptop market works πŸ™‚

Today’s victim will be Chromium. I generally use Firefox but sometimes when a page behaves strangely in Firefox I verify this behavior in Chromium. I also use Chromium as file opener (or file browser should I say) for the *.htm/*.html/*.chm local files. But this time it forbid to start, so I went to the command line to check what went wrong.

% chrome
Shared object "" not found, required by ""

… a missing dependency in the form of library.

Reckless Symlink

This method is considered dangerous or quick and dirty way of fixing such problems – it can also introduce other problems by itself – but still – in many cases it temporary solves the problem.

… and its exactly that – a quick fix till the ffmpeg package finishes its rebuild – it takes longer then pkg upgrade command but when I need Chromium now its NOW, not later when ffmpeg package will be rebuilt. This problem is caused by lack of guts of the FreeBSD project to provide lame package. OpenBSD guys does not have problem with that but FreeBSD guys do, so to have MP3 support in ffmpeg you need to first manually build lame package and then select it as option in ffmpeg and again built is as package … and do that everytime you run pkg upgrade command … which is PITA to say the least.

This is why I use script for that purpose – to not do that β€˜by hand’ everytime I update packages (which is about two times a week). This is the β€˜workflow’ if I can call it like that:

# pkg upgrade
# build

Lets verify it something else is not missing for Chromium then.

% which chrome

% ldd /usr/local/bin/chrome
ldd: /usr/local/bin/chrome: not a dynamic executable

So /usr/local/bin/chrome is just a wrapper, let’s see what it contains.

% cat /usr/local/bin/chrome

if [ "`/sbin/sysctl -n $SYSCTL`" = 0 ] ; then
        cat << EOMSG
For correct operation, shared memory support has to be enabled
in Chromium by performing the following command as root :

sysctl $SYSCTL=1

To preserve this setting across reboots, append the following
to /etc/sysctl.conf :

        exit 1
ulimit -c 0
exec /usr/local/share/chromium/chrome ${1+"$@"}

So our binary actually is /usr/local/share/chromium/chrome file, lets check it with ldd(8) then.

% ldd /usr/local/share/chromium/chrome
/usr/local/share/chromium/chrome: => /lib/ (0x809b78000) => /usr/local/lib/ (0x809da0000) => /usr/local/lib/ (0x80a0df000) => /usr/local/lib/ (0x80a2e0000) => /usr/local/lib/ (0x80a506000) => /usr/local/lib/ (0x80a708000) => /usr/local/lib/ (0x80a913000) => /usr/local/lib/ (0x80ab15000) => /usr/local/lib/ (0x80ad26000) => /usr/local/lib/ (0x80af2b000) => /usr/local/lib/ (0x80b139000) => /usr/local/lib/ (0x80b342000) => /usr/local/lib/ (0x80b547000) => /usr/local/lib/ (0x80b74a000) => /usr/local/lib/ (0x80ba61000) => /usr/local/lib/ (0x80bcab000) => /usr/local/lib/ (0x80beac000) => /usr/local/lib/nss/ (0x80c0b7000) => /usr/local/lib/nss/ (0x80c3e3000) => /usr/local/lib/nss/ (0x80c60d000) => /usr/local/lib/ (0x80c83d000) => /usr/local/lib/ (0x80ca40000) => /usr/local/lib/ (0x80cc44000) => /usr/lib/ (0x80ce83000) => /usr/local/lib/ (0x80d084000) => /usr/local/lib/ (0x80d315000) => /usr/local/lib/ (0x80d6a8000) => /usr/local/lib/ (0x80d8ef000) => /usr/lib/ (0x80db40000) => /lib/ (0x80dd43000) => /lib/ (0x80df51000) => /usr/local/lib/ (0x80e165000) => /usr/local/lib/ (0x80e367000) => /usr/local/lib/ (0x80e56b000) => /usr/local/lib/ (0x80e775000) => /usr/local/lib/ (0x80ea05000) => /usr/local/lib/ (0x80ecbb000) => /usr/local/lib/ (0x80ef4e000) => /usr/local/lib/ (0x80f179000) => /usr/local/lib/ (0x80f458000) => /usr/local/lib/ (0x80f66b000) => /usr/local/lib/ (0x80f875000) => /usr/local/lib/ (0x80fe00000) => /usr/local/lib/ (0x811800000) => /usr/local/lib/ (0x811c52000) => /usr/local/lib/ (0x811eca000) => /usr/local/lib/ (0x8121da000) => /usr/local/lib/ (0x8124de000) => /usr/local/lib/ (0x8126e6000) => /usr/local/lib/ (0x812956000) => /usr/local/lib/ (0x812b63000) => /usr/local/lib/ (0x812db1000) => /usr/local/lib/ (0x8130d8000) => /usr/local/lib/ (0x813366000) => /usr/local/lib/ (0x813571000) => /usr/local/lib/ (0x81379c000) => /usr/local/lib/ (0x8139cc000) => /usr/local/lib/ (0x813bfd000) => /usr/local/lib/ (0x814000000) => /usr/local/lib/ (0x8148b9000) => /usr/local/lib/ (0x814bb0000) => /usr/local/lib/ (0x814db8000) => /usr/local/lib/ (0x814fdb000) => /lib/ (0x815218000) => /usr/lib/ (0x815430000) => /lib/ (0x815659000) => /usr/lib/ (0x815886000) => /usr/lib/ (0x815a8c000) => /lib/ (0x815d5a000) => /lib/ (0x800823000) => /usr/local/lib/ (0x815f79000) => /usr/local/lib/ (0x81617c000) => /usr/local/lib/ (0x816381000) => /usr/local/lib/ (0x81667c000) => /usr/local/lib/ (0x81691a000) => /usr/local/lib/ (0x816b21000) => /usr/local/lib/ (0x816ed4000) => /usr/local/lib/ (0x8170e0000) => /lib/ (0x8172ef000) => /lib/ (0x81750e000) => /lib/ (0x817725000) => /usr/lib/ (0x817934000) => /usr/local/lib/ (0x817b48000) => /usr/local/lib/ (0x817d71000) => /usr/local/lib/ (0x818000000) => /usr/local/lib/ (0x818411000) => /usr/local/lib/ (0x818732000) => /usr/local/lib/ (0x8189b3000) => /usr/local/lib/ (0x818be2000) => /usr/local/lib/ (0x818df3000) => /usr/local/lib/ (0x819024000) => not found (0) => /usr/local/lib/ (0x819400000) => /usr/local/lib/ (0x819b4b000) => /usr/local/lib/ (0x819e70000) => /usr/local/lib/ (0x81a096000) => /usr/local/lib/ (0x81a316000) => /usr/local/lib/ (0x81a518000) => /usr/local/lib/ (0x81a71d000) => /usr/local/lib/ (0x81a920000) => /usr/local/lib/ (0x81ab36000) => /usr/local/lib/ (0x81ad4c000) => /usr/local/lib/ (0x81b016000) => /usr/local/lib/ (0x81b24e000) => /usr/local/lib/ (0x81b489000) => /usr/local/lib/ (0x81b68b000) => /usr/local/lib/ (0x81b898000) => /usr/local/lib/ (0x81ba9b000) => /usr/local/lib/ (0x81bca2000) => /usr/local/lib/ (0x81bea4000) => /usr/local/lib/ (0x81c0aa000) => /usr/local/lib/ (0x81c2ab000) => /usr/local/lib/ (0x81c505000) => /usr/local/lib/ (0x81c71e000) => /usr/local/lib/ (0x81c922000) => /usr/local/lib/ (0x81cb26000) => /usr/local/lib/ (0x81cd2c000) => /usr/local/lib/ (0x81cf2e000) => /usr/local/lib/ (0x81d16b000) => /usr/local/lib/ (0x81d372000) => /usr/local/lib/ (0x81d573000) => /usr/local/lib/ (0x81d782000) => /usr/local/lib/ (0x81da91000) => /usr/local/lib/ (0x81ddb2000) => /usr/local/lib/ (0x81dfc7000) => /usr/local/lib/ (0x81e1ff000) => /usr/local/lib/ (0x81e435000) => /usr/local/lib/ (0x81e653000) => /usr/local/lib/ (0x81ea07000) => /usr/local/lib/ (0x81ec15000) => /usr/local/lib/ (0x81ee28000)

Lots of deps here, lets cut to the point with grep(1) as shown below.

% ldd /usr/local/share/chromium/chrome | grep found => not found (0)

Only one – – dependency is missing. Let’s fix it then.

% cd /usr/local/lib
% ls -l*
lrwxr-xr-x  1 root  wheel       14 2019.03.19 02:11 ->
-rwxr-xr-x  1 root  wheel  2090944 2019.03.19 02:11

There is little newer version available so we will link to it with our ‘missing’ name.

# pwd
# ln -s
# ls -l*
lrwxr-xr-x  1 root  wheel       14 2019.03.19 02:11 ->
lrwxr-xr-x  1 root  wheel       10 2019.03.21 15:26 ->
-rwxr-xr-x  1 root  wheel  2090944 2019.03.19 02:11

Chromium should be happy now.

% ldd /usr/local/share/chromium/chrome | grep found

Zero not found results.

Let’s start Chromium then with chrome command.

% chrome

Starts as usual and everything works πŸ™‚

This whole process can be visualized with this simple screenshots below.


Using /etc/libmap.conf File

Instead making ad symlink – which will work globally – you can create the proper libmap.conf file with configuration only for /usr/local/share/chromium/chrome binary.

Here is the fix only for Chromium browser.

# cat /etc/libmap.conf


… and equivalent solution that works globally as symlink would be as follows.

# cat /etc/libmap.conf

Its also easier to migrate or mass populate such changes instead of copying a symlink.

Fixing Broken Dependency in pkg(8) Database

I already wrote about it in the Less Known pkg(8) Features article but its worth mentioning here for the completeness of options.

There was time when one missing dependency about vulnerable www/libxul19 package started to torture me for some time.

I was even desperate to compile everything with portmaster already.

I started with portmaster --check-depends command, but said no ‘n‘ when asked for fix as it will downgrade a lot of packages needlessly.

# portmaster --check-depends
Checking dependencies: evince
graphics/evince has a missing dependency: www/libxul19

>>> Missing package dependencies were detected.
>>> Found 1 issue(s) in total with your package database.

The following packages will be installed:

        Downgrading perl: 5.14.2_3 -> 5.14.2_2
        Downgrading glib: 2.34.3 -> 2.28.8_5
        Downgrading gio-fam-backend: 2.34.3 -> 2.28.8_1
        Downgrading libffi: 3.0.12 -> 3.0.11
        Downgrading gobject-introspection: 1.34.2 -> 0.10.8_3
        Downgrading atk: 2.6.0 -> 2.0.1
        Downgrading gdk-pixbuf2: 2.26.5 -> 2.23.5_3
        Downgrading pango: 1.30.1 -> 1.28.4_1
        Downgrading gtk-update-icon-cache: 2.24.17 -> 2.24.6_1
        Downgrading dbus: 1.6.8 -> 1.4.14_4
        Downgrading gtk: 2.24.17 -> 2.24.6_2
        Downgrading dbus-glib: 0.100.1 -> 0.94
        Installing libxul:

The installation will require 66 MB more space

38 MB to be downloaded

>>> Try to fix the missing dependencies [y/N]: n
>>> Summary of actions performed:

www/libxul19 dependency failed to be fixed

>>> There are still missing dependencies.
>>> You are advised to try fixing them manually.

>>> Also make sure to check 'pkg updating' for known issues.

Lets see what pkg(8) shows we have installed.

# pkg info | grep libxul
libxul-10.0.12                 Mozilla runtime package that can be used to bootstrap XUL+XPCOM apps

# pkg info -qoa | grep libxul

So the problem is that we have installed www/libxul instead of www/libxul19 and that is why portmaster (and not only) complains about it.

Before pkg(8) was introduced it was easy just to grep -r the entire /var/db/pkg directory with its ‘file database’ but now its quite more complicated as the package database is kept in SQLite database. Using pkg shell command You can connect to that database. Lets check what we can find there.

# pkg shell
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .databases
seq  name             file
---  ---------------  ----------------------------------------------------------
0    main             /var/db/pkg/local.sqlite
sqlite> .tables
categories       licenses         pkg_directories  scripts
deps             mtree            pkg_groups       shlibs
directories      options          pkg_licenses     users
files            packages         pkg_shlibs
groups           pkg_categories   pkg_users
sqlite> .header on
sqlite> .mode column
sqlite> pragma table_info(deps);
cid         name        type        notnull     dflt_value  pk
----------  ----------  ----------  ----------  ----------  ----------
0           origin      TEXT        1                       1
1           name        TEXT        1                       0
2           version     TEXT        1                       0
3           package_id  INTEGER     0                       1
sqlite> .quit

So now we know that ‘deps‘ table is probably what we are looking for ;).

As pkg shell is quite limited for SQLite ‘browsing’ I will use the sqlite3 command itself. By limited I mean that You can not type pkg shell "select * from deps;" query, You first need to start pkg shell and then You can type your query.

# sqlite3 -column /var/db/pkg/local.sqlite "select * from deps;" | grep libxul
www/libxul19   libxul  104

The second column is name so lets try to use it.

sqlite3 -header -column /var/db/pkg/local.sqlite "select * from deps where name='libxul';"
origin        name        version     package_id
------------  ----------  ----------  ----------
www/libxul19  libxul  104

So now we have the ‘problematic’ dependency entry nailed, lets modify it a little to the real installed packages state.

# sqlite3 /var/db/pkg/local.sqlite "update deps set origin='www/libxul' where name='libxul';"
# sqlite3 /var/db/pkg/local.sqlite "update deps set version='10.0.12' where name='libxul';"

You can of course use the ‘official’ way by using the pkg shell command.

# pkg shell
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> update deps set origin='www/libxul' where name='libxul';
sqlite> update deps set version='10.0.12' where name='libxul';
sqlite> .header on
sqlite> .mode column
sqlite> select * from deps where name='libxul';
origin      name        version     package_id
----------  ----------  ----------  ----------
www/libxul  libxul      10.0.12     104
sqlite> .quit

Now portmaster is happy and does not complain about any missing dependencies.

# portmaster --check-depends
Checking dependencies: zenity
Checking dependencies: zip
Checking dependencies: zsh

Viola! Problem solved πŸ˜‰

… but pkg(8) has a tool for that already πŸ™‚

Its called pkg set and two most useful options from man pkg-set are.

  -n oldname:newname, --change-name oldname:newname
       Change the package name of a given dependency from oldname to newname.


  -o oldorigin:neworigin, --change-origin oldorigin:neworigin
       Change the port origin of a given dependency from oldorigin to neworigin.
       This corresponds to the port directory that the package originated from.
       Typically, this is only needed for upgrading a library or package that
       has MOVED or when the default version of a major port dependency changes.
       (DEPRECATED) Usually this will be explained in /usr/ports/UPDATING.
       Also see pkg-updating(8) and EXAMPLES.

In our case we would use pkg set -o www/libxul19:www/libxul command.

Not sure if it will solve that problem in the same way as I also updated the version in the database.

Use pkg_libchk from bsdadminscripts2 Package

There is also other way to fix/check for such problems – its the pkg_libchk from the bsdadminscripts2 package. Keep in mind that there are TWO conflicting (!) packages with bsdadminscripts in their name.

# pkg search bsdadmin
bsdadminscripts-6.1.1_8        Collection of administration scripts
bsdadminscripts2-0.2.1         BSD Administration Scripts 2


… and once you install bsdadminscripts2 you will not be able to install bsdadminscripts because they are conflicting. I already had bsdadminscripts2 installed and wanted to add bsdadminscripts to my system.

# pkg install bsdadminscripts
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking integrity... done (1 conflicting)
  - bsdadminscripts-6.1.1_8 conflicts with bsdadminscripts2-0.2.1 on /usr/local/sbin/distviper
Checking integrity... done (0 conflicting)
The following 2 package(s) will be affected (of 0 checked):

Installed packages to be REMOVED:

New packages to be INSTALLED:
        bsdadminscripts: 6.1.1_8

Number of packages to be removed: 1
Number of packages to be installed: 1

Proceed with this action? [y/N]: n

Here is the description of the /usr/ports/ports-mgmt/bsdadminscripts2 port/package.

# cat /usr/ports/ports-mgmt/bsdadminscripts2/pkg-descr
This is a collection of scripts around the use of ports and packages.

It allows you to: 
- check library dependencies without producing false positives (pkg_libchk)
- lets you manage the autoremove flag for leaf packages (pkg_trim)
- remove obsolete or damaged distfiles (distviper)
- manage build flags (buildflags.conf)
- auto-create pkg-plist files taking port options into account (makeplist)


There are exactly 4 tools in this package.

% pkg info -l bsdadminscripts2 | grep bin

Invoked without any arguments it will check all packages installed in a system.

# pkg_libchk
Jobs done:   35 of 1057

… so in order to make the ckecks only for Chromium you will need to specify chromium package with pkg_libchk chromium command.

The pkg_libchk allows you to fetch missing dependencies based on which package provides what files or create a list of the packages that need to be rebuilt.

Use Provides Database

You can also use ‘provides’ database from pkg(8) command.

% pkg provides lib/
Name    : libx264-0.157.2945
Desc    : H.264/MPEG-4 AVC Video Encoding (Library)
Repo    : FreeBSD
Filename: /usr/local/lib/

To learn how to setup ‘provides’ database for pkg(8) command check the Less Known pkg(8) Features article please.

UPDATE 1 – Rework Entire Article

The Roman philosopher Seneca once said – “While we teach, we learn.” – it is very true – especially for this article. After I posted it on various places people reminded my that its not the best way to just create symlink and that its not the best way to do it. I stand corrected and added additional sections and methods of fixing a broken dependency on a FreeBSD (or Linux/Illumos) system.


7 thoughts on “Fix Broken Dependency on FreeBSD

    1. vmisev

      I posted comment before I did pkg upg. I just updated, ffpmeg had upgrade and ldd ffpmeg is showing libx264 1.57
      libx264-0.157.2945.txz 2019-Mar-19 01:19
      ffmpeg-4.1.1_10,1.txz 2019-Mar-19 02:33
      (quarterly pkgs still have libx264-0.155)

      Also, I just installed chromium to check (chromium-72.0.3626.121_1.txz 2019-Mar-19 17:13) and
      ldd /usr/local/share/chromium/chrome | grep libx264 => /usr/local/lib/

      so maybe there is no need for that ln anymore πŸ˜€
      All best πŸ™‚


      1. vermaden Post author

        Thank you for little investigation πŸ™‚

        That is exactly the case and I rebuild ffmpeg after pkg upgrade but when I need Chromium now its now, not later when ffmpeg package will be rebuilt – hence the ‘fix’ post – maybe someone find it useful.

        Its not actually a solution – its more like – you can try this and in 90% cases it should work, I will make an UPDATE to the post and will try to ‘fix’ that.


        Liked by 1 person

  1. Glen Neff

    Good job troubleshooting, but sadly, your “fix” was bushleague and could potentially break more things on your next update. Creating willy-nilly symlinks in a pkg-managed prefix like /usr/local is never a good idea. I suggest you read libmap.conf(1).


  2. Pingback: Valuable News – 2019/03/25 | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  3. Pingback: In Other BSDs for 2019/03/23 – DragonFly BSD Digest

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s