supercollider icon indicating copy to clipboard operation
supercollider copied to clipboard

Quarks system should be able to work without installing Git

Open cdbzb opened this issue 1 year ago • 15 comments

Motivation

Currently users are required to install Git to use Quarks - this can be challenging for new users who don't come form a coding background esp on Windows.

Description of Proposed Feature

on my system: curl -L -O https://github.com/supercollider-quarks/downloaded-quarks/archive/refs/heads/master.zip works.

Quarks should fall back to curl if Git is not installed

cdbzb avatar Jun 22 '24 15:06 cdbzb

Would be nice! When you install git after you have downloaded supercollider, how will you move from this one to the git one?

telephon avatar Jun 22 '24 16:06 telephon

I think that supporting multiple ways create even more problems and unstableness in this case - at least as long as we don't have a proper package index and package/dependency-management which could unify a download procedure by "guiding" a client (e.g. which versions are available ...). If we e.g. fallback to curl in case git is not available, this only works on unix but not on windows - and what happens in case curl is not installed...? Do we look out for wget? Also, the download URL is maybe clear for github (although the default branch maybe not obivous w/o git), but github != git.

There is also libgit2 but I think this is overkill? Maybe the time would be better spend to implement basic curl/wget functionality into sclang via boost instead of git functionality?

I think one additional problem currently could be https://github.com/supercollider/supercollider/issues/6341#issuecomment-2154362421 which does not give reliable results if git is installed at all?

Indeed a very non-optimal solution :/

capital-G avatar Jun 22 '24 16:06 capital-G

Thank you, yes, I suspected this a little bit.

telephon avatar Jun 22 '24 17:06 telephon

re Github !=Git I think that ideally SC should ship with at least the canonical Quark library accessible without installing Git. Now new users can't use any Quarks without Git. With this change they could tinker with Quarks and then learn that they need to install Git only when they seek quarks outside the main repo.

We should transition at some point to a real package manager...

I stupidly hadn't realized that curl was not present in Windows by default...

Would making a Download class that works in this case be a first step towards those goals? Current Download won't work with GH since it won't follow redirects

cdbzb avatar Jun 22 '24 20:06 cdbzb

I thought windows 10 came with curl? Can't find a reliable source right now..

JordanHendersonMusic avatar Jun 22 '24 20:06 JordanHendersonMusic

When you install git after you have downloaded supercollider, how will you move from this one to the git one?

FWIW, I think this isn't a very serious problem.

If you're just downloading and using quarks, then... there wouldn't be any need for Quarks to download the entire history automatically, would there?

The primary case where the user might need to add the history after-the-fact would be to contribute a change back to the quark's repository. But I think in that case, we can assume that the user has enough sophistication to delete the curl-ed directory and re-checkout via git.

I'm in favor of this feature request btw. git has been a weak point of quarks for casual users.

(And, in case a user started with curl and installed git later, we can distinguish between curl-ed and 'git clone'-d quarks by File.exists(theQuark.localPath +/+ ".git") -- when updating a quark, if this is false, use curl -- if true, use git. So in this situation, if .git exists and the git system command can't be found, then we should throw an error because curl-and-overwrite would lose the .git folder and delete history -- definitely don't do that without the user's consent.)

jamshark70 avatar Jun 23 '24 01:06 jamshark70

re Github !=Git I think that ideally SC should ship with at least the canonical Quark library accessible without installing Git.

I agree that it should be easy to install quarks but disagree that Quarks should be shipped with SC - it already starts with a discussion what a canonical quark library would look like.

Currently I see no way of fallbacking to curl in a reliable manner because of the previously mentioned obstacles (additionally: branch/sha pinned dependencies should be resolved accordingly and is not possible w/o git). And while curl is available on windows, I am unsure if it is a system lib for macOS and pretty confident that it is not a system lib on most Linux distros.

I think a way to resolve this "once and for all" would be a proper package index and introduce something like package.json / package-lock.json, combined with native IDE support. But this would require some dev effort, but has already been approached multiple times - maybe it is time for this? But a package index would most likely not be de-centralized anymore :/

capital-G avatar Jun 23 '24 11:06 capital-G

a discussion what a canonical quark library would look like

by canonical library I meant the directory hardcoded into Quark: <>directoryUrl="https://github.com/supercollider-quarks/quarks.git"`

It would be good for new users to be able to try out at least these quarks without installing git.

...but yes I think the "real" answer is a package manager

cdbzb avatar Jun 23 '24 14:06 cdbzb

And while curl is available on windows, I am unsure if it is a system lib for macOS and pretty confident that it is not a system lib on most Linux distros.

From https://everything.curl.dev/

  • Windows 10 comes with the curl tool bundled with the operating system since version 1804.
  • macOS comes with the curl tool bundled with the operating system for many years.
  • Linux distributions come with packager managers that let you install software that they offer. Most Linux distributions offer curl and libcurl to be installed if they are not installed by default.

Linux would be the only unknown there, but assuming linux users can use the package manager seems fair.

JordanHendersonMusic avatar Jun 23 '24 15:06 JordanHendersonMusic

I think it would be good to fix the 'save quark set' with the git hashes for a deterministic archive of a large project. it's broken...

@smoge if you have time can you please file a new issue and label it "quarks"

cdbzb avatar Jun 23 '24 21:06 cdbzb

@smoge if you have time can you please file a new issue and label it "quarks"

it never worked, and I think the tendency is to rewrite quarks anyway

@smoge maybe you misunderstood the comment?

telephon avatar Jun 24 '24 08:06 telephon

One solution would be to introduce a folder downloaded-quarks-without-git that is used for curl or similar. Then switching from that one to git would be easy and clean.

The main problem is that it needs to be communicated, and having different standards between people may complicate communication later on. A typical sitaution: imagine a workshop where half of the members use git, and then you want everybody to update after a bugfix in a quark. This should work smoothly (it may be possible, but needs to be taken into account).

Another good thing about git is that, while an entrance barrier, it makes it easier for people to contribute later. That means it lowers the barrier between developer and user.

I am undecided, just wanted to remark this.

telephon avatar Jun 24 '24 08:06 telephon

You can get the SHA of the current commits on github (I know git isn't github).

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/supercollider-quarks/UnitTesting/commits

You could use this to tell if you are out of date. Unauthenticated access like this is limited to 60 times an hour however.

JordanHendersonMusic avatar Jun 24 '24 08:06 JordanHendersonMusic

Actually, I think @capital-G's suggestion of libgit2 is the right choice. Its very well respected, here is a PR demonstrating basic use #6380. Its super easy to use and we could use it for lots of other things, a few example off the top of my head:

  • Create some kind of project that makes a commit every time you save, letting you see your music's history from inside sc.
  • Making the help docs editable so users can suggest typos and other changes.

The nuances of how it replaces the existing Git class are yet to be worked out. Discussion about this approach's details should be moved to the PR.

JordanHendersonMusic avatar Jun 30 '24 14:06 JordanHendersonMusic