# Somehow pkg is installed from ports, not binary package



## vaskark (Nov 16, 2022)

Not sure how this happened. I built one app from ports and then checked a list of installed ports. I see that `pkg` has _also_ installed from ports-mgmt/pkg, over the previous binary package of pkg. 
Is there any way to get the binary pkg back? I'm sorry if this is a stupid question.
Thanks.

13.1-Release-p3


----------



## richardtoohey2 (Nov 16, 2022)

Not sure if there's a problem - that's how most of my systems are set-up but I don't mix ports and packages - sticking with ports for now.

Don't _think_ the binary would have been replaced - /usr/sbin is the system pkg, /usr/*local*/sbin will be the port-installed version.


```
$ which pkg
/usr/sbin/pkg
$ /usr/sbin/pkg --version
1.18.4
$ /usr/local/sbin/pkg --version
1.18.4
```

But not sure what's "best" here or if I've got a mess that hasn't caught up with me yet.


----------



## vaskark (Nov 16, 2022)

Thanks for replying. Not sure why I didn't think of that.

Upon checking, I don't even have /usr/local/bin/pkg, just /usr/sbin/pkg as normal. Checking /usr/ports/distfiles and it's also empty of pkg.

Weird. See? I knew it was stupid.


----------



## richardtoohey2 (Nov 16, 2022)

You’ve missed the s from sbin - check in /usr/local/sbin

I don’t know what’s right so see what other feedback you get - I’m just saying don’t be too worried (yet!)


----------



## vaskark (Nov 16, 2022)

Sigh!

In /usr/local/*s*bin:


```
pkg
pkg-static
pkg-static.pkgsave
```


----------



## zirias@ (Nov 16, 2022)

Each and every port/package depends on ports-mgmt/pkg. The version in base is normally just used for "bootstrapping": Download and install the current version of `pkg`.

If building/installing some software from ports also triggers building/installing `pkg`, it most likely means your ports tree has a newer version of it than available in the package repository you use. This in itself is not a problem at all, it's just an update.

But it might be a hint that you're mixing ports and packages from different versions, which can quickly lead to other problems. The most common error is to use "quarterly" packages (the default configuration of `pkg`) with "latest" ports (which is what e.g. portsnap(8) fetches). If that's the case, either configure `pkg` to use latest packages, see the handbook, or use e.g. net/gitup to fetch your ports from the current quarterly branch.


----------



## SirDice (Nov 16, 2022)

richardtoohey2 said:


> /usr/sbin is the system pkg, /usr/*local*/sbin will be the port-installed version.


/usr/sbin/pkg is pkg(7), /usr/local/sbin/pkg is pkg(8). pkg(7) from the base is used to bootstrap ports-mgmt/pkg.


----------



## vaskark (Nov 16, 2022)

zirias@ said:


> But it might be a hint that you're mixing ports and packages from different versions, which can quickly lead to other problems. The most common error is to use "quarterly" packages (the default configuration of `pkg`) with "latest" ports (which is what e.g. portsnap(8) fetches). If that's the case, either configure `pkg` to use latest packages, see the handbook, or use e.g. net/gitup to fetch your ports from the current quarterly branch.


I am on latest in /usr/local/etc/pkg/repos/FreeBSD.conf and did run `pkg update -f`. And if portsnap is also on latest then I'll assume I'm fine for now.

Many thanks to everyone for their help.


----------



## zirias@ (Nov 16, 2022)

vaskark, yes, then you're (mostly) fine. Of course, package builders always lag a few days behind the ports tree (they need time to build as well), so an upgrade of `pkg` can still be explained.

Not sure it's suitable for your usecase, but I'll mention it just in case: poudriere enables you to build your own package repository, and the version in ports-mgmt/poudriere-devel has the nice feature to just fetch official binary packages instead of building *if* they're a "perfect match" (same version, same options, same dependencies). This is the most reliable way for "mixing ports and packages".


----------



## vaskark (Nov 16, 2022)

zirias@ said:


> Not sure it's suitable for your usecase, but I'll mention it just in case: poudriere enables you to build your own package repository, and the version in ports-mgmt/poudriere-devel has the nice feature to just fetch official binary packages instead of building *if* they're a "perfect match" (same version, same options, same dependencies). This is the most reliable way for "mixing ports and packages".


Thanks for your suggestion. I'm still new so I didn't realize it was a precarious situation to mix packages and ports. I'll check out ports-mgmt/pourdriere-devel.


----------

