# \[SC boffins reqd\] Can SuperDirt be installed in the SC startup.scd process (to simplify amount of tidal install steps)?

**URL:** <https://uzu.lurk.org/t/sc-boffins-reqd-can-superdirt-be-installed-in-the-sc-startup-scd-process-to-simplify-amount-of-tidal-install-steps/4634>\
**Category:** TidalCycles\
**Tags:** installation\
**Created:** [26 March 2023 19:58 UTC](https://uzu.lurk.org/t/sc-boffins-reqd-can-superdirt-be-installed-in-the-sc-startup-scd-process-to-simplify-amount-of-tidal-install-steps/4634 "2023-03-26T19:58:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cleary](https://uzu.lurk.org/user_avatar/uzu.lurk.org/cleary/32/177_2.png) [@cleary](https://uzu.lurk.org/u/cleary)\
**Post date:** [26 March 2023 19:58 UTC](https://uzu.lurk.org/t/sc-boffins-reqd-can-superdirt-be-installed-in-the-sc-startup-scd-process-to-simplify-amount-of-tidal-install-steps/4634/1 "2023-03-26T19:58:36Z")

</div>

During a bit of a brainstorming session on discord re the complexity of managing the Win installs, I had a thought that it might be possible to move the SuperDirt install step into the SuperCollider `startup.scd` file

The problem as I've learned during the building of the ansible tool, is that the quark install likes to fork it's process and carry on past that step regardless of the outcome - so it needs to be held up before continuing (a wait loop)

I've discovered a bit of documentation on the [`Condition` object](https://doc.sccode.org/Classes/Condition.html) which looked helpful, and on using a `Routine` to check it's state/trigger it to re-check.

I have a bit of code that seems like it should be close to working, I was wondering if there were any other more knowledgable SuperCollider-ers in the area that could help get it over the line (or rule it out completely)?

I have an overly simplified startup.scd that just needs to confirm that the SuperDirt class is defined _after_ the SuperDirt quark is installed - but the routine is not holding up the file execution (it's like it's being evaluted as a block rather than in serial):

```haskell
(
s.reboot { // server options are only updated on reboot

	// boot the server and start SuperDirt
	s.waitForBoot {
		(
			c = Condition.new(Quarks.isInstalled("SuperDirt"));

			Routine {
				if (Quarks.isInstalled("SuperDirt"),
					{ "SuperDirt already installed".postln },
					{ Quarks.install("https://github.com/musikinformatik/SuperDirt.git")}
				);
				loop {
					if (c.test,
						{"SuperDirt Installed".postln; c.signal},
						{1.wait}
					);
					c.wait;
				};
			}.play;

			~dirt = SuperDirt(2, s);
		)
	};
	s.latency = 0.3; // increase this if you get "late" messages

};
)

```

---

<div class="post-metadata">

**Author:** ![cleary](https://uzu.lurk.org/user_avatar/uzu.lurk.org/cleary/32/177_2.png) [@cleary](https://uzu.lurk.org/u/cleary)\
**Post date:** [27 March 2023 06:18 UTC](https://uzu.lurk.org/t/sc-boffins-reqd-can-superdirt-be-installed-in-the-sc-startup-scd-process-to-simplify-amount-of-tidal-install-steps/4634/2 "2023-03-27T06:18:14Z")

</div>

I've got a response on the SuperCollider discord channel - it's possible to obfuscate the SuperDirt class by loading it in a separate file altogether, eg:

```haskell
    if(Quarks.isInstalled("SuperDirt").not) {
        "installing Superdirt".postln;
        Quarks.install("SuperDirt");
        thisProcess.recompile;
    } {
        "SuperDirt is ready".postln;
        "/tmp/bla.scd".load;
    };

```

works, but raises the issue of file path conventions cross-platform.  
If there's a concept of a running directory I can just drop a file in and provide no path prefix, that would be good.  
Alternatively, SC does some file IO stuff, so it may be a matter of rewriting startup.scd after the initial installation?

---

<div class="post-metadata">

**Author:** ![cleary](https://uzu.lurk.org/user_avatar/uzu.lurk.org/cleary/32/177_2.png) [@cleary](https://uzu.lurk.org/u/cleary)\
**Post date:** [28 March 2023 22:17 UTC](https://uzu.lurk.org/t/sc-boffins-reqd-can-superdirt-be-installed-in-the-sc-startup-scd-process-to-simplify-amount-of-tidal-install-steps/4634/3 "2023-03-28T22:17:35Z")

</div>

It's getting real close - for some reason the `Download` is being pre-empted by the `Quarks.install` process, so I just need to work that out.

Then i just need to see if I can download and clobber the existing startup.scd with the superdirt startup.scd template...

```haskell
var sd_startup = (thisProcess.platform.userConfigDir +/+ "superdirt_startup.scd");

if(Quarks.isInstalled("SuperDirt").not) {
    "...installing Superdirt".postln;
    Download.new("https://raw.githubusercontent.com/musikinformatik/SuperDirt/develop/superdirt_startup.scd", sd_startup,
        {\huzzah.postln;},
        {\error.postln;},
        {|rec, tot| [rec, tot].postln});
    Quarks.install("SuperDirt");
    //Get startup.scd reference
    thisProcess.recompile;
} {
    "...Starting SuperDirt".postln;
    sd_startup.load;
};

```

---

<div class="post-metadata">

**Author:** ![cleary](https://uzu.lurk.org/user_avatar/uzu.lurk.org/cleary/32/177_2.png) [@cleary](https://uzu.lurk.org/u/cleary)\
**Post date:** [29 March 2023 19:58 UTC](https://uzu.lurk.org/t/sc-boffins-reqd-can-superdirt-be-installed-in-the-sc-startup-scd-process-to-simplify-amount-of-tidal-install-steps/4634/4 "2023-03-29T19:58:44Z")

</div>

I got there - this downloads and installs the quark, downloads and installs the template superdirt startup.scd file, and does an in-place replacement of the startup.scd so it looks "normal" from that point on

I need to test on win here, and it would be great if someone with a mac could test on osx (@HighHarmonics ?)

Stick this in a blank startup.scd (you can open SC, file -\> open startup file, copy and paste it in then restart sc)

```haskell
var sd_startup = (thisProcess.platform.userConfigDir +/+ "sd_startup.scd");
var startup = (thisProcess.platform.userConfigDir +/+ "startup.scd");

if(Quarks.isInstalled("SuperDirt").not) {
	Quarks.install("SuperDirt");
	thisProcess.recompile;
} {
	Download.new("https://raw.githubusercontent.com/musikinformatik/SuperDirt/develop/superdirt_startup.scd", sd_startup,
		{
			File.delete(startup);
			File.copy(sd_startup, startup);
			File.delete(sd_startup);
			startup.load;
		},
		{\error.postln;},
		{|rec, tot| [rec, tot].postln});
};

```

---

<div class="post-metadata">

**Author:** ![HighHarmonics](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/h/13edae/32.png) [@HighHarmonics](https://uzu.lurk.org/u/HighHarmonics)\
**Post date:** [30 March 2023 02:49 UTC](https://uzu.lurk.org/t/sc-boffins-reqd-can-superdirt-be-installed-in-the-sc-startup-scd-process-to-simplify-amount-of-tidal-install-steps/4634/5 "2023-03-30T02:49:41Z")

</div>

Sure. I'll test this as soon as I can.

---

<div class="post-metadata">

**Author:** ![cleary](https://uzu.lurk.org/user_avatar/uzu.lurk.org/cleary/32/177_2.png) [@cleary](https://uzu.lurk.org/u/cleary)\
**Post date:** [30 March 2023 03:00 UTC](https://uzu.lurk.org/t/sc-boffins-reqd-can-superdirt-be-installed-in-the-sc-startup-scd-process-to-simplify-amount-of-tidal-install-steps/4634/6 "2023-03-30T03:00:02Z")

</div>

Thanks! Confirmed working on Windows btw 🙂

---

<div class="post-metadata">

**Author:** ![Raph](https://uzu.lurk.org/user_avatar/uzu.lurk.org/raph/32/45_2.png) [@Raph](https://uzu.lurk.org/u/Raph)\
**Post date:** [31 March 2023 22:06 UTC](https://uzu.lurk.org/t/sc-boffins-reqd-can-superdirt-be-installed-in-the-sc-startup-scd-process-to-simplify-amount-of-tidal-install-steps/4634/7 "2023-03-31T22:06:37Z")

</div>

That's really awesome. It is a great step forward in order to simplify installation. Great work @cleary. It would be nice to document this even if it doesn't end up being the default method for install.
