# using pkg_add with sudo giving error



## gps23 (Jul 18, 2010)

hi,

when i try to install a package using *sudo pkg_add -r*, i get the following error:

```
$ sudo pkg_add -v -r xchat
scheme:   [ftp]
user:     []
password: []
host:     [ftp.freebsd.org]
port:     [0]
document: [/pub/FreeBSD/ports/amd64/packages-8.0-release/Latest/xchat.tbz]
---> ftp.freebsd.org:21
looking up ftp.freebsd.org
connecting to ftp.freebsd.org:21
<<< 220 Welcome to freebsd.isc.org.
>>> USER anonymous
<<< 331 Please specify the password.
>>> PASS me@freebsd
<<< 230 Login successful.
>>> PWD
<<< 257 "/"
>>> CWD pub/FreeBSD/ports/amd64/packages-8.0-release/Latest
<<< 250 Directory successfully changed.
>>> MODE S
<<< 200 Mode set to S.
>>> TYPE I
<<< 200 Switching to Binary mode.
binding data socket
>>> PORT 10,0,0,2,232,216
<<< 500 Illegal PORT command.
Error: Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.0-release/Latest/xchat.tbz: Syntax error, command unrecognized
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.0-release/Latest/xchat.tbz' by URL
pkg_add: 1 package addition(s) failed
```

However, package installation works fine when I log out and then log in as root.
Please help.


----------



## gps23 (Jul 18, 2010)

*[Solved]  using pkg_add with sudo giving error*

Hi,

I uncommented the following line using visudo, and pkg_add started working.

```
Defaults        env_keep += "PKG_PATH PKG_DBDIR PKG_TMPDIR TMPDIR PACKAGEROOT PA
CKAGESITE PKGDIR FTP_PASSIVE_MODE"
```

Thanks Aprogas


----------

