# pkg: Command not found.



## WHAO (Jun 16, 2017)

Please help me !!
FreeBSD 10.2-RELEASE-p1 

I used the command by mistake
# pkg delete pkg

I know, I an idiot  

Please how fix pkg command 
pkg: Command not found.


----------



## WHAO (Jun 17, 2017)

getopt said:


> Try `pkg-static bootstrap -f` to force a re-installation of pkg. See pkg(7)
> 
> If the fetched version of Pkg does not work you might need to upgrade your system to a supported version of FreeBSD.



Thank, but not work
pkg-static: Command not found.

I try update with freebsd-update but command not found

Also try install with makefile 

```
# make -C /usr/ports/ports-mgmt/pkg install clean
```
But get error: make: Command not found.

And try with autogen.sh of github 

```
# git clone https://github.com/freebsd/pkg
# cd pkg
#./autogen.sh
# ./configure
# make
# make install
```

But get this error:


```
pkg# ./autogen.sh
configure.ac:31: installing './compile'
configure.ac:76: installing './config.guess'
configure.ac:76: installing './config.sub'
configure.ac:12: installing './install-sh'
configure.ac:12: installing './missing'
parallel-tests: installing './test-driver'
compat/Makefile.am:1: error: Libtool library used but 'LIBTOOL' is undefined
compat/Makefile.am:1:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
compat/Makefile.am:1:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
compat/Makefile.am:1:   If 'LT_INIT' is in 'configure.ac', make sure
compat/Makefile.am:1:   its definition is in aclocal's search path.
compat/Makefile.am: installing './depcomp'
external/Makefile.am:81: error: Libtool library used but 'LIBTOOL' is undefined
external/Makefile.am:81:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
external/Makefile.am:81:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
external/Makefile.am:81:   If 'LT_INIT' is in 'configure.ac', make sure
external/Makefile.am:81:   its definition is in aclocal's search path.
external/blake2/Makefile.am:4: error: Libtool library used but 'LIBTOOL' is undefined
external/blake2/Makefile.am:4:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
external/blake2/Makefile.am:4:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
external/blake2/Makefile.am:4:   If 'LT_INIT' is in 'configure.ac', make sure
external/blake2/Makefile.am:4:   its definition is in aclocal's search path.
libpkg/Makefile.am:116: error: Libtool library used but 'LIBTOOL' is undefined
libpkg/Makefile.am:116:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
libpkg/Makefile.am:116:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
libpkg/Makefile.am:116:   If 'LT_INIT' is in 'configure.ac', make sure
libpkg/Makefile.am:116:   its definition is in aclocal's search path.
libpkg/repo/binary/Makefile.am:24: error: Libtool library used but 'LIBTOOL' is undefined
libpkg/repo/binary/Makefile.am:24:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
libpkg/repo/binary/Makefile.am:24:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
libpkg/repo/binary/Makefile.am:24:   If 'LT_INIT' is in 'configure.ac', make sure
libpkg/repo/binary/Makefile.am:24:   its definition is in aclocal's search path.
autoreconf-2.69: automake failed with exit status: 1
```


I don't know that to do


----------



## ShelLuser (Jun 17, 2017)

WHAO said:


> Please help me !!
> FreeBSD 10.2-RELEASE-p1
> 
> I used the command by mistake
> # pkg delete pkg


Did you by any chance build your own system? Because removing ports-mgmt/pkg does not render your system completely useless. You see...  ports-mgmt/pkg installs its contents to /usr/local but how would it be able to register itself without a package manager? 

Look into /usr/sbin/pkg, that file is there by default and is also not affected by the package system. Simply because it's a part of the base system. This is the so called pkg bootstrap. When you execute it it'll detect the lack of pkg and asks if you want to download a version. That will install pkg on your system again.

Another possible solution is to go to /usr/ports/ports-mgmt/pkg, run `# make build` after which you should be left with a working pkg version somewhere in the working directory. Try running that, and when it works you can then use `# ./pkg install pkg` which would fix your problems.

(edit): I just thought of something else 

You can _also_ use the source tree if you have that installed (/usr/src). If you do then you could go to /usr/src/usr.sbin/pkg and run `# make`. That would eventually leave you with the pkg bootstrapper which I mentioned earlier.

So yeah, plenty of ways to fix this.


----------



## Beastie (Jun 17, 2017)

It's probably the entire /usr/sbin directory. That's where both pkg(8) and freebsd-update(8) are. If confirmed, you can extract them back from the base distribution found on your CD/DVD/memstick (or online). But this may cause inconsistencies: if *-p1* affects something there, it will be reset to its original *RELEASE* state, obviously.


----------



## gkontos (Jun 17, 2017)

Time to upgrade to FreeBSD 10.3-RELEASE


----------



## SirDice (Jun 19, 2017)

WHAO said:


> FreeBSD 10.2-RELEASE-p1


FreeBSD 10.2 has been End-of-Life since December 2016, please upgrade to a supported version.

Topics about unsupported FreeBSD versions
https://www.freebsd.org/security/unsupported.html


----------

