# Ports metadata is corrupt



## Daniel Santos (Apr 16, 2015)

Hello all,

I just started at my new job and one of my tasks is to maintain and upgrade several FreeBSD servers acting as routers and firewalls. One of the first things I am trying to do is to install the tools the I am used to use through the ports method. The thing is when I try to run `portsnap fetch update` on the servers that are running 9.0-RELEASE I got the following messages:

```
Looking up portsnap.FreeBSD.org mirrors... none found.
Fetching snapshot tag from portsnap.FreeBSD.org... done.
Fetching snapshot metadata... done.
Updating from Fri Feb 10 09:04:57 BRST 2012 to Thu Apr 16 09:32:58 BRT 2015.
Fetching 4 metadata patches. done.
Applying metadata patches... done.
Fetching 5 metadata files... /usr/sbin/portsnap: cannot open a60d47c75bde6fef02b249cf27cd202c924febf4d0d444cd9dcf67191fa60596.gz: No such file or directory
metadata is corrupt.
```

Can anyone give me any directions for solving this?

Thanks in advance,


----------



## SirDice (Apr 16, 2015)

This should remove the cached data: `rm -rf /var/db/portsnap/files/*`. You can also remove the whole lot: `rm -rf /var/db/portsnap/*`.

Keep in mind that 9.0-RELEASE is end-of-life since March 2013, I strongly advise you to update to 9.3-RELEASE.


----------



## Daniel Santos (Apr 16, 2015)

SirDice,

moving /var/db/portsnap/files/ to /var/db/portsnap/files.old/ did not do the trick, I still get the following error running `portsnap fetch update`:


```
Looking up portsnap.FreeBSD.org mirrors... none found.
Fetching snapshot tag from portsnap.FreeBSD.org... done.
Fetching snapshot metadata... done.
Updating from Fri Feb 10 09:04:57 BRST 2012 to Thu Apr 16 10:08:40 BRT 2015.
Fetching 0 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files...




/usr/sbin/portsnap: cannot open 0eb3dc5b7fd905895ab61a6c9c6ca3af478a6eef1ed6a684b08746055f3155e7.gz: No such file or directory
```

Question: If I move or remove the whole /var/db/portsnap/ would I still be able to get information about installed ports and stuff like that? I am not aware of the purpose of the /var/db/portsnap/ files individual purpose, but don't they have a role at ports management?

Thanks in advance,


----------



## SirDice (Apr 16, 2015)

Daniel Santos said:


> Question: If I move or remove the whole /var/db/portsnap/ would I still be able to get information about installed ports and stuff like that? I am not aware of the purpose of the /var/db/portsnap/ files individual purpose, but don't they have a role at ports management?


The directory is only used by portsnap(8), so it's safe to remove. Your installed packages are stored in /var/db/pkg/local.sqlite.


----------



## Daniel Santos (Apr 16, 2015)

SirDice ,

Should I run `portsnap fetch extract` or `portsnap fetch update` after removing /var/db/portsnap/ content?


----------



## Daniel Santos (Apr 16, 2015)

The error persists even after removing the /var/db/portsnap/ content.


----------



## Georg Andreev (Jan 4, 2016)

Hello all,

I have exactly same problem in last few days.

```
root@doublehead:~ # portsnap fetch
Looking up portsnap.FreeBSD.org mirrors... 7 mirrors found.
Fetching public key from ec2-eu-west-1.portsnap.freebsd.org... done.
Fetching snapshot tag from ec2-eu-west-1.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Fetching snapshot generated at Mon Jan  4 10:03:03 YAKT 2016:
0bfaab36a00cf97896da3306248d20dfdd0e00e643a518100% of   70 MB  110 kBps 10m51s
Extracting snapshot... done.
Verifying snapshot integrity... done.
Fetching snapshot tag from ec2-eu-west-1.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Updating from Mon Jan  4 10:03:03 YAKT 2016 to Tue Jan  5 01:22:13 YAKT 2016.
Fetching 4 metadata patches. done.
Applying metadata patches... done.
Fetching 4 metadata files... /usr/sbin/portsnap: cannot open d11d67961a6e9fabe3020e91725c28797cb83fe295b863242f16e64e46cf39c5.gz: No such file or directory
metadata is corrupt.

root@doublehead:~ # uname -a
FreeBSD doublehead.xxxxxx.ru 9.3-RELEASE FreeBSD 9.3-RELEASE #0: Sun Nov 29 18:38:56 YAKT 2015     [email]root@doublehead.xxxxxx.ru[/email]:/usr/obj/usr/src/sys/dbl93  i386
```
I'm also tried to remove whole /var/db/portsnap directory, and try `portsnap fetch` several times in few days.

What should I do?


----------



## Jahzoone (Sep 29, 2016)

I have been having a similar issue when running `portsnap fetch update`. I read a lot of the posts here and on other web sites and had been searching for the answer to fix this problem. After reading many posts, I decided to look at the directory permissions for /usr/sbin/. I found that only ROOT had read / write access, so I gave GROUP read / write permission and re-ran `portsnap fetch update` and the ports tree updated and built the new index files just as it always used to do. I don't know if this is the proper fix, but it worked for me. Maybe it will work for you as well?


----------



## SirDice (Sep 29, 2016)

> I decided to look at the directory permissions for /usr/sbin/. I found that only ROOT had read / write access


Yes, it's supposed to be like that.



> so I gave GROUP read / write permission


Bad idea.



> I don't know if this is the proper fix, but it worked for me.


It's not a proper fix, it not a fix at all actually. I don't know why it worked for you, there's probably something else wrong with your system.


----------



## pboehmer (Sep 29, 2016)

I found that just running `portsnap fetch update` after the first failure works without removing the previous files.  

I had be doing a `portsnap fetch update` and when I encounter the corruption error, running `portsnap fetch extract` as a fix.  Yesterday, I had accidentally ran the update instead of extract and it worked just as well.


----------

