Opened 3 years ago

Closed 3 years ago

#62606 closed defect (invalid)

Strange "ports diag" complaint wrt ghc-8.10.4

Reported by: GussyFinkNottle Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.6.4
Keywords: Cc: ryandesign (Ryan Carsten Schmidt)
Port: ghc

Description

port diag returns:

Warning: couldn't find file '/opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi' for port 'ghc'. Please deactivate and reactivate the port to fix this issue.

ls -l /opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi returns:

-rw-r--r-- 1 macports wheel 17025 Feb 12 15:16 /opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi

ghc itself seems to work fine. It may be relevant that I rarely use macport's ghc, relying instead on "ghcup", which maintains several versions of ghc. (So for me, this bug/glitch, whether it is in "port" or "ghc", is of supreme unimportance :)

sudo port deactivate ghc returns:

--->  Deactivating ghc @8.10.4_0
Error: Failed to deactivate ghc: this entry does not own the given file
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_registry_portfiles_ghc-8.10.4_0_1568b9927a7c1a4ff0e0b430009d6fdd4910ba2659f74f6857ed213608cd0c7c-10941/ghc/main.log for details.
Warning: Failed to execute portfile from registry for ghc @8.10.4_0
--->  Deactivating ghc @8.10.4_0
Error: port deactivate failed: this entry does not own the given file

(The log will be attached.)

Attachments (1)

main.log (8.3 KB) - added by GussyFinkNottle 3 years ago.
log generated by "port diag".

Download all attachments as: .zip

Change History (10)

Changed 3 years ago by GussyFinkNottle

Attachment: main.log added

log generated by "port diag".

comment:1 Changed 3 years ago by GussyFinkNottle

Incidentally, I'd be grateful to be told how to browse in the finder to /opt. I had to copy the logfile to ~/Desktop to attach it.

comment:2 in reply to:  1 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to GussyFinkNottle:

port diag returns:

Warning: couldn't find file '/opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi' for port 'ghc'. Please deactivate and reactivate the port to fix this issue.

ls -l /opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi returns:

-rw-r--r-- 1 macports wheel 17025 Feb 12 15:16 /opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi

ghc itself seems to work fine. It may be relevant that I rarely use macport's ghc, relying instead on "ghcup", which maintains several versions of ghc. (So for me, this bug/glitch, whether it is in "port" or "ghc", is of supreme unimportance :)

sudo port deactivate ghc returns:

--->  Deactivating ghc @8.10.4_0
Error: Failed to deactivate ghc: this entry does not own the given file
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_registry_portfiles_ghc-8.10.4_0_1568b9927a7c1a4ff0e0b430009d6fdd4910ba2659f74f6857ed213608cd0c7c-10941/ghc/main.log for details.
Warning: Failed to execute portfile from registry for ghc @8.10.4_0
--->  Deactivating ghc @8.10.4_0
Error: port deactivate failed: this entry does not own the given file

(The log will be attached.)

The name of the folder should be time-1.9.3 but the path recorded in the registry for this file on your system appears to contain the folder name time-1*9.3 instead. This looks like a single-bit error that could be the result of bad RAM, cosmic rays, or other random phenomena. ("." is 101110 in binary; "*" is 101010 in binary.) If you uninstall the port that will remove its references from your registry. You can then reinstall the port which will put new references into the registry, which hopefully won't be affected by the same phenomenon.

Replying to GussyFinkNottle:

Incidentally, I'd be grateful to be told how to browse in the finder to /opt. I had to copy the logfile to ~/Desktop to attach it.

In the Finder, select Go to Folder from the Go menu or press Command-Shift-G. Type the path you want to go to.

Or, in the Terminal, type open followed by the path you want the Finder to open.

When I want to attach a log, I usually find it easiest to press the Choose File button on the web page, and then in the file selection dialog box, either type "/" or press Command-Shift-G, either of which bring up a dialog where you can type the path you want to go to. Tab completion also works in this dialog. I usually copy the port's logfile location to the pasteboard by running e.g. port logfile ghc | pbcopy in the Terminal, then it's all ready to paste into the file selection dialog's path entry subdialog.

comment:3 Changed 3 years ago by GussyFinkNottle

Thank you about the finder! I live and learn. User-friendly software like finder can be deeply baffling.

Sadly, when uninstalling ghc, the first thing done seems to be to deactivate it. sudo port uninstall ghc fails, with essentially the logfile I attached above. I'm not terribly bothered. I've got ghc from elsewhere, and if a subsequent ghc version turns up in macports, perhaps that will deactivate what I currently have. I also tried sudo port --force upgrade ghc, which rebuilt/reinstalled many ports, and then failed on ghc in the same way.

