# pkg_add PKG_PATH bug?



## kpedersen (Sep 18, 2010)

Hello,

I was attempting to compile a largish port offline (xorg-server) when I think I ran into a bug in pkg_add.

Basically I did...


```
# make pretty-print-build-depends-list
```

To get a list of all the package I needed to install before building it.

I set my PKG_PATH variable with my two package paths (one is dvd and another one with a few extra packages)...


```
# setenv PKG_PATH "/cdrom/packages/All:/mnt/otherpackages"
```

(I tried with and without quotes)

Then I pasted the list of packages from make pretty-print... into a pkg_add command


```
# pkg_add xproto-x.x.x xtrans-x.x.x etc...
```

But it could only ever stat (find) packages in the first location in PKG_PATH (first path separated by colon ( : )

Has anyone else run into this problem?

The workaround was to obviously drive to the uni and get all packages from the ftp, but that is a waste of bandwidth... and petrol 

Thanks


----------



## DutchDaemon (Sep 18, 2010)

What says [cmd=]echo $PKG_PATH[/cmd] after you've set that variable? Maybe your shell needs 'export' instead of 'setenv'?


----------



## kpedersen (Sep 18, 2010)

As expected it outputs


```
# echo $PKG_PATH
/cdrom/packages/All:/mnt/otherpackages
```

If I swap round the variable, i.e 


```
/mnt/otherpackages:/cdrom/packages/All
```

Then suddenly packages which definitely are on the DVD cannot be found.

I am testing this as root, so it is not a problem with sudo passing through env variables.


----------



## wblock@ (Sep 18, 2010)

/usr/src/usr.sbin/pkg_install/lib/file.c, line 166, looks wrong.  -v doesn't show what paths are being searched, but a printf shows it does work:

```
# echo $PKG_PATH
/tmp:/mnt
# pkg_add -nv zoot
pkg_add -nv zoot
checking for file at /tmp/zoot.tbz
checking for file at /tmp/zoot.tgz
checking for file at /tmp/zoot.tar
checking for file at /mnt/zoot.tbz
checking for file at /mnt/zoot.tgz
checking for file at /mnt/zoot.tar
pkg_add: can't stat package file 'zoot'
pkg_add: 1 package addition(s) failed
```


----------



## kpedersen (Sep 19, 2010)

Hmm,

I can't understand what happened.

Next time I run into the problem, I will revive this thread


----------



## kpedersen (Oct 3, 2010)

Yeps,

As far as I can tell, something is definitely wrong with this.

To reproduce this problem...

```
1) Create a folder $HOME/Packages and inside it put the feh-1.5.tbz package.

2) Log in as root but do not navigate to the above users Package directory

3) As root `setenv PKG_PATH ".:/home/<user>/Packages:/cdrom/packages/All"`

4) As root `mount /cdrom` (Make sure to put in your FreeBSD 8.1 DVD)

5) As root `pkg_add feh-1.5`
```

It will complain that it cannot find libungif-4.1.4_5 but as you can see, it *IS* on the FreeBSD cdrom (in packages/All).

So I believe the bug is that pkg_add only looks for package dependencies in the same folder that the package was found in.

There is another bug (may be related)


```
1) after doing the above (with the same env as root etc...)

2) As root, `cd /home/<user>/Packages`

3) As root, `pkg_add feh-1.5.tbz`
```

You will notice that it now finds and adds libungif-4.1.4_5 but still cannot find libid3tag-0.15.1b.

If you do another [cmd=]pkg_add feh-1.5.tbz[/cmd] you will notice that now it does find and install libid3tag-0.15.1b


----------

