# Specify path for pkg install?



## chris.shelton (Jun 9, 2015)

Hi All,

I am running version 9.3 and I am wanting to install git.

The following command works:

`pkg install git`

But I would like to specify where to install git and not the default, is that possible?

Thanks, Chris.


----------



## SirDice (Jun 9, 2015)

Only if it's a chroot(8) environment.

From pkg(1):

```
-c	<chroot	path>
	     pkg will chroot in	the <chroot path> Environment
```


----------



## chris.shelton (Jun 9, 2015)

SirDice said:


> Only if it's a chroot(8) environment.
> 
> From pkg(1):
> 
> ...



Thanks for your help. I tried this but got the following error:

```
pkg: open(/bin/sh): No such file or directory
pkg: open(/bin/sh): No such file or directory
pkg: Unable to determine ABI
pkg: Cannot parse configuration file!
```
Any suggestions?


----------



## pkubaj (Jun 9, 2015)

Your chroot(8) directory doesn't contain /bin/sh.


----------



## tobik@ (Jun 9, 2015)

You never mentioned why you need to do this?

Instead of installing in a chroot you can specify a different root directory with `pkg -r /path/to/dir install git`.

However this might not do what you want. As far as I know the paths where Git looks for its support files are hard coded at compile time (probably overridable via environment variables but that's more trouble than it's worth IMHO).

It's probably easier to compile Git from source and passing a different prefix there (look at the INSTALL in the Git source code for instructions).


----------



## chris.shelton (Jun 9, 2015)

tobik said:


> You never mentioned why you need to do this?
> 
> Instead of installing in a chroot you can specify a different root directory with `pkg -r /path/to/dir install git`.
> 
> ...



Sorry, I am building a NAS using FreeBSD + zfs but I have installed it embedded. The problem is, when I install git without specifying a path, it gets wiped after a reboot which is understandable. I am trying to specify it to install git into a directory in my pool, so that it persists. I know that jails or a full installation would overcome this but that is not what the person wants who I am building it for.

Trying your command was a bit better but failed when trying to create /mnt/pool/pkg/git/usr/local/bin/perl5.


----------



## tobik@ (Jun 9, 2015)

If they just want to create some Git repos on their NAS devel/git-lite could work (it doesn't depend on Perl, but is missing some commands).


----------



## chris.shelton (Jun 9, 2015)

tobik said:


> If they just want to create some Git repos on their NAS devel/git-lite could work (it doesn't depend on Perl, but is missing some commands).


It's not a repo that's needed, it's just the ability to use the git commands, the repo is held elsewhere.


----------