For several decades, I've been longing to come across a single-bit cosmic-ray induced single-bit error. But in that time, I've seen dozens of mismatches where one piece of software (tcl?) sees a string through '...' quotes, and passes it another (bash?), stripped of quotes (or vice versa). If that might be the problem, is there some file, or perhaps database entry I can edit by hand, to restore or delete such quotes? Or some file or directory I can simply delete?

Many thanks for your swift attention. There must be many things more deserving of it than my little problem.

comment:4 in reply to:  3 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to GussyFinkNottle:

Sadly, when uninstalling ghc, the first thing done seems to be to deactivate it. sudo port uninstall ghc fails, with essentially the logfile I attached above. I'm not terribly bothered. I've got ghc from elsewhere, and if a subsequent ghc version turns up in macports, perhaps that will deactivate what I currently have.

If deactivating the port fails, as I see now from your log that it does, then uninstalling or upgrading the port won't work either, since uninstalling requires deactivating first and upgrading requires uninstalling first.

I also tried sudo port --force upgrade ghc, which rebuilt/reinstalled many ports, and then failed on ghc in the same way.

The reason why many ports were rebuilt is that --force applies to the specified port and all dependencies. If you want to rebuild one port without rebuilding its dependencies, which is usually what you want if rebuilding is needed, then add the -n flag: sudo port -n upgrade --force ....

For several decades, I've been longing to come across a single-bit cosmic-ray induced single-bit error.

We've encountered several single-bit errors in user bug reports over the years, and I've even seen one or two on our Power Macintosh G5 build machine, back when that was running. I haven't seen any single-bit errors on our Xserve build machines; they use error-correcting ECC memory which corrects for this kind of problem.

But in that time, I've seen dozens of mismatches where one piece of software (tcl?) sees a string through '...' quotes, and passes it another (bash?), stripped of quotes (or vice versa). If that might be the problem, is there some file, or perhaps database entry I can edit by hand, to restore or delete such quotes? Or some file or directory I can simply delete?

I still believe this is a single-bit error in the data that was recorded in your registry. Since it looks like this will prevent you from uninstalling or upgrading the port, it will have to be fixed by correcting the error in the registry. I believe this command would do it:

sudo sqlite3 /opt/local/var/macports/registry/registry.db 'update files set path="/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi" where path="/opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi";' 'select changes();'

It should print the number of changes made, which should be 1. If you run it a second time, it should print 0. You should then be able to deactivate, uninstall, or upgrade ghc, unless of course there are other similar errors, which we can fix the same way.

Our registry database uses a custom collation and usually you need to load our custom sqlite extension to use it. I didn't seem to need to do this to run the above command on my system, but if you get an error like Error: no such collation sequence: VERSION let me know and I'll explain how to work around that.

comment:5 Changed 3 years ago by GussyFinkNottle

I now believe you about the single-bit error.

The command you suggested currently returns "0". Macports still refuses to deactivate (a fortiori uninstall) ghc. Last night I made some very ill-advised changes to registry.db via SQL, and suspect I may now have to reinstall macports from scratch. However it seems to work fine, except where ghc is concerned. I can still list my requested and installed ports, upgrade outdated ports, etc.

Before my ill-advised changes, I used sqlite3's .dump command to make a text file "tmp2", in which grep Week.p_hi returns:

INSERT INTO files VALUES(1257,'/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi','/opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi',1,0);

After my ill-advised changes, I used produced a text file "tmp3", which differs from tmp2 as follows:

> INSERT INTO files VALUES(1257,'/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi','/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi',1,0);

grep Week.p_hi tmp2 tmp3 returns:

tmp2:INSERT INTO files VALUES(1257,'/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi','/opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi',1,0);
tmp3:INSERT INTO files VALUES(1257,'/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi','/opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi',1,0);
tmp3:INSERT INTO files VALUES(1257,'/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi','/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi',1,0);

