1

I'm trying to reinstall MacPorts a long time after a system upgrade. Following the instructions (https://trac.macports.org/wiki/Migration) I was deleting the existing packages with

sudo port -f uninstall installed

but some packages failed to uninstall, like this one:

$ sudo port -fp uninstall htop
--->  Deactivating htop @2.0.2_0
Error: Failed to deactivate htop: this entry does not own the given file
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_registry_portfiles_htop-2.0.2_0_8c865ba69295476c0e7a128dde4e99667e096af21713a15e5017549bae60ccfb-949/htop/main.log for details.
Warning: Failed to execute portfile from registry for htop @2.0.2_0
--->  Deactivating htop @2.0.2_0
Error: Failed to uninstall htop: this entry does not own the given file
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_registry_portfiles_htop-2.0.2_0_8c865ba69295476c0e7a128dde4e99667e096af21713a15e5017549bae60ccfb-949/htop/main.log for details.
Warning: Failed to execute portfile from registry for htop @2.0.2_0
--->  Deactivating htop @2.0.2_0
Error: Failed to deactivate htop: this entry does not own the given file
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_registry_portfiles_htop-2.0.2_0_8c865ba69295476c0e7a128dde4e99667e096af21713a15e5017549bae60ccfb-949/htop/main.log for details.
Warning: Failed to execute portfile from registry for htop @2.0.2_0
--->  Deactivating htop @2.0.2_0
Error: port uninstall failed: this entry does not own the given file

The mentioned file is not that helpful either:

:msg:deactivate --->  Deactivating htop @2.0.2_0
:error:deactivate Failed to deactivate htop: this entry does not own the given file
:debug:deactivate Error code: registry::invalid
:debug:deactivate Backtrace: this entry does not own the given file
:debug:deactivate     while executing
:debug:deactivate "$port deactivate $imagefiles"
:debug:deactivate     invoked from within
:debug:deactivate "registry::write {
:debug:deactivate                 $port deactivate $imagefiles
:debug:deactivate                 foreach file $files {
:debug:deactivate                     _deactivate_file $file
:debug:deactivate       ..."
:debug:deactivate     invoked from within
:debug:deactivate "try {
:debug:deactivate         # Block the TERM and INT signals to avoid being interrupted. Note that
:debug:deactivate         # they might already be block at this point because
:debug:deactivate      ..."
:debug:deactivate     (procedure "_deactivate_contents" line 39)
:debug:deactivate     invoked from within
:debug:deactivate "_deactivate_contents $requested [$requested files] $force"
:debug:deactivate     (procedure "portimage::deactivate" line 57)
:debug:deactivate     invoked from within
:debug:deactivate "registry_deactivate $subport $version $revision $portvariants [array get user_options]"
:debug:deactivate     (procedure "portdeactivate::deactivate_main" line 10)
:debug:deactivate     invoked from within
:debug:deactivate "$procedure $targetname"

I tried to clean and deactivate the packages, but still no luck, deactivation also fails the same way. Should I try to mess with the sqlite database and delete the entries manually? It seems only to contain the bad packages:

$ sudo sqlite3 registry.db 
SQLite version 3.19.3 2017-06-27 16:48:08
Enter ".help" for usage hints.
sqlite> .tables
dependencies  files         metadata      portgroups    ports       
sqlite> select * from ports;
2753|p11-kit|3e3faa778ecfd28430bbe315280dc341c966441683d37d94a4024d7748d0b7cb-1683|/opt/local/var/macports/software/p11-kit/p11-kit-0.23.2_1.darwin_16.x86_64.tbz2|0|0.23.2|1|||installed|1481028113|image|x86_64|0|darwin|16|none|0
2760|xbitmaps|d0453d7e97c5ef303ba12583cf774f04d96bfdda76e47bf1c18a6944c273080b-805|/opt/local/var/macports/software/xbitmaps/xbitmaps-1.1.1_0.darwin_16.noarch.tbz2|0|1.1.1|0|||installed|1481028131|image|noarch|0|darwin|16|none|0
2782|xorg-util-macros|262e72a94b787a522dcb652a4c3643dc331e516f2aa715062b1c3ca00b1ba912-780|/opt/local/var/macports/software/xorg-util-macros/xorg-util-macros-1.19.0_0.darwin_16.noarch.tbz2|0|1.19.0|0|||installed|1481028739|image|noarch|0|darwin|16|none|0
2791|poppler-data|8bfccdaf843aa84f3983dab2b792a00e2ddb60b9be3e5194532f69df974fdb0e-1013|/opt/local/var/macports/software/poppler-data/poppler-data-0.4.7_0.darwin_16.noarch.tbz2|0|0.4.7|0|||installed|1481030116|image|noarch|0|darwin|16|none|0
2805|p5.24-algorithm-diff|20d724c44989c8a1b452a6ff3458ac2b307b7582d8777f39bcb0e47d6a0e9ded-1293|/opt/local/var/macports/software/p5.24-algorithm-diff/p5.24-algorithm-diff-1.190.300_0.darwin_16.noarch.tbz2|0|1.190.300|0|||installed|1481030356|image|noarch|0|darwin|16|none|0
2919|htop|8c865ba69295476c0e7a128dde4e99667e096af21713a15e5017549bae60ccfb-949|/opt/local/var/macports/software/htop/htop-2.0.2_0.darwin_16.x86_64.tbz2|1|2.0.2|0|||installed|1482232073|image|x86_64|1|darwin|16|none|0
2933|pkgconfig|41f1bec966161e029163156824d434f599d70e58638639db369f380b19057459-1991|/opt/local/var/macports/software/pkgconfig/pkgconfig-0.29.2_0.darwin_16.x86_64.tbz2|0|0.29.2|0|||installed|1490785772|image|x86_64|0|darwin|16|none|0
3035|ossp-uuid|679100994c7d2fc1932795e073581709ae3faacb61aceb88dfd99ff6422adf06-3998|/opt/local/var/macports/software/ossp-uuid/ossp-uuid-1.6.2_9+perl5_24.darwin_16.x86_64.tbz2|0|1.6.2|9|+perl5_24||installed|1494806679|image|x86_64|0|darwin|16|none|0
3047|p11-kit|f0e2db7b00d411016b8cd109d061d4436941234fdd0cf0f84d8d792804202eb5-1489|/opt/local/var/macports/software/p11-kit/p11-kit-0.23.18.1_0.darwin_17.x86_64.tbz2|0|0.23.18.1|0|||imaged|1577965184|image|x86_64|0|darwin|17|none|0
sqlite> 
2
1

If things go really wrong, don't forget that you can always ​uninstall MacPorts entirely before manually reinstalling ports.

from the migration guidelines.

Also

If the port command is not functioning, you can proceed on to the next steps, but if you had installed any ports that install files to nonstandard locations, those files might not be removed.

from https://guide.macports.org/chunked/installing.macports.uninstalling.html

Usually, when my macports installation starts going nutty (usually because I goofed it up), I delete the /opt folder and reinstall. I'm just lazy, i guess. From what it looks like though, you are trying to reinstall a new port over an old/existing folder.

https://stackoverflow.com/a/335313/10063119

So I suggest you perform uninstall.

1
  • Thanks, acknowledging failure and a complete reinstall seems to solve the problem. I'm a bit afraid that there was something else in the /opt/local directory, but after ~10 years of usage clearing that mess probably is for the better. – gipszjakab Jan 2 '20 at 14:19

You must log in to answer this question.

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