# Make Package Bad File Descriptor



## dave (Feb 11, 2014)

The Porters Handbook says I should be able to run `# make package` as a user.  When I do this, I am getting the following error:


```
...
===>  Building package for myport-1.2.3
pkg-static: archive_write_open_filename(/usr/ports/packages/All/myport-1.2.3.txz): Bad file descriptor
*** Error code 1

Stop.
```

Presumably this is because my regular user doesn't have write permissions to write to /usr/ports/packages/All/.

Am I missing something?


----------



## ljboiler (Feb 11, 2014)

/usr/ports/packages/All is indeed where `make package` will drop the created package, but it can't do that if the user running the command doesn't have permissions to put it there...


----------



## dave (Feb 11, 2014)

ljboiler said:
			
		

> /usr/ports/packages/All is indeed where `make package` will drop the created package, but it can't do that if the user running the command doesn't have permissions to put it there...


Yes, I understand that.   The question is really why the handbook is suggesting I should be able to do that.


----------



## ljboiler (Feb 11, 2014)

The recent changes to the ports system involving the staging step where designed to allow you to be able to have the entire ports tree owned by some user other than root, where that non-root user could build ports and make packages without needing root privileges.  This wasn't possible prior to the staging addition because you had to _install_ a port (which required root privileges to write in places like /usr/local/bin and /usr/local/lib) before being able to make the package of that port.  With the staging step, a pseudo-installation is being done in a temporary working area that the user won't need special privileges to write in, and the package is created from that temporary working area, not the live system directories. 

So, what the handbook is suggesting is that is is now possible to change ownership of the entire ports tree: 
	
	



```
sudo chown -R userX:userX /usr/ports
```
and do all the port building and packaging as "userX", not root.  If you want to go all the way and `make install`, you can actually run that command as userX as well; you will be prompted for the root password when needed.


----------



## dave (Feb 11, 2014)

Thanks very much for the clarification.


----------



## SirDice (Feb 11, 2014)

Don't change permissions on /usr/ports/. If you want to test `make package` as a regular user set PACKAGES to a directory the user is allowed to write. The packages will be stored there instead of /usr/ports/packages/. The permissions on /usr/ports are likely to be restored next time you run svn or portsnap to update the tree.


----------

