22

I want to use GitHub as a paclet server, but this fails:

PacletInstall[
 "ServiceConnection_StackExchange",
 "Site" -> "https:/github.com/paclets/Repository"
 ]

PacletSiteUpdate::err: An error occurred attempting to update paclet information from site https:/github.com/b3m2a1/PacletServer. Does not appear to be a valid paclet site

PacletInstall::notavail: No paclet named ServiceConnection_StackExchange is available for download from any currently enabled paclet sites.

$Failed

Is there a work around?


See also: How to distribute Mathematica packages as paclets? and this answer

b3m2a1
  • 46,870
  • 3
  • 92
  • 239

1 Answers1

21

First things first we set up the paclet server in the normal way as described here or here.

Then all we need to do is pass the "raw.githubusercontent" version of that so that the resources themselves get downloaded instead of the HTML pages:

PacletInstall[
 "ServiceConnection_StackExchange",
 "Site" -> 
  "http://raw.githubusercontent.com/paclets/Repository/master"
 ]

Paclet[
"Name" -> "ServiceConnection_StackExchange", "Version" -> "1.0.0", 
 "Description" -> "A service connection to the Stack Exchange API. \
Supports the majority of the functions defined in the API", 
 "Extensions" -> {{
   "Kernel", "Root" -> ".", 
    "Context" -> "ServiceConnection_StackExchange`"}, {
   "FrontEnd", "Prepend" -> True}}, 
 "Location" -> "~/Library/Mathematica/Paclets/Repository/\
ServiceConnection_StackExchange-1.0.0"]

Note:

As Szabolcs points out, you must use "http://raw.githubusercontent.com". The PacletManger refuses to use the "https://" form.

b3m2a1
  • 46,870
  • 3
  • 92
  • 239
  • 3
    Do point out the HTTPS thing for those who wouldn't realize its importance. – Szabolcs Sep 05 '17 at 20:37
  • a) GitHubServer should be PacletServer right? b) I think this topic deserves a one line intro about the setup because users could be confused about that is really going on. – Kuba Jan 07 '19 at 10:20
  • @Kuba the GitHubServer was a repo I set up specifically for this question and at some point must have removed. I'll change it to the public server. That's a better one to point to. – b3m2a1 Jan 07 '19 at 16:09
  • How can you pass on Authentication and/or Header information to PacletSiteRegister and/or PacletSiteUpdate to access private GitHub repos? – István Zachar Apr 08 '21 at 13:01
  • @IstvánZachar there’s no general way, but you can intercept the behavior of PacletInstall to do so, e.g. write a PrivatePacletInstall that can forward auth details to URLFetch when it’s called – b3m2a1 Apr 08 '21 at 17:06
  • @b3m2a1 Yes, I got to the same conclusion. But then it defies the purpose of distributing paclets if the method to get the paclet is not available for other users. I.e. one has to distribute the custom PrivatePacletInstall definition with the authetntication token. Not very convenient. – István Zachar Apr 08 '21 at 17:23
  • @IstvánZachar paclet servers aren’t really ready for prime time. WRI was working on a formalization of the server infrastructure, but then they stopped doing so because of the success of the function repository. I think they might be getting back into it, but you can see what we did for that public paclet server, where I wrote a PublicPacletInstall function that could be loaded from a URL and used to install any paclet on the server. Ain’t perfect but it’ll get you where you need to be while you wait for WRI. – b3m2a1 Apr 08 '21 at 17:26