# \[ANN\] AutoPkg.jl - install and use packages in one go

**URL:** <https://discourse.julialang.org/t/ann-autopkg-jl-install-and-use-packages-in-one-go/134832>\
**Category:** Package Announcements\
**Created:** [January 1, 2026, 4:03pm UTC](https://discourse.julialang.org/t/ann-autopkg-jl-install-and-use-packages-in-one-go/134832 "2026-01-01T16:03:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Post date:** [January 1, 2026, 4:03pm UTC](https://discourse.julialang.org/t/ann-autopkg-jl-install-and-use-packages-in-one-go/134832/1 "2026-01-01T16:03:33Z")

</div>

Motivated by the need to create Google Colab notebooks that handle package installation in a very simple, beginner-friendly way (for didactic scenarios), I’ve registered a little package [AutoPkg](https://github.com/oschulz/AutoPkg.jl). It provides a macro `@autopkg` that makes it easy to add and use packages in one go ([Colab example link](https://colab.research.google.com/drive/1351EjrlNOEbBtBsEqlGfXRiNKamEbDCE)).

Just have a cell like

```julia
import Pkg; Pkg.add("AutoPkg"); using AutoPkg

```

at the top of the notebook (Colab, Jupyter, VS-Code), then you can just do

```julia
@autopkg begin
    using Distributions
    using Makie
    import CairoMakie
end

```

On Google Colab, `@autopkg` installs packages directly (since the notebooks run in isolated containers anyway), otherwise it activates a temporary Julia project env. It also always sets `$JULIA_PKG_PRESERVE_TIERED_INSTALLED` to `"true"`.

In addition to notebooks, I’ve also found `@autopkg` useful to quickly try out some packages on the REPL. It also, at least partially, addresses [Pkg issues 3027](https://github.com/JuliaLang/Pkg.jl/issues/3027).

(`@autopkg` is not intended for Pluto notebooks, Pluto has built-in package management after all.)

`@autopkg` can handle more complex block of code as well, like

```julia
@autopkg begin
    using SomePackage, SomeOtherPackage
    import YetAnotherPackage

    if some_condition
        using OneMorePackage: some_feature
    end
end

```

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [January 1, 2026, 11:15pm UTC](https://discourse.julialang.org/t/ann-autopkg-jl-install-and-use-packages-in-one-go/134832/2 "2026-01-01T23:15:20Z")

</div>

> [@oschulz](#):
>
> `@autopkg` useful to quickly try out some packages on the REPL

For REPL, is it basically the default behavior + auto-click “o + Enter” at the prompt? Or something different?

---

<div class="post-metadata">

**Author:** ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Post date:** [January 3, 2026, 12:24pm UTC](https://discourse.julialang.org/t/ann-autopkg-jl-install-and-use-packages-in-one-go/134832/3 "2026-01-03T12:24:03Z")

</div>

> [@aplavin](#):
>
> For REPL, is it basically the default behavior + auto-click “o + Enter” at the prompt? Or something different?

Basically, though `@autopkg` will activate a temporary project env no matter if the packages are already in the current env or not. And it will always set `$JULIA_PKG_PRESERVE_TIERED_INSTALLED` (we could make that configurable, if there’s interest). It’s nice to have in VSCode though - at least for me, the VSCode Julia REPL doesn’t offer automatic package installation.

But yes, while if `@autopkg` can be convenient at the REPL, it’s certainly not a necesscity. It is mainly intended for notebook, and my main use case has been Colab so far.
