# Recommended practices for trying out packages without polluting global env

**URL:** <https://discourse.julialang.org/t/recommended-practices-for-trying-out-packages-without-polluting-global-env/129912>\
**Category:** New to Julia\
**Created:** [June 16, 2025, 8:31am UTC](https://discourse.julialang.org/t/recommended-practices-for-trying-out-packages-without-polluting-global-env/129912 "2025-06-16T08:31:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunafazio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lunafazio/32/217332_2.png) [@lunafazio](https://discourse.julialang.org/u/lunafazio)\
**Post date:** [June 16, 2025, 8:31am UTC](https://discourse.julialang.org/t/recommended-practices-for-trying-out-packages-without-polluting-global-env/129912/1 "2025-06-16T08:31:20Z")

</div>

I am aware of `activate --temp`, but adding any package always seems to involve a lot of precompilation, so not ideal for quickly testing things.

Are there some additional convenience options for `--temp` that I am overlooking or should I just create some “scratch” project for trying things out in? This approach feels messier since it will just keep around things from previous tests as part of the project and manifest `.toml` files.

I guess the setup I am looking for would be one that wipes those config files at the end of the session but still keeps around the results of precompilation, but maybe someone has better ideas.

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/224680_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 16, 2025, 9:19am UTC](https://discourse.julialang.org/t/recommended-practices-for-trying-out-packages-without-polluting-global-env/129912/2 "2025-06-16T09:19:58Z")

</div>

Personally, I keep a global `@sandbox` environment in which I regularly purge the contents and install new things. It’s essentially like a `--temp` but I can reuse it several times if I’m working on the same little bit of code. Other than that, I have some global environments dedicated to specific themes (`@autodiff`, `@gpu`) which contain relevant packages for these fields, that are amortized rather fast. It’s much better than always going `Test.activate()` in my experience.

I also know that there are options to make compilation less burdensome:

- disable [automatic precompilation](https://pkgdocs.julialang.org/v1/environments/#Automatic-Precompilation) with environment variable [`JULIA_PKG_PRECOMPILE_AUTO`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_PKG_PRECOMPILE_AUTO)
- install [already available versions](https://pkgdocs.julialang.org/v1/api/#Pkg.add) of packages when possible, setting preferences with variables like [`JULIA_PKG_PRESERVE_TIERED_INSTALLED`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_PKG_PRESERVE_TIERED_INSTALLED)
- keep more versions of packages precompiled by increasing [`JULIA_MAX_NUM_PRECOMPILE_FILES`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_MAX_NUM_PRECOMPILE_FILES)
- automatically precompile existing environments when you update Julia with PrecompileAfterUpdate.jl

---

<div class="post-metadata">

**Author:** ![lunafazio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lunafazio/32/217332_2.png) [@lunafazio](https://discourse.julialang.org/u/lunafazio)\
**Post date:** [June 16, 2025, 10:44am UTC](https://discourse.julialang.org/t/recommended-practices-for-trying-out-packages-without-polluting-global-env/129912/3 "2025-06-16T10:44:58Z")

</div>

Ah, I wasn’t aware of the shared environments feature. Thank you for the pointers, these are all very helpful!

---

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [June 21, 2025, 1:34pm UTC](https://discourse.julialang.org/t/recommended-practices-for-trying-out-packages-without-polluting-global-env/129912/4 "2025-06-21T13:34:33Z")

</div>

ShareAdd.jl can help with using shared and stacked environments.

---

<div class="post-metadata">

**Author:** ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)\
**Post date:** [June 21, 2025, 2:32pm UTC](https://discourse.julialang.org/t/recommended-practices-for-trying-out-packages-without-polluting-global-env/129912/5 "2025-06-21T14:32:09Z")

</div>

> [@lunafazio](#):
>
> the setup I am looking for would be one that wipes those config files at the end of the session but still keeps around the results of precompilation

I don’t think precompilation results are wiped when you use `activate --temp`?

---

<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:** [June 21, 2025, 2:47pm UTC](https://discourse.julialang.org/t/recommended-practices-for-trying-out-packages-without-polluting-global-env/129912/6 "2025-06-21T14:47:45Z")

</div>

> [@danielwe](#):
>
> I don’t think precompilation results are wiped when you use `activate --temp`?

They’re not. Precompile cache is evicted when you have more than [`JULIA_MAX_NUM_PRECOMPILE_FILES`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_MAX_NUM_PRECOMPILE_FILES) cached file for the given package in the given version of Julia, regardless of which environment the precompile cache was created in, temporary or not.

---

<div class="post-metadata">

**Author:** ![lunafazio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lunafazio/32/217332_2.png) [@lunafazio](https://discourse.julialang.org/u/lunafazio)\
**Post date:** [June 22, 2025, 10:22am UTC](https://discourse.julialang.org/t/recommended-practices-for-trying-out-packages-without-polluting-global-env/129912/7 "2025-06-22T10:22:42Z")

</div>

You’re right, I probably mis-inferred Julia’s behavior due to the fact I was only using it very sparingly until now. After testing things out more systematically, it does seem like the default behavior is just what I had hoped for!
