packageracketraco

Programmatically determining if a Racket package is installed


Is there any programmatic way to determine if a package has been installed?

I know about raco pkg show, but it only seems to return a string with information about the scope that is installed. For example, if I run it from the command line:

$ raco pkg show frog
Installation-wide:
 Package  Checksum                Source
 frog     13fbe6b0...             clone...tt/frog/master
User-specific for installation "development":
 [none]

While I could try to parse this result, is there currently a more straightforward way to programmatically determine if a package is installed?


Solution

  • #lang racket
    (require pkg/lib)
    
    (installed-pkg-names)
    

    In general, pkg/lib is the library that raco pkg uses.