# Specifying the Working Directory



## balanga (Aug 6, 2018)

I have read The Handbook about Specifying the Working Directory, but am none the wiser. I have /usr/ports on the LAN, but I want the working directory somewhere local, possibly /tmp, but I can't figure out how to specify this. It looks like $WORKSRC is the thing I need to setup, but how?


----------



## ShelLuser (Aug 6, 2018)

Assuming this can be specified then it should go where everything else gets specified for building Ports: /etc/make.conf.


----------



## balanga (Aug 6, 2018)

After further searching, I came across https://www.freebsd.org/doc/handbook/ports-using.html

where an example is provided:-

```
# make WRKDIRPREFIX=/usr/home/example/ports install
```


----------



## SirDice (Aug 6, 2018)

See ports(7):

```
WRKDIRPREFIX      Where to create any temporary files.  Useful if
                       PORTSDIR is read-only (perhaps mounted from a CD-ROM).
```


----------



## balanga (Aug 6, 2018)

/usr/ports/misc/heyu2/ is mounted on a remote host and I am trying to run

```
cd /usr/ports/misc/heyu2
make WRKDIRPREFIX=/tmp/heyu install
```
but it seems that the build requires the building of ports-mgmt/dialog4ports and this happens:-

```
root@tester:~ # mount
/dev/gpt/S03p2 on / (ufs, local, soft-updates)
....
192.168.1.2:/mnt/nas/Web-Server/usr/ports on /usr/ports (nfs, noatime, nfsv4acls)
.....
root@tester:~ # sh /mnt/projects/heyu/build
===> Building/installing dialog4ports as it is required for the config dialog
===>  Cleaning for dialog4ports-0.1.6
===>  License BSD2CLAUSE accepted by the user
===>   dialog4ports-0.1.6 depends on file: /usr/local/sbin/pkg - not found
===>  License BSD2CLAUSE accepted by the user
mkdir: /usr/ports/distfiles: Permission denied
*** Error code 1

Stop.
```

What am I doing wrong?


----------



## SirDice (Aug 6, 2018)

Your /usr/ports is essentially read-only, so downloaded distfiles cannot be saved to /usr/ports/distfiles. So you either make sure the distfiles are already there or you set DISTDIR to a writable directory. See ports(7):

```
DISTDIR           Where to find/put distfiles, normally distfiles/ in
                       PORTSDIR.
```


----------



## balanga (Aug 6, 2018)

Am I right in thinking these variables can be set globally in /etc/make.conf?

Would /var/tmp/ be a reasonable location to use?


----------



## Phishfry (Aug 6, 2018)

Why not a shell environment variable.
`set WRKDIRPREFIX=/tmp/heyu`
Then anytime it encounters $WRKDIRPREFIX is goes to the variable provided.

I have done this with cross compiling base but not with any ports. A variable is a variable right? Many ways to skin a sheep.
set WRKSRC= Any source tree you want to use


----------



## SirDice (Aug 7, 2018)

balanga said:


> Am I right in thinking these variables can be set globally in /etc/make.conf?


Yes, that works.


----------

