# SelfStarter: make Julia scripts self-starters

**URL:** https://discourse.julialang.org/t/selfstarter-make-julia-scripts-self-starters/124917
**Category:** Package Announcements
**Created:** [January 19, 2025, 11:48am UTC](https://discourse.julialang.org/t/selfstarter-make-julia-scripts-self-starters/124917 "2025-01-19T11:48:46Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![inokawazu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/inokawazu/32/25347_2.png) [@inokawazu](https://discourse.julialang.org/u/inokawazu)
#### Post date: [January 19, 2025, 11:48am UTC](https://discourse.julialang.org/t/selfstarter-make-julia-scripts-self-starters/124917/1 "2025-01-19T11:48:46Z")

</div>

I would like to share a package I wrote a first draft of today called [SelfStarter](https://github.com/inokawazu/SelfStarter). Essentially, it’s a way to make your script self-contained via a simple macro, `@selfstart`, and Julia’s standard library package, `Pkg`. It’s similar to Pluto but focuses on scripts. I look forward to hearing everyone’s thoughts.

---

<div class="post-metadata">

### Author: ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)
#### Post date: [January 19, 2025, 2:59pm UTC](https://discourse.julialang.org/t/selfstarter-make-julia-scripts-self-starters/124917/2 "2025-01-19T14:59:52Z")

</div>

It is unclear to me what problem you attempt to solve. Could you elaborate?  
If I want to run a julia script, I do `julia script.jl` (maybe with `--project`). What is different when using SelfStarter.jl?

---

<div class="post-metadata">

### Author: ![inokawazu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/inokawazu/32/25347_2.png) [@inokawazu](https://discourse.julialang.org/u/inokawazu)
#### Post date: [January 20, 2025, 1:28am UTC](https://discourse.julialang.org/t/selfstarter-make-julia-scripts-self-starters/124917/3 "2025-01-20T01:28:10Z")

</div>

Yeah, this is fair. For anything more permanent than SelfStarter’s intended use case, using the `--project` option is more useful. The idea was to have a script that makes it easier to share scripts; essentially, it is for convenience, where the package shallowly scans the script for what dependencies are needed and creates a provisional package for the script to run in. Ideally, to run the script, all one needs to do is execute `julia script.jl`.

---

<div class="post-metadata">

### Author: ![sschmidhuber](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sschmidhuber/32/13349_2.png) [@sschmidhuber](https://discourse.julialang.org/u/sschmidhuber)
#### Post date: [January 20, 2025, 5:55am UTC](https://discourse.julialang.org/t/selfstarter-make-julia-scripts-self-starters/124917/4 "2025-01-20T05:55:53Z")

</div>

Does that mean SelfStarter would download and precompile all dependencies?

I’m afraid that would lead to a horrible startup time, or did I misunderstand?

If one doesn’t want to add any runtime argument one can also activate the script specific environment by:

`using Pkg; Pkg.activate(@ __DIR__ )`

BR Stefan

---

<div class="post-metadata">

### Author: ![inokawazu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/inokawazu/32/25347_2.png) [@inokawazu](https://discourse.julialang.org/u/inokawazu)
#### Post date: [January 20, 2025, 6:37am UTC](https://discourse.julialang.org/t/selfstarter-make-julia-scripts-self-starters/124917/5 "2025-01-20T06:37:00Z")

</div>

> Does that mean SelfStarter would download and precompile all dependencies?  
> I’m afraid that would lead to a horrible startup time, or did I misunderstand?

Yes, the current version would be slow ([possibly](https://docs.makie.org/stable/) [horribly](https://docs.sciml.ai/DiffEqDocs/stable/)) at first. The package caches the packages as a whole, so subsequent runs should be faster. I was thinking of adding a feature that would allow SelfStarter to consider using globally installed packages as well. If a package is already installed, it would default to the global version—think of plotting packages. I believe this is possible because Julia uses stacked environments.

> If one doesn’t want to add any runtime argument, one can also activate the script-specific environment by: `using Pkg; Pkg.activate(@DIR)`.

Very true! I have used this for some Jupyter notebooks. It can definitely be better for the use case where the script is embedded in a project directory. With `SelfStarter`, a goal is to make it convenient to share a Julia script via a single `.jl` file.

---

<div class="post-metadata">

### Author: ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)
#### Post date: [January 20, 2025, 6:39am UTC](https://discourse.julialang.org/t/selfstarter-make-julia-scripts-self-starters/124917/6 "2025-01-20T06:39:35Z")

</div>

You may find ShareAdd.jl interesting.
