How to fix "can't find package Pextlib 1.0" in MacPorts installation

Installing MacPorts (formerly DarwinPorts), I ran into an issue with the post-installation selfupdate command which took some digging to solve. Eventually, I tracked it down to this thread at gmane.org.

Two fixes need to be made: adding a missing line in a text file, and replacing a PPC binary with an Intel-compatible version.

First up, follow the installation instructions at the MacPorts wiki: InstallingMacPorts.

After installation is complete and the installer app is quit:

  1. Right-click on the .pkg launcher (which is as of this writing called "MacPorts-1.4.0.pkg") and select "Show Package Contents".
  2. Navigate into the "Contents" folder and double-click on the "Archive.pax.gz" file. This will result in an "Archive" folder in your Downloads folder.
  3. In the Terminal:
    cd /opt/local/share/darwinports/Tcl/pextlib1.0
  4. Open "pkgIndex.tcl" in your favorite Terminal text editor. Assuming vim:
    sudo vim pkgIndex.tcl
  5. On the first blank line (below the commented text), add this text all on the same line:
    package ifneeded Pextlib 1.0 [list load [file join Pextlib.dylib]]
  6. Save and quit the editor.
  7. Backup the incompatible binary just in case:
    mv Pextlib.dylib Pextlib.dylib.old
  8. Use the command open . to reveal this directory in a Finder window.
  9. Leaving this window open, open a second Finder window and go to the corresponding folder in the Archive you extracted in step 2. It will be at "Archive/opt/local/share/darwinports/Tcl/pextlib1.0"
  10. Copy the "Pextlib.dylib" file from the Archive into the permanent folder.

Back in the Terminal, your sudo port selfupdate command should work now. You can trash the Archive folder and Archive.paz file from your Downloads folder.

Note: see comments for another approach in step 5 that worked for at least one visitor.

And for your reference, here's the original error message I got when I first ran the selfupdate:

can't find package Pextlib 1.0  
    while executing  
"package_native require Pextlib 1.0"  
    ("eval" body line 1)  
    invoked from within  
"eval package_native $args"  
    (procedure "package" line 14)  
    invoked from within  
"package require Pextlib 1.0"  
    (procedure "dportinit" line 315)  
    invoked from within  
"dportinit ui_options global_options global_variations"  
Error: /opt/local/bin/port: Failed to initialize ports system, 
can't find package Pextlib 1.0

SEPT 2009 UPDATE: Apparently some folks are running into this same issue with new Snow Leopard installations. See the more recent comments below for more info.

Should the replaced line be

Should the replaced line be "package if needed Pextlib 1.0 [list load [file join $dir Pextlib.dylib]]" ? this is what is listed in http://thread.gmane.org/gmane.os.apple.macports.user/402/

The one listed above worked

The one listed above worked for me -- I haven't tried the one you found.

I tried the one you

I tried the one you suggested, but it didn't seem to solve the whole problem. I had to put this line to get it to work:

package ifneeded Pextlib 1.0 [list load [file join $dir Pextlib.dylib]]

Thanks for the page anyway! Helped me solve the problem.

Thanks for the additional

Thanks for the additional info -- I've updated the story to direct folks into the comments for another approach. Whatever works, eh? :)

Thanks!

Thanks for writing this! I just had to run a port selfupdate after upgrading to Snow Leopard and ended up running just what you’ve got here.

Ah

I suspect a lot of Snow Leopard people are going to be landing here today.

Landed hard..

Yep.. I just upgraded to Snow Leopard and ran in to this problem. I have no idea what is going to fix it at this time. I guess I will wait until people more experienced than me run in to this issue and use their know-how to fix it. :-)

I also had to reinstall MySql 5.x that I had installed previously. The mysql server would not start otherwise. Just FYI.

Found the fix

Ok.. I did some more searching and found the fix for those that upgraded to Snow Leopard and found that Macports does not work. If I am allowed to post a link I will do so now:

http://pjkix.com/journal/2009/08/30/os-x-10-6-snow-leopard-and-macports/

Basically the package install of Macports, even a reinstall, does not seem to fix the port update issue. Using svn to grab the source and compiling the source /does/ fix the issue.

There is a lot of good info on the supplied link.

Thanks

Thanks, that helped me to progress in my project :)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Allowed HTML tags: <a> <cite> <code> <strong> <em> <blockquote> <b> <i> <p> <br> <ul> <ol> <li> <small>
  • Lines and paragraphs break automatically.

More information about formatting options