Opened 3 years ago

Closed 3 years ago

#27544 closed defect (fixed)

sage-spkg-uninstall doesn't properly remove symlinks

Reported by: embray Owned by:
Priority: critical Milestone: sage-8.8
Component: build Keywords:
Cc: jhpalmieri, dimpase Merged in:
Authors: Erik Bray Reviewers: John Palmieri
Report Upstream: N/A Work issues:
Branch: 0ba3094 (Commits, GitHub, GitLab) Commit: 0ba309459d15066ce032f45d736a3d7984bf8ae4
Dependencies: Stopgaps:

Status badges


I noticed that the python2 SPKG (and probably python3 as well) install a number of .pc files in $SAGE_LOCAL/lib/pkgconfig/, some of which are symlinks:

$ cat local/var/lib/sage/installed/python2-2.7.15.p0
    "package_name": "python2",
    "package_version": "2.7.15.p0",
    "install_date": "Mon Mar 25 13:37:31 CET 2019",
    "system_uname": "Darwin 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64",
    "sage_version": "SageMath version 8.7, Release Date: 2019-03-23",
    "test_result": "",
    "files": [

In this case python2.pc is a symlink to python-2.7.pc, and python.pc a symlink to python2.pc.

When uninstalling python2, these symlinks are not removed properly, but you get warning messages:

Warning: File '/home/embray/src/sagemath/sage/local/lib/pkgconfig/python.pc' not found
Warning: File '/home/embray/src/sagemath/sage/local/lib/pkgconfig/python2.pc' not found

When rebuilding python2 (and this likely affects other packages as well) this can result in errors since the installer will refuse to copy over existing symlinks.

Change History (4)

comment:1 Changed 3 years ago by embray

  • Authors set to Erik Bray
  • Branch set to u/embray/ticket-27544
  • Cc jhpalmieri dimpase added
  • Commit set to 0ba309459d15066ce032f45d736a3d7984bf8ae4
  • Status changed from new to needs_review

I believe that fixing this issue properly will fix many problems that have arisen with symlinks not being handled properly when reinstalling packages.

New commits:

0ba3094Trac #27544: Fix uninstallation of symlinks

comment:2 follow-up: Changed 3 years ago by jhpalmieri

  • Reviewers set to John Palmieri
  • Status changed from needs_review to positive_review

This branch looks good to me. The change makes sense, not sure why it wasn't that way already. Without it, uninstalling python 2 fails, and with it, uninstalling succeeds. (In particular, make python2-clean; make python2 fails without this, succeeds with it.) On OS X, together with the repaired file manifests, I'm expecting this to fix a lot of the problems that arise when upgrading packages.

comment:3 in reply to: ↑ 2 Changed 3 years ago by embray

Replying to jhpalmieri:

The change makes sense, not sure why it wasn't that way already.

Because I didn't know os.path.exists dereferences symlinks :)

As much as I use Python I don't often use it for manipulating filesystem trees in non-trivial ways. So even after ~15 years you can still learn something new and very basic (I'm sure I've encountered this distinction before, but not enough times for it to stick).

comment:4 Changed 3 years ago by vbraun

  • Branch changed from u/embray/ticket-27544 to 0ba309459d15066ce032f45d736a3d7984bf8ae4
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.