Announcement

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

  • odd problem in access to files in ado-file path (osx) (ado package maintenance)

    I want to search the stata.trk file for a package (see motivation below if interested)


    I can find the file easily enough
    . findfile stata.trk
    ~/Library/Application Support/Stata/ado/plus/stata.trk

    . di `"`r(fn)'"'
    ~/Library/Application Support/Stata/ado/plus/stata.trk

    but the filefilter command can not find the file

    . filefilter `"`r(fn)'"' temp.trk,from(moremata.pkg)
    file ~/Library/Application Support/Stata/ado/plus/stata.trk not found
    r(601);
    However the "type" command has no trouble
    . type `"`r(fn)'"',lines(5)
    * 00000139
    *! 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.
    Other commands do have the same problem
    . findfile stata.trk
    ~/Library/Application Support/Stata/ado/plus/stata.trk

    . ls `"`r(fn)'"'

    ls: ~/Library/Application Support/Stata/ado/plus/stata.trk: No such file or directory

    Am I missing some subtlety of stata or the shell behavior?


    There is a work around, if I copy the file to my default directory. (which shows further that "copy" works while "ls" does not)
    . findfile stata.trk
    ~/Library/Application Support/Stata/ado/plus/stata.trk

    . copy `"`r(fn)'"' test.trk

    . filefilter test.trk temp.trk,from(moremata.pkg)

    . return list

    scalars:
    r(occurrences) = 1
    r(bytes_from) = 12
    r(bytes_to) = 0
    Which gives me what I want - the number of occurrences of moremata.pkg in my ado tracking file. I can certainly use this work-around, but the behavior in access to files seems erratic and likely to trip one up in programming, unless someone can explain the rule that I am missing.

    (motivation: I want to automate installation of necessary packages for users of a do file.
    while the command "which" can find if ado files are installed, as far as I can tell you can not find if a package is installed without searching for one of the component ado files.
    In my program I'd rather just supply a list of packages and then "ssc install <package>" if missing, rather than have to keep track of two lists: one of component ado files to check if installed and then a second of packages to install if the corresponding component ado files are missing)

    I am using stata version 14.1 in osx 10.11.2





  • #2
    I believe this is a problem for Stata Tech Support. It appears that for the ls command (and apparently some others) the combination of a ~ and a space within the filespec leads to this problem, and that replacing the ~ with the home directory avoids the problem.
    Code:
    . ls "~"
    
    total 0
    drwxr-xr-x   4 lisowskiw  staff   136 Dec 21 21:54 Applications/
    drwx------+  6 lisowskiw  staff   204 Jan  3 14:03 Desktop/
    drwx------+  9 lisowskiw  staff   306 Sep  7 20:45 Documents/
    drwx------+ 10 lisowskiw  staff   340 Jan  4 12:10 Downloads/
    drwx------+ 66 lisowskiw  staff  2244 Dec 25 10:34 Library/
    drwx------+  5 lisowskiw  staff   170 Nov 23 12:53 Movies/
    drwx------+ 11 lisowskiw  staff   374 Sep 12 09:23 Music/
    --Break--
    r(1);
    
    . ls "~/Library"
    
    total 8
    drwx------    5 lisowskiw  staff    170 Nov 25 16:56 Accounts/
    drwx------    6 lisowskiw  staff    204 Oct 30 20:57 Address Book Plug-Ins/
    drwxr-xr-x    5 lisowskiw  staff    170 Aug 14  2014 Application Scripts/
    drwx------   75 lisowskiw  staff   2550 Dec 17 21:33 Application Support/
    drwxr-xr-x    4 lisowskiw  staff    136 Nov  1  2014 Assistant/
    drwx------    2 lisowskiw  staff     68 Dec 18  2010 Assistants/
    drwx------    6 lisowskiw  staff    204 Sep 11 13:21 Audio/
    --Break--
    r(1);
    
    . ls "~/Library/Application Support"
    
    ls: ~/Library/Application Support: No such file or directory
    
    . ls "/Users/lisowskiw/Library/Application Support"
    
    total 16
    drwx------  18 lisowskiw  staff   612 Feb 17  2015 AddressBook/
    drwxr-xr-x   2 lisowskiw  staff    68 Dec 19  2014 Aperture/
    drwxr-xr-x   3 lisowskiw  staff   102 Jan  4 08:20 App Store/
    drwxr-xr-x   6 lisowskiw  staff   204 Oct 16 12:12 Audio Hijack/
    drwxr-xr-x   4 lisowskiw  staff   136 Jan  3 20:22 Automator/
    drwxr-xr-x  23 lisowskiw  staff   782 Apr 23  2015 BBEdit/
    --Break--
    r(1);

    Comment


    • #3
      Would whichpkg (available from SSC in the usual way) do what needs doing for you?

      Comment


      • #4
        I ran into a somewhat related issue. There is a reasonably easy work around however:

        Code:
        findfile stata.trk
        loc filepath `r(fn)'
        loc modfile `: environment HOME'`: subinstr loc filepath `"~"' "", all'
        di `"`modfile'"'
        filefilter `"`modfile'"' ~/Desktop/temp.trk, from(moremata.pkg)
        I'm working on OSX 10.10.5 and am using Stata 14. There is an issue with the tilde expansion in the OS a bit. My case wasn't related directly to this, but the example code above should get you squared away.

        Comment


        • #5
          Thanks- I think you all provided the answer(s) - idiosyncratic behavior in the presence of the tilde.

          whichpkg might well work for my purposes (although my distributed do file would need to check for and install that first :-)

          Comment

          Working...
          X