# pkg_add -r syntax error command unrecognized



## gore (Jun 1, 2011)

Hi,

I'm running FreeBSD 8.2-RELEASE and I was trying to install some software, and just as I always have, I did this:

`pkg_add -r links`

And it came back with an error saying 
	
	



```
Syntax error, command unrecognized
```
 and that it wouldn't install. I thought it was odd, so I went to another machine running the same version, and tried there. I got the same error, and thought it was a little weird. 

Anyone seen this? Or maybe know what happened? I haven't messed with any system files on my Laptop at all, in fact, it's a fresh installation that I haven't set up anything on yet, so I know this wasn't me screwing up a system file or something. 

Any ideas? I've got no clue how this happened. 

It's FreeBSD 8.2-RELEASE. I did the install from a CD to boot it, and then did the rest over FTP. Just to make sure I didn't somehow misstype something multiple times, I pressed the up arrow key in my shell a few times until I had one I ran earlier to install something else, and sure enough, the command I used to install multiple packages gave me errors too. I expected to see "Already installed" but instead got the same error.

My router rebooted earlier, but just to be sure, I rebooted my laptop, and it got an IP fine. I logged into the other machine over SSH, and it works fine except for that.


----------



## Deleted member 23923 (Jun 1, 2011)

I've got the same problem. The ftp site needs authentication, but about 10 hours ago everything was OK. So weird.


----------



## Deleted member 23923 (Jun 1, 2011)

Only ftp://ftp.FreeBSD.org/pub/FreeBSD/ needs authentication.
Use other ftp sites instead, or http://ftp.freebsd.org/pub/FreeBSD/


----------



## boomer3200 (Jun 1, 2011)

Hey Gore,

I had the same error message while compiling from ports this evening on a known good build.  Luckily this was on a vm test machine and not my actual hardware running FreeBSD.  Got the same result when trying *pkg_add* as well as a direct fetch in passive mode from the FreeBSD ftp server out of curiosity.  Another test site worked with fetch and I was able to download from the main FreeBSD server 2 nights ago on exactly the same virtual machine.

Usually people advise to try passive mode if you're behind a router and to avoid sudo (I use su anyway, so neither made a difference in my case).  Sorry I can't be of further help.


----------



## gore (Jun 1, 2011)

Hey,

I have FreeBSD running on three machines. It was a little strange to get this error on all three. I just tried before replying to this to see if it was still happening, and it's not.

I just ran *pkg_add -r links* and it was successful. I'm not really sure what was going on, but maybe one of the FTP servers were down for maintenance or something. Either way, it's working now, so, I guess if anyone finds out what was going on, feel free to drop in and say so. 

Otherwise I'll mark this down to weird lol.


----------



## ProServ (Jan 22, 2013)

To fix the problem of *pkg_add -r portname* which yields syntax error, command unrecognized simply run visudo(8) and comment out the line shown below:


```
Defaults        env_keep += "PKG_PATH PKG_DBDIR PKG_TMPDIR TMPDIR PACKAGEROOT PACKAGESITE PKGDIR FTP
_PASSIVE_MODE"
```


```
#exit
> sudo su
pkg_add -r portname
```


----------



## ProServ (Jan 22, 2013)

*fix error in last reply*

Sorry, 

I wrote comment out, I meant *UNCOMMENT* the line:


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


----------



## SirDice (Jan 22, 2013)

Use *sudo -i* instead of *sudo su* or use *sudo su -*.


----------

