# Initializing pkg



## donallen (Aug 27, 2016)

In 10.3 and now in 11RC2, when following the instruction in the Handbook to run

/usr/sbin/pkg

to bootstrap the pkg system, you get an error complaining that pkg was run with insufficient args.

Either the documentation is wrong or the bootstrap is process is causing this. Either way, it does not inspire confidence and whatever the cause, the problem should be fixed.


----------



## tobik@ (Aug 27, 2016)

Yeah, it should be `/usr/sbin/pkg bootstrap`. You mean this chapter right? https://www.freebsd.org/doc/handbook/pkgng-intro.html


----------



## donallen (Aug 27, 2016)

tobik said:


> Yeah, it should be `/usr/sbin/pkg bootstrap`. You mean this chapter right? https://www.freebsd.org/doc/handbook/pkgng-intro.html



The URL I'm seeing is

https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/pkgng-intro.html

but clearly we're talking about the same thing.


----------



## tobik@ (Aug 29, 2016)

FYI, we are both wrong. I've just setup a new FreeBSD VM and if you run `/usr/sbin/pkg` for the first time it asks if you want to fetch and install pkg.


----------



## kpa (Aug 29, 2016)

I'd guess you already have ports-mgmt/pkg installed, in that case the bootstrap program is going to complain about missing arguments if it's run as `# /usr/sbin/pkg`.


----------



## donallen (Aug 29, 2016)

tobik said:


> FYI, we are both wrong. I've just setup a new FreeBSD VM and if you run `/usr/sbin/pkg` for the first time it asks if you want to fetch and install pkg.



That was not what happened with me. I just got the error message I reported about insufficient args. pkg did and does work correctly after this though. My issue is that doing what the doc says should not result in an error message of any kind. This also happened with two installs of 10.3.

kpa Your guess is not correct. This was a fresh install of 11RC2 and I had not installed ports-mgmt/pkg.


----------



## ShelLuser (Aug 29, 2016)

I'm not sure from mind but I could well imagine that there is a huge difference between the initial behavior of a stable release and that of a release candidate.


----------



## Yampress (Sep 6, 2016)

```
pkg-static install -f pkg
```


----------



## donallen (Sep 6, 2016)

Yampress said:


> ```
> pkg-static install -f pkg
> ```



This is the answer to a question I didn't ask. My issue, if you read my original post again, is not getting pkg set up (which I did). It's that following the instructions in the documentation produces an error, which it should not.


----------



## donallen (Sep 6, 2016)

ShelLuser said:


> I'm not sure from mind but I could well imagine that there is a huge difference between the initial behavior of a stable release and that of a release candidate.



Read my original post again. The behavior I report also occurred in the 10.3 *release*.


----------



## SirDice (Sep 6, 2016)

The error is correct, the handbook should use something like `pkg -vv` or, probably better, `pkg bootstrap` to prevent the error showing up.


----------



## donallen (Sep 6, 2016)

SirDice said:


> The error is correct, the handbook should use something like `pkg -vv` or, probably better, `pkg bootstrap` to prevent the error showing up.



This should be fixed in the doc then. It does no operational harm (pkg does get bootrapped and works correctly afterwards despite the error), but it harms confidence in the system, just as getting compiler warnings do when building something that ends up working.


----------



## donallen (Jul 3, 2017)

Incredibly, this *still* has not been fixed after almost a year.


----------



## ShelLuser (Jul 4, 2017)

donallen said:


> Incredibly, this *still* has not been fixed after almost a year.


Well, feel free to pick up the pace then 

Seriously though, although the command generates an error it's also fair to note that the bootstrap _does_ work (see attachment from my VM). So basically the handbook isn't completely wrong here.


----------



## donallen (Jul 4, 2017)

ShelLuser said:


> Well, feel free to pick up the pace then
> 
> Seriously though, although the command generates an error it's also fair to note that the bootstrap _does_ work (see attachment from my VM). So basically the handbook isn't completely wrong here.



If I had write access to the Handbook sources, I'd have fixed it last year 

As for your second sentence, you are absolutely right, as far as you go. I am talking about the impression this makes. It is in the same category as spelling errors in one of the FreeBSD web pages. You could make the argument that if "seperate" appeared on a web page, everyone would understand that as "separate" (essentially the same argument you are making: "it works"). But it looks bad. FreeBSD is a serious system, the result of a lot of hard work by a lot of people over many years. I think it's a shame to let something like this, so easily fixed, detract from that, even in this very small way.


----------



## SirDice (Jul 4, 2017)

donallen said:


> If I had write access to the Handbook sources, I'd have fixed it last year


You don't need that. _Anybody_ can submit PRs for the documentation.



> It is in the same category as spelling errors in one of the FreeBSD web pages. You could make the argument that if "seperate" appeared on a web page, everyone would understand that as "separate" (essentially the same argument you are making: "it works"). But it looks bad. FreeBSD is a serious system, the result of a lot of hard work by a lot of people over many years. I think it's a shame to let something like this, so easily fixed, detract from that, even in this very small way.


Submit PRs for it. Same as the documentation, _anybody_ can submit fixes, updates or rewrites. Issues don't magically fix themselves, somebody has to submit a PR to set things in motion. If everybody thinks somebody else will fix it, nothing would get done. It's a community effort after all. 

FreeBSD Documentation Project Primer for New Contributors
https://bugs.freebsd.org/bugzilla/enter_bug.cgi?product=Documentation


----------



## ANOKNUSA (Jul 4, 2017)

donallen said:


> If I had write access to the Handbook sources, I'd have fixed it last year



https://www.freebsd.org/docproj/



donallen said:


> I think it's a shame to let something like this, so easily fixed, detract from that, even in this very small way.



It's easy to surmise that the bootstrap process is just an extra step that's taken when pkg(7) is first run. The "not enough arguments" error appears because as soon as the bootstrapped binary is installed, pkg itself is actually executed. If you install a fresh system, reboot, then run `pkg install xorg`, you'll first be notified that pkg isn't installed yet and asked to bootstrap it. After that's done, pkg will move on to updating the package database and installing x11/xorg. `pkg bootstrap` is an extra, unnecessary step. The /usr/sbin/pkg mentioned in the _Handbook_ is in fact a distinct binary that is replaced by the bootstrapped binary during the initial installation process. See pkg(7) (the bootstrapper) versus pkg(8) (the actual package manager).

Spelling all this out in the _Handbook_ would certainly confuse new users more than a meaningless error message they only see one time, and you more-or-less figured it out yourself.


----------

