Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dealing with duplicate entries in stata.trk

    I recently ran into some problems with duplicate entries in my stata.trk file. This file is located at the base of an ado tree (like PLUS) and is used to track what user written programs have been installed. To see if you have duplicate entries you can use -ado dir pkgname-. If an entry appears twice you can not remove the pacakge normally.

    . ado uninstall pkgname
    criterion matches more than one package
    r(111);


    You can get these duplicate entries if you install packages using:
    • -ssc install pkgname, replace- and the package has been updated since you installed. FYI, you should use -adoupdate pkgname, update-
    • -net install pkgname, force-
    If the duplicate entries list that the package was installed from the same source, this can be fixed easily by running -adoupdate-, which will say (note: package pkgname was installed more than once; older copy removed).

    If they are from different sources then you will manually have to remove the earlier ones from stata.trk file (there may also be orphaned files to want to deal with). I've run into this when developing a package and I want to switch from using the 'stable' package (e.g. on SSC) to the 'development' package (e.g. local files or GitHub). The moral of the story seems to be if you are going to install a package from a new source make sure that you uninstall it first.

    Anyone found easier ways of dealing with things like this?

  • #2
    I can confirm that this is a problem and can be easily replicated as illustrated here:

    Code:
    . * Install leftalign package from SSC
    . ssc install leftalign
    checking leftalign consistency and verifying not already installed...
    installing into /Users/robert/Library/Application Support/Stata/ado/plus/...
    installation complete.
    
    . 
    . * Install an update from a different site
    . net from "http://robertpicard.com/updates"
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    http://robertpicard.com/updates/
    Package(s) available on this site:
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    
    PACKAGES you could -net describe-:
        leftalign         module to left-align (or right-align) variables
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    
    . net install leftalign.pkg, replace
    checking leftalign consistency and verifying not already installed...
    
    the following files will be replaced:
        /Users/robert/Library/Application Support/Stata/ado/plus/l/leftalign.ado
        /Users/robert/Library/Application Support/Stata/ado/plus/r/rightalign.ado
    
    installing into /Users/robert/Library/Application Support/Stata/ado/plus/...
    installation complete.
    
    . 
    . * show what's happened
    . findfile stata.trk
    ~/Library/Application Support/Stata/ado/plus/stata.trk
    
    . type "`r(fn)'"
    * 00000067
    *! version 1.0.0
    * Do not erase or edit this file
    * It is used by Stata to track the ado and help
    * files you have installed.
    
    S http://fmwww.bc.edu/repec/bocode/l
    N leftalign.pkg
    D  3 Feb 2015
    U 66
    d 'LEFTALIGN': module to left-align (or right-align) variables
    d 
    d   -leftalign- changes the variable's format so that values are
    d aligned to the left. -rightalign- changes variables to a
    d right-aligned format. Only the variable's format is changed, the
    d values are not affected.
    d 
    d KW: data management
    d KW: align
    d KW: justify
    d KW: format
    d 
    d Requires: Stata version 9.2
    d 
    d Distribution-Date: 20140921
    d 
    d Author: Robert Picard
    d Support: email picard@@netbox.com
    d 
    f l/leftalign.ado
    f l/leftalign.hlp
    f r/rightalign.ado
    f r/rightalign.hlp
    e
    S http://robertpicard.com/updates
    N leftalign.pkg
    D  3 Feb 2015
    U 67
    d 'leftalign': module to left-align (or right-align) variables
    d 
    d -leftalign- changes the variable's format so that values
    d are aligned to the left. -rightalign- changes variables
    d to a right-aligned format. Only the variable's format is
    d changed, the values are not affected.
    d 
    d KW: align
    d KW: justify
    d KW: format
    d 
    d Requires: Stata version 9.2
    d 
    d Author: Robert Picard
    d Support: email [email protected]
    d 
    d Distribution-Date: 20150203
    f l/leftalign.ado
    f l/leftalign.hlp
    f r/rightalign.ado
    f r/rightalign.hlp
    e
    
    . 
    . * try to uninstall
    . ado uninstall leftalign
    criterion matches more than one package
    r(111);
    At this point, the only solution I can think to fix the problem is to either erase the content of the PLUS directory and rebuild it or edit "state.trk" and fix the problem manually. I can't think of a reason why you can have more than one package with the same name in "state.trk" so I would tend to consider this a bug.

    Note that you can install packages in more than one location and each location will have it's own "state.trk". You can then use the ado path to choose which package will have priority:

    Code:
    . * Reset ado path, show there's nothing installed in PLUS
    . global S_ADO BASE;SITE;.;PERSONAL;PLUS;OLDPLACE
    
    . net set ado PLUS
    
    . ado
    
    . 
    . * Install leftalign package from SSC
    . ssc install leftalign
    checking leftalign consistency and verifying not already installed...
    installing into /Users/robert/Library/Application Support/Stata/ado/plus/...
    installation complete.
    
    . 
    . * Install an update from a different site into a custom ado directory
    . net from "http://robertpicard.com/updates"
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    http://robertpicard.com/updates/
    Package(s) available on this site:
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    
    PACKAGES you could -net describe-:
        leftalign         module to left-align (or right-align) variables
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    
    . net set ado "`c(pwd)'/ado"
    
    . net install leftalign.pkg, replace
    checking leftalign consistency and verifying not already installed...
    installing into /Users/robert/Documents/statalist/2015/20150203/ado/...
    installation complete.
    
    . 
    . * give the version in the custom directory precedence
    . adopath ++ "`c(pwd)'/ado"
      [1]              "/Users/robert/Documents/statalist/2015/20150203/ado"
      [2]  (BASE)      "/Applications/Stata/ado/base/"
      [3]  (SITE)      "/Applications/Stata/ado/site/"
      [4]              "."
      [5]  (PERSONAL)  "~/Library/Application Support/Stata/ado/personal/"
      [6]  (PLUS)      "~/Library/Application Support/Stata/ado/plus/"
      [7]  (OLDPLACE)  "~/ado/"
    
    . ado
    
    [1] package leftalign from http://fmwww.bc.edu/repec/bocode/l
          'LEFTALIGN': module to left-align (or right-align) variables
    
    . which leftalign
    /Users/robert/Documents/statalist/2015/20150203/ado/l/leftalign.ado
    *! version 2.0.4, 03feb2015, Robert Picard, [email protected]      
    
    . 
    . * uninstall version in PLUS and in custom ado
    . ado uninstall leftalign
    
    package leftalign from http://fmwww.bc.edu/repec/bocode/l
          'LEFTALIGN': module to left-align (or right-align) variables
    
    (package uninstalled)
    
    . ado uninstall leftalign, from("`c(pwd)'/ado")
    
    package leftalign from http://robertpicard.com/updates
          'leftalign': module to left-align (or right-align) variables
    
    (package uninstalled)

    Comment


    • #3
      It looks like this was fixed in Stata v14. I see messages from -adoupdate- like "(note: package XXX was installed more than once; older copy removed)".

      Comment


      • #4
        I had the same problem with STAT v14. However you can solve it using " ado uninstall [#]":
        Code:
        . ado dir spost13_ado
        
        [147] package spost13_ado from http://www.indiana.edu/~jslsoc/stata
              Distribution-date: 10Feb2015
        
        [215] package spost13_ado from https://jslsoc.sitehost.iu.edu/stata
              Distribution-date: 05Apr2019
        . ado uninstall [147]
        
        package spost13_ado from http://www.indiana.edu/~jslsoc/stata
              Distribution-date: 10Feb2015
        
        (package uninstalled)
        
        . ado dir spost13_ado
        
        [214] package spost13_ado from https://jslsoc.sitehost.iu.edu/stata
              Distribution-date: 05Apr2019

        Comment

        Working...
        X