Opened 6 weeks ago

Last modified 3 weeks ago

#70511 new defect

sqlite error: attempt to write a readonly database after 2.10.0 update

Reported by: wlipa (Bill Lipa) Owned by:
Priority: Normal Milestone:
Component: base Version: 2.10.0
Keywords: Cc: bal-agates, jmroot (Joshua Root)
Port:

Description

$ sudo port selfupdate
Password:
--->  Updating MacPorts base sources using rsync
MacPorts base version 2.9.3 installed,
MacPorts base version 2.10.0 downloaded.
--->  Updating the ports tree
--->  MacPorts base is outdated, installing new version 2.10.0
Installing new MacPorts release in /opt/local as root:wheel; permissions 0755


The ports tree has been updated. To upgrade your installed ports, you should run
  port upgrade outdated


$ port outdated
sqlite error: attempt to write a readonly database (8) while executing query: CREATE INDEX registry.snapshot_file_id ON snapshot_files(id)
    while executing
"registry::open $db_path"
    (procedure "mportinit" line 832)
    invoked from within
"mportinit ui_options global_options global_variations"
Error: /opt/local/bin/port: Failed to initialize MacPorts, sqlite error: attempt to write a readonly database (8) while executing query: CREATE INDEX registry.snapshot_file_id ON snapshot_files(id)

Change History (17)

comment:1 Changed 6 weeks ago by jmroot (Joshua Root)

Component: portsbase

It's attempting to update the registry database schema, but can't because it doesn't have write permissions. That theoretically should have already happened when the new version was being installed.

The workaround is easy at least: just run any port command with sudo, e.g. sudo port outdated.

comment:2 Changed 6 weeks ago by wlipa (Bill Lipa)

Thank you, yes, that does work. However this error is not something I saw on previous versions.

comment:3 Changed 6 weeks ago by ryandesign (Ryan Carsten Schmidt)

Not all new MacPorts base versions change the schema. Only those that do need write access to the database.

comment:4 Changed 6 weeks ago by jmroot (Joshua Root)

That is true, but of course this is still a bug since the schema update should happen during make install. Any time mportinit is called should trigger it, and several scripts that do that are run at the end of installation, so I'm not sure how it didn't happen.

comment:5 Changed 6 weeks ago by ryandesign (Ryan Carsten Schmidt)

Cc: bal-agates added

Has duplicate #70523.

comment:6 Changed 6 weeks ago by bal-agates

Sorry for the duplicate ticket. I did search but missed this one.

One other thing I noticed that could be related. The Change Log says:

- The number of outdated ports is printed after running
      'port selfupdate'. (#33820, thelastlin in 4ae6d98)

I did not see that. So maybe more than just the DB update is not getting executed?

comment:7 in reply to:  6 Changed 6 weeks ago by jmroot (Joshua Root)

Replying to bal-agates:

One other thing I noticed that could be related. The Change Log says:

- The number of outdated ports is printed after running
      'port selfupdate'. (#33820, thelastlin in 4ae6d98)

I did not see that. So maybe more than just the DB update is not getting executed?

It will be printed only if the number is not zero, so there's probably nothing to worry about unless you did have some outdated ports. Oh, and also the selfupdate that installed the new version was run by the old version, so it would not have this feature. You would only see it with future selfupdates.

Last edited 6 weeks ago by jmroot (Joshua Root) (previous) (diff)

comment:8 Changed 6 weeks ago by wlipa (Bill Lipa)

Is there a log for what happened during the self update? Or a verbose mode... I have some other computers to upgrade.

Last edited 6 weeks ago by wlipa (Bill Lipa) (previous) (diff)

comment:9 Changed 6 weeks ago by ryandesign (Ryan Carsten Schmidt)

selfupdate does not save a log. If you run selfupdate on the command line you can run it with the -d flag to generate debug output and you can redirect that output to a file if you want. If you use the installer package, you can choose Installer Log from the Window menu and in that window change the Detail Level from Show Errors Only to Show All Logs. You can click the Save button in that window if you want to save it to a file.

comment:10 Changed 6 weeks ago by bal-agates

When I did the selfupdate upgrading to 2.10.0 I had outdated ports but nothing on stdout indicating the count outdated. Here is the entire selfupdate output:

$ sudo port selfupdate
Password:
--->  Updating MacPorts base sources using rsync
MacPorts base version 2.9.3 installed,
MacPorts base version 2.10.0 downloaded.
--->  Updating the ports tree
--->  MacPorts base is outdated, installing new version 2.10.0
Installing new MacPorts release in /opt/local as root:wheel; permissions 0755


The ports tree has been updated. To upgrade your installed ports, you should run
  port upgrade outdated

I used "sudo port outdated" to workaround the DB schema update. This showed 356 ports that were outdated.

Now when I run "sudo port selfupdate" I do see the message counting outdated ports:

$ sudo port selfupdate
Password:
--->  Checking for newer releases of MacPorts
MacPorts base version 2.10.0 installed,
MacPorts base version 2.10.0 available.
--->  MacPorts base is already the latest version
--->  Updating the ports tree

The ports tree has been updated.

356 ports are outdated. Run 'port outdated' for details.
To upgrade your installed ports, you should run
  port upgrade outdated

So the code to report the outdated count was not run on my selfupdate from 2.9.3 to 2.10.0. Was that selfupdate output from the 2.9.3 exe? Could that also explain why the DB schema was not updated?

comment:11 in reply to:  10 Changed 6 weeks ago by jmroot (Joshua Root)

Replying to bal-agates:

So the code to report the outdated count was not run on my selfupdate from 2.9.3 to 2.10.0. Was that selfupdate output from the 2.9.3 exe?

Yes, as I said in my edit to comment:7.

Could that also explain why the DB schema was not updated?

No, or this would have happened for every previous version that changed the database schema, which is quite a lot of them.

comment:12 Changed 5 weeks ago by gctwnl

After doing a first portindex that fails like this, I did a second one with sudo. After that, the one without sudo works. And ownership of the Portindex and Portindex.quick files are still normal user me. Weird.

(I am using an alternate sources location)

Last edited 5 weeks ago by gctwnl (previous) (diff)

comment:13 Changed 5 weeks ago by jmroot (Joshua Root)

Looking at the registry of an installation that just selfupdated to 2.10.0, the version field is 1.214. It becomes 1.215 when fully updated, and it was 1.211 for MacPorts 2.9.3, which means most of the schema updates happened correctly, just not the last one. Still no idea why.

comment:14 Changed 5 weeks ago by jmroot (Joshua Root)

Cc: jmroot added

comment:15 Changed 3 weeks ago by programmingkidx

Just wanted to note I saw this problem when I ran 'sudo port selfupdate'. The installed version was 2.9.3 and the downloaded version was 2.10.1. This was on Mac OS 10.5.

comment:16 Changed 3 weeks ago by programmingkidx

Forgot to mention that the solution to this issue for me was to download the installer and run it.

comment:17 Changed 3 weeks ago by jmroot (Joshua Root)

I'm sure that worked, but there are much easier ways. See comment:1.

Note: See TracTickets for help on using tickets.