# Suggestion for a new package: MinimalWorkingExamples.jl

**URL:** <https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391>\
**Category:** Package Announcements\
**Tags:** question, package\
**Created:** [April 16, 2021, 7:43am UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391 "2021-04-16T07:43:27Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 16, 2021, 2:08pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/21 "2021-04-16T14:08:32Z")

</div>

> [@yakir12](#):
>
> alleviates the need to
> 
> 1. activate a temp env
> 2. add the mentioned packages

FWIW, I don’t find this that much of a hassle, unless the MWE uses a lot of packages — in practice, most of them just use 1–5, more is kind of uncommon and should live in a repo with a manifest.

For the latter, Github Gist actually works fine, because multiple files can exist in the same gist and be downloaded as a zip file. If a `Manifest.toml` is included, downloading, extracting, instantiating and activating that is a reasonable and convenient workflow.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [April 16, 2021, 3:08pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/22 "2021-04-16T15:08:59Z")

</div>

Compare what we do today (ignore the errors):  
 ![mwe](https://global.discourse-cdn.com/julialang/original/3X/8/f/8fc8e5f595475e8ffa6a2672e7e828feba1c7e27.gif)

with this:

![mwe2](https://global.discourse-cdn.com/julialang/original/3X/6/f/6f0b5ef59c53f1d725cf1813315f656e5edb83d6.gif)

(it looks better if you click on the gifs)  
I just added `using MinimumWorkingExample` to your MWE.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 16, 2021, 3:36pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/23 "2021-04-16T15:36:36Z")

</div>

This example underscores my point above: you really need a manifest for anything nontrivial. Note how the [code in that example](https://discourse.julialang.org/t/concatenate-csv-data-into-feather-using-datastreams/3690/) is outdated now (will fail at `CSV.Source`).

I think it would be better to come up with a convenience solution that reproduces an environment in a few steps, rather than just automatically downloading the latest versions of some packages. And, from the user side, that packs code + manifest to an archive or a gist.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [April 16, 2021, 3:44pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/24 "2021-04-16T15:44:27Z")

</div>

I do wish there was some sort of environment or REPL mode for what you are describing. It would be great if `using MinimumWorkingExample` would activate a temp environment and also detect and add packages that were subsequently entered by `using ThisPackage`.

And to get at @Tamas_Papp point, perhaps what this `MinimumWorkingExample.jl` should do is package the MWE so that other people can run it. So it would have dual purposes:

1. Users creating an MWE would `using MinimumWorkingExamples` and call a function on a `.jl` script from which they would like to create an MWE. This package would create a reproducible environment and push it … somewhere (GitHub Gist? making this up as I go, sorry). It generates a link that they can share.
2. Users wanting to run an MWE would `using MinimumWorkingExamples` and call a function on some provided link which would then download and execute the code. I guess it would be most beneficial if it also opened the code in your editor or something.

Thinking out loud here.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [April 16, 2021, 4:10pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/25 "2021-04-16T16:10:37Z")

</div>

@tbeason, ooo, I like that. Very cool!

And @Tamas_Papp, yea, I guess my main point is that (to begin with at least) this would only be for immediately testing someone’s MWE. Failing an outdated MWE or a complicated one is totally fine. I guess the question is: Are these small, simple, and ephemeral MWE too simple for building and using such a tool, or not?

---

<div class="post-metadata">

**Author:** ![FPGro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fpgro/32/20822_2.png) [@FPGro](https://discourse.julialang.org/u/FPGro)\
**Post date:** [April 16, 2021, 5:48pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/26 "2021-04-16T17:48:01Z")

</div>

Just throwing in some additional points that may benefit **the creator of an MWE** (I’d agree with Tamas in that it’s usually simple enough to run MWEs)

- Assert self-containment: you often enough see MWE that are missing packages, variable or function definitions and the like. A useful functionality would be something like a macro that you could wrap around your mwe that would throw if the example couldn’t be run on its own

- Environment state: it may be as simple as outputting or prepending to an existing example a series of

```julia
using Pkg
Pkg.activate(...) # temp? 
Pkg.add(...) # pinned to the exact versions that are at the environment at the time of writing the mwe
... 
using...

```

This would also make it completely self-contained and you don’t need another package to run it.

- Up-to-dateness: issuing a warning when you create a mwe with outdated packages in the environment. I know it should not be the task of such a package, but it would catch quite a lot of questions before they even appear here (looking at `DataFrames`, surprisingly many people end up with v0.19 something of that)

- some debut info is never bad. If the package would pack an mwe into a neat self-contained script, it could likewise append some basic information as comments at the end (especially OS, build and Julia version)

- should be easy to discover and use. Maybe just two entry points, a macro for in-script or REPL usage (`@mwe begin... mwe... end`) that would generate a clean mwe.jl script and a function that would execute the above checks for an existing script

- promotional header: the first line of a generated script should be a comment stating that it was generated with MWE.jl for two reasons: If you intend to run the mwe to offer help, you immediately know that the most basic checks were already done and you can just copy paste everything. And additionally, new users and people searching for help in the forum see that there’s a package for that stuff.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [April 16, 2021, 7:16pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/27 "2021-04-16T19:16:59Z")

</div>

Some awesome stuff. Allow me to summarize:

I think we can agree, there are two different tools being discussed here:

1. minimal tool that just alleviates the need to activate a temp env and add the packages mentioned in small, minimal, and ephemeral MWE.
2. robust tool that guarantees the up-to-dateness, completeness, and reproducibility of any MWE.

The first simpler tool would save some typing when testing people’s MWE. The second tool would dramatically increase the quality of MWE in the whole ecosystem. And as @FPGro mentioned, it might solve some of the issues people see just by checking the up-to-dateness and completeness of people’s MWE. I mean, it could revolutionize MWE in Julia forever 🙂

So while I started this off with the idea of something small but useful (tool #1) I’m slowly realizing that the second robust tool would have a much bigger positive effect on the community. Obviously, the robust tool would also alleviate the same pains the first tool was supposed to address, so win win!

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [April 16, 2021, 7:22pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/28 "2021-04-16T19:22:17Z")

</div>

> [@yakir12](#):
>
> minimal tool that just alleviates the need to activate a temp env and add the packages mentioned in small, minimal, and ephemeral MWE.

I still think you need to work in a different process with a clean load path/depot, otherwise you stack on the global environment (and people tend to have huge global environments), which isn’t good.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [April 16, 2021, 7:36pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/29 "2021-04-16T19:36:16Z")

</div>

I totally agree. Not doing that would prevent us from being able to reproduce the exact same environment (baring system differences).

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [April 16, 2021, 8:38pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/30 "2021-04-16T20:38:15Z")

</div>

This movie makes it clear for me, I hadn’t fully grasped your idea. I pretty much would love to have something like that!

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [April 19, 2021, 9:29pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/31 "2021-04-19T21:29:09Z")

</div>

@fredrikekre pointed out on Zulip that you can activate a completely clean environment (with empty load path) with

```julia
push!(empty!(LOAD_PATH), joinpath(mktempdir(), "Project.toml"))

```

without having to start a separate Julia process.

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [March 20, 2025, 7:38pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/32 "2025-03-20T19:38:05Z")

</div>

IMO it’s still cleaner to have a new process, specifically because any changes you made or packages you loaded in the current process will still be present in the “MWE”.

A nice API that I could see would be:

```julia
@mwe begin
using blahblah
somecode
here
end temp=true newprocess=true manifest=true packagespecs=PackageSpec[]

```

and this would execute like a Documenter `@repl` block, and copy something like the following to your clipboard:

```julia
` ` ` julia
julia> using blahblah
julia> your
someresult
...
` ` `
<details>
<summary Manifest.toml </summary>

` ` ` toml
Manifest contents
` ` `
</details>

```

This could then also mock up a Pluto notebook, for example, and add that in a description block too.

The keyword arguments would be:

- `temp = true`: launch in a temporary environment and add all packages invoked by `using` or `import` in the MWE
- `newprocess = true`: run the MWE in a new Julia process
- `manifest = true`: include the Manifest.toml in a details block in the copied Markdown
- `packagespecs = PackageSpec[]`: a vector of `PackageSpec`s from `Pkg`, so that you can specify specific versions, PRs, or URLs for repos. Useful when creating MWEs of pull requests, et cetera. This is more for hardcore package devs/users though.

What do folks here think? Would be a great new user project, and I’d be happy to provide support if requested 🙂

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [March 21, 2025, 12:00pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/33 "2025-03-21T12:00:09Z")

</div>

This sounds stellar.

---

<div class="post-metadata">

**Author:** ![BjarkeHautop](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bjarkehautop/32/219291_2.png) [@BjarkeHautop](https://discourse.julialang.org/u/BjarkeHautop)\
**Post date:** [June 18, 2026, 3:45pm UTC](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391/34 "2026-06-18T15:45:39Z")

</div>

I made a package inspired by this thread, your comment (and the R package reprex of course): [MinimalWorkingExamples.jl](https://bjarkehautop.github.io/MinimalWorkingExamples.jl/dev/)

Would love any feedback!

[Previous page](https://discourse.julialang.org/t/suggestion-for-a-new-package-minimalworkingexamples-jl/59391.md?page=1)
