# What's the proper way to install and upgrade pkg?



## mrjayviper (Apr 18, 2014)

I have just setup FreeBSD 9.2 and I want to start familiarizing myself with the pkgng so I installed pkg via pkg_add.

```
pkg_add -r pkg
```

This install pkg 1.1.4 I believe. This isn't the latest as trying to install another app (e.g. pkg install editors/nano) would install a newer version (I believe this is 1.2.x). Anyway, the install would fail because pkg 1.2.x uses configuration that's not compatible with version 1.1.x. So I would then use the new pkg.conf.sample as my new pkg.conf.

I'm just wondering if there is a step I can run between the initial "pkg_add" and the 1st "pkg install" so I can upgrade pkg to whatever is the latest. I tried "pkg upgrade" but it seems it doesn't really upgrade pkg.

Thanks very much


----------



## kpa (Apr 18, 2014)

Try this:

`/usr/sbin/pkg bootstrap -f`


----------



## asteriskRoss (Apr 18, 2014)

@mrjayviper, did you remember to run `pkg2ng` after installing ports-mgmt/pkg to convert the package database?  You may also want to append the following to /etc/make.conf

```
WITH_PKGNG=yes
```

Reference: FreeBSD handbook: Using pkgng for Binary Package Management.


----------



## mrjayviper (Apr 18, 2014)

kpa said:
			
		

> Try this:
> 
> `/usr/sbin/pkg bootstrap -f`



Thank you so much. My setup is now running whatever is latest. Previously, using pkg_add (as mentioned in the handbook) will confused my setup. The pkg "database" is on version 1.1.x even after running pkg2ng while the pkg executable is on 1.2.x.


----------



## kpa (Apr 18, 2014)

mrjayviper said:
			
		

> kpa said:
> 
> 
> 
> ...



Don't forget to set WITH_PKGNG=yes in /etc/make.conf, the setting is not yet the default on the version of FreeBSD you're using. Also after switching to PKGNG packaging tools you'll have to forget that the pkg_add etc. tools exist, mixing those with the new PKGNG tools is not possible.


----------

