# New to FreeBSD -- some pkg_add questions



## kdorf (Mar 3, 2010)

Hey folks, I've been reading through the FreeBSD Handbook (great documentation, by the way) but I've been having some trouble. I'm new to FreeBSD but consider myself fairly knowledgeable in Red Hat and Debian based Linux systems.

Anyway, my issues are as follows:

I get hangs when using pkg_add. For example, I have left `pkg add -vr xorg gnome2` running for about 15 minutes but it seems to be stuck trying to get a package via FTP. The last line of output is


```
>>> RETR libXTrap-1.0.0.tbz
```

It's been that way for quite a long time now. I set my PACKAGEROOT to ftp://ftp8.us.FreeBSD.org. Browsing there on my desktop, I had no problem retrieving libXTrap (using Firefox). Other packages seemed to download just fine -- it's just this one that gives me problems. Is there an easy solution here? I suppose I could download and install it manually but I have to say if I had to do this more than a few times I'd be pretty frustrated.

Another issue I've come across with pkg_add is that it seems some mirrors don't have certain packages. After I changed my PACKAGEROOT as described above there weren't any issues locating them, just the hangs as described above. Is there a way to force a timeout on retrieval of packages? Coupling this with a retry after failure would be ideal I think. Barring that, is there some way to ensure that I get a mirror that has everything (besides "choose one, hope it works, change it if it doesn't").

If these package issues are not resolvable I might just roll ports. I haven't yet had problems with them building (just takes a long time). When building from the ports tree, is there any way to say (for a given build) "don't ask me about configure options, just give me the defaults"? This would be useful for long running builds like Gnome, I think.

Lastly, if you have any particularly helpful resources for users new to FreeBSD (coming from Linux, specifically) I would certainly appreciate suggestions. I've found a few already but they seem pretty slim compared to what I expect (http://www.freebsd.org/doc/en/articles/linux-users/software.html, for instance).

Thanks in advance for the help.

John


----------



## chess (Mar 3, 2010)

I've always used PACKAGESITE, not PACKAGEROOT, and set it permanently in /root/.cshrc.  Also, I don't believe you can use ftp://ftp8.us.FreeBSD.org.  I believe you need to set a fuller path to the actual location on the FTP server for the package directory you need for your version of FreeBSD.

I recommend reading Dru Lavigne's nice little summary about PACKAGESITE here:

http://it.toolbox.com/blogs/bsd-guru/some-freebsd-pkg_add-magic-18897


----------



## kdorf (Mar 3, 2010)

Firstly, thanks to DutchDaemon for the helpful formatting edits. I'll try to reflect that formatting in my future posts. Thanks also to chess for the link. I read over it but I am still having issues.

If you were interested, the article I referenced regarding PACKAGEROOT is at http://www.cyberciti.biz/tips/freebsd-changing-pkg_add-package-ftp-site-location.html. There didn't seem to be anything wrong with doing it this way -- packages were still fetched (except for the hanging issue, which I am still having).

I followed the article you linked to, chess, cleared my PACKAGEROOT environment variable and ran [CMD=]setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.0-release/Latest/[/CMD] followed by [CMD=]pkg_add -vr xorg[/CMD]. I ran into the same issue as before (it hung on a RETR line, different package however). As far as I can tell, the process is fine up until it just randomly decides to hang up. I can see the packages being downloaded and extracted but then it is just stuck. Very frustrating.

I don't know how relevant this information is but maybe it will be of use. I am tracking 8.0-RELEASE (amd64) which I updated using freebsd-update. This installation running in Sun VirtualBox OSE (version 3.0.8_OSE r53138 as provided by Ubuntu 9.10, with any updates). The NIC connected to the VM is running in NAT mode but I would hope that this is not a problem as passive FTP is being used.

When I look at top, the pkg_add process is not using any CPU and is in the sbwait state (indicating that it is waiting on input from a socket, apparently). I can only conclude that the FTP servers are dropping the connection or something and pkg_add is freaking out about it.

Not really sure what to do here. Any further advice is again appreciated. Google seems to be no help here.


----------



## kdorf (Mar 3, 2010)

*Switching to HTTP did the trick?*

Frustrated with the fact that I couldn't get X installed, I wiped the VM. This time, I opted to download the entire 8.0-RELEASE disc (32 bit) instead of having previously installed over FTP w/ the boot only disc (64 bit).

I went through setup as before and things went fine. Right off the bat I tried `# pkg_add -vr xorg` and it didn't work (it hung as described before). However, I suspected that the problem lay in FTP and so I changed my PACKAGEROOT (*not* PACKAGESITE) to http://ftp4.freebsd.org/pub/FreeBSD/. I gave pkg_add a go again and the hang was gone. Things are installing now.

I'm not sure what the problem was. Has anyone else experienced this? Perhaps there is some sort of bug in one of the FTP routines?

In any case, I'd be happy to try and sort things out if someone wants to troubleshoot the issue (pkg_add not working per default install). Otherwise, this issue is solved for me.


----------



## Maxsu (Mar 22, 2010)

*Switching to HTTP did the trick.*

I would first like to thank kdorf for this tip. I was experiencing the same package installation problem that he described.

The solution that worked for me was:


```
# export PACKAGEROOT="http://ftp.freebsd.org"
```

I'm running in Virtualbox 3.1.4.


----------



## gilinko (Mar 22, 2010)

Maxsu said:
			
		

> I would first like to thank kdorf for this tip. I was experiencing the same package installation problem that he described.
> 
> The solution that worked for me was:
> 
> ...



In general try to stay of the main ftp, and choose either a primary mirror or a suitable country mirror. Choose from the ftp-mirror list, which also states what mirrors support http transfer.


----------



## rotiq (Jan 26, 2012)

Maxsu said:
			
		

> I would first like to thank kdorf for this tip. I was experiencing the same package installation problem that he described.
> 
> The solution that worked for me was:
> 
> ...



Had the same problem. And using "http://ftp.freebsd.org" site instead of the default ftp site fixed it. Many Thanks. I'm using FreeBSD 9.0 (64 bit) in VirtualBox 4.0.10.

I also tried ftp mirrors but with no success. Only http site seems to be working.

Razvan


----------

