Reinstall package manager in FreeBSD 10.X

Default featured post

pkg_info/pkg_create/pkg_add commands have been replaced in FreeBSD version 10.X by pkg. Personally I think the new package manager is quite amazing and way better than the old one. For more details about new features, refer to this link.

However, on very rare and unusual occasions pkg might break and stop working. For instance, in my case, the system turned off inappropriately and caused pkg to stop working.

The easiest solution to tackle the issue is to reinstall the package manager. To do so first go to ports directory available at /usr/ports/ports-mgmt/pkg.

# cd /usr/ports/ports-mgmt/pkg

The next step is to so-called deinstall the corrupted package manager by running this command.

# make deinstall

And then compile the package and install it.

# make
# make install clean

Lastly, reboot your system and issue pkg to see whether it is working or not.