(I was trying to insert the correct row into the files table. Needless to say, I've little experience with SQL.)

When things didn't work out, I ran: sudo sqlite3 /opt/local/var/macports/registry/registry.db "PRAGMA integrity_check" This produced (as hinted at from your remark about "custom collation"):

Error: no such collation sequence: VERSION

Now I wonder:

  1. reinstate a previous state of registry.db from a time-machine backup, cross my fingers, and try to upgrade what then seems to be outdated.
  2. follow the instructions to reinstall macports from scratch. Worryingly, the first step seems to be to uninstall all ports. The odds are that ghc will be hard to uninstall.
  3. simply forget about macports ghc. Everything else seems to work, and I don't actually need it.

comment:6 Changed 3 years ago by GussyFinkNottle

I have now managed to uninstall ghc, by ".load macports.sqlext", and reindexing file_actual. (Some errors from "pragma integrity_check" (below) still remain. However, ghc could then be deactivated and uninstalled.)

The errors that remain are;

row 11786 missing from index file_path
wrong # of entries in index file_actual_nocase

(By the way, having uninstalled ghc, I cannot *re*install it. But that's another story.)

comment:7 in reply to:  6 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign added

Replying to GussyFinkNottle:

The command you suggested currently returns "0". Macports still refuses to deactivate (a fortiori uninstall) ghc. Last night I made some very ill-advised changes to registry.db via SQL, and suspect I may now have to reinstall macports from scratch. However it seems to work fine, except where ghc is concerned. I can still list my requested and installed ports, upgrade outdated ports, etc.

Before my ill-advised changes, I used sqlite3's .dump command to make a text file "tmp2", in which grep Week.p_hi returns:

INSERT INTO files VALUES(1257,'/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi','/opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi',1,0);

Ah ok. I see now that the files table records each file's path twice: the first in "path" which is where the port wants to install the file, and a second time in "actual_path" which is where MacPorts (thinks it) actually installed the file. I told you to modify the "path" when I should have told you to modify the "actual_path".

After my ill-advised changes, I used produced a text file "tmp3", which differs from tmp2 as follows:

> INSERT INTO files VALUES(1257,'/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi','/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi',1,0);

grep Week.p_hi tmp2 tmp3 returns:

tmp2:INSERT INTO files VALUES(1257,'/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi','/opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi',1,0);
tmp3:INSERT INTO files VALUES(1257,'/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi','/opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi',1,0);
tmp3:INSERT INTO files VALUES(1257,'/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi','/opt/local/lib/ghc-8.10.4/time-1.9.3/Data/Time/Calendar/Week.p_hi',1,0);

(I was trying to insert the correct row into the files table. Needless to say, I've little experience with SQL.)

Ok, so you've inserted a duplicate row for the Week.p_hi file. The fix may then be to remove the remaining erroneous row:

sudo sqlite3 /opt/local/var/macports/registry/registry.db 'delete from files where actual_path="/opt/local/lib/ghc-8.10.4/time-1*9.3/Data/Time/Calendar/Week.p_hi";' 'select changes();'

However since you have subsequently uninstalled the port, I suspect that this entry has already been deleted and that this will print 0 (for 0 rows affected).

When things didn't work out, I ran: sudo sqlite3 /opt/local/var/macports/registry/registry.db "PRAGMA integrity_check" This produced (as hinted at from your remark about "custom collation"):

Error: no such collation sequence: VERSION

Glad to hear that you found the .load macports.sqlext command to overcome this, presuming that you had installed the extension using sudo port install macports.sqlext.

Now I wonder:

  1. reinstate a previous state of registry.db from a time-machine backup, cross my fingers, and try to upgrade what then seems to be outdated.

If your backed-up registry.db matches your installed ports -- that is, you did not install, upgrade, uninstall or otherwise change any installed ports after taking the backup, and MacPorts was not doing anything at any time during the backup -- then you could restore the backup copy of the registry. But otherwise I would not attempt to do this because what's recorded in the backup registry would not match what is actually installed.

  1. follow the instructions to reinstall macports from scratch. Worryingly, the first step seems to be to uninstall all ports. The odds are that ghc will be hard to uninstall.

Yes, the first recommended step when completely uninstalling is to have MacPorts uninstall all ports. The given command will proceed (-p) past any errors encountered, such as being unable to uninstall some ports. As it says, "you can proceed on to the next steps" despite any errors, with the understanding that if the ports that could not be uninstalled put files in nonstandard places, then they will not be removed by the subsequent instructions. ghc does not put files in nonstandard locations, so this is not a concern.

Replying to GussyFinkNottle:

I have now managed to uninstall ghc, by ".load macports.sqlext", and reindexing file_actual. (Some errors from "pragma integrity_check" (below) still remain. However, ghc could then be deactivated and uninstalled.)

The errors that remain are;

row 11786 missing from index file_path
wrong # of entries in index file_actual_nocase

I am not really familiar with indexes in sqlite, but since you already found the command for recreating the table's file_actual index, and since that's not one of the indexes it's complaining about, maybe you should use the same command to recreate the table's file_path and file_actual_nocase indexes as well.

(By the way, having uninstalled ghc, I cannot *re*install it. But that's another story.)

Agreed, and filing a separate bug report about that (presuming that none of the existing bug reports cover your issue) would be clearer.

comment:8 Changed 3 years ago by GussyFinkNottle

Thanks. After reindexing also file_path and file_actual_nocase , I got:

sqlite> .load /opt/local/lib/sqlite3/macports.sqlext
sqlite>  pragma integrity_check; 
ok

Moreover port diag reports no errors. Macports seems to function normally, upgrading outdated ports, and (mostly) uninstalling and reinstalling things. If I take a text dump of registry.db, nothing untoward (like '*' characters in filenames) appears. I tentatively consider the problem I encountered to be solved.

(Although, having uninstalled ghc-bootstrap and ghc, I find they will not reinstall. I'll open a new ticket about that after some more investigation.)

comment:9 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.