1

I was building packages in MacPorts on a Mac Mini when the power went out. Now anything I try to do in MacPorts (install, clean, selfupdate) results in the following error:

sqlite error: disk I/O error (3850) while executing query: ATTACH DATABASE '/opt/local/var/macports/registry/registry.db' AS registry
    while executing
"registry::open $db_path"
    (procedure "mportinit" line 610)
    invoked from within
"mportinit ui_options global_options global_variations"
Error: /opt/local/bin/port: Failed to initialize MacPorts, sqlite error: disk I/O error (3850) while executing query: ATTACH DATABASE '/opt/local/var/macports/registry/registry.db' AS registry

How can I fix this?

  • I would restore from backup as a fie is corrupt and that file depends on the pros you have installed and can't be reproduced from a new install – user151019 Aug 20 '15 at 18:16
  • @Mark I don't have any backups for this particular machine. Any other ideas? – Brian McCutchon Aug 20 '15 at 18:18
  • The way to reinstall macports is to have a list of the ports you installed and then redo - to get the list of pros you need that db. So no - just take this as a learning moment and realise you need backups. You can reinstall macports from scratch if you know which ones you need – user151019 Aug 20 '15 at 19:31
  • @Mark Both port list installed and port -qv installed result in the same error. Is there a way to get a list of installed ports outside of macports? – Brian McCutchon Aug 20 '15 at 19:52
  • No as that list is held in the database that is corrupted. – user151019 Aug 20 '15 at 19:54
0

The fix for this is actually quite simple, and is mentioned in this MacPorts issue. From a comment on the issue by "pixilla@…":

$ cd /opt/local/var/macports/registry
$ ls registry.db-journal                                                                                                                                                                             
$ sudo sqlite3 registry.db
sqlite> .tables
sqlite> SELECT id FROM ports;
sqlite> .quit

Based on another comment by "ecronin@…", I conclude that, had I run any port command as root, it would have been fixed automatically and saved me all this trouble. But I always forget to use sudo...

EDIT Wait, I did run a port command with sudo. Weird. Oh, well, at least it works now.

  • Same thing happened to me. Power out during an install. I get a straight sqlite error, but there is no journal file. sqlite error: database disk image is malformed (11). – Andrew Backer May 15 at 9:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .