# Avoiding recompilation between interactive use and testing by making testing also checkbounds=auto?

**URL:** <https://discourse.julialang.org/t/avoiding-recompilation-between-interactive-use-and-testing-by-making-testing-also-checkbounds-auto/100830>\
**Category:** General Usage\
**Created:** [June 26, 2023, 5:32am UTC](https://discourse.julialang.org/t/avoiding-recompilation-between-interactive-use-and-testing-by-making-testing-also-checkbounds-auto/100830 "2023-06-26T05:32:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [June 26, 2023, 5:32am UTC](https://discourse.julialang.org/t/avoiding-recompilation-between-interactive-use-and-testing-by-making-testing-also-checkbounds-auto/100830/1 "2023-06-26T05:32:48Z")

</div>

So because by default julia runs with `check-bounds=auto`,  
but when testing it runs with `check-bounds=yes`  
and those generate different package-images,  
julia will have to re-precompile everything when you change from interactive use to `]test`.  
Even if you have no test time dependencies.  
At least, that is my understanding.

Is there something i can monkey-patch to make testing also use `check-bounds=auto` ?  
I can always leave it to CI for the final check anyway.

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [June 26, 2023, 5:34am UTC](https://discourse.julialang.org/t/avoiding-recompilation-between-interactive-use-and-testing-by-making-testing-also-checkbounds-auto/100830/2 "2023-06-26T05:34:57Z")

</div>

Why not use `check-bounds=yes` in the REPL?

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [June 26, 2023, 6:01am UTC](https://discourse.julialang.org/t/avoiding-recompilation-between-interactive-use-and-testing-by-making-testing-also-checkbounds-auto/100830/3 "2023-06-26T06:01:45Z")

</div>

also an option.  
is there an easy way to do that in my startup.jl?  
i don’t want to deal with shell aliases.

---

<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 26, 2023, 7:05am UTC](https://discourse.julialang.org/t/avoiding-recompilation-between-interactive-use-and-testing-by-making-testing-also-checkbounds-auto/100830/4 "2023-06-26T07:05:37Z")

</div>

Not exactly answering your question, but in case you didn’t know that (I discovered this only recently) you can run tests with `--check-bounds=auto` with

```julia
Pkg.test("MyPackage"; julia_args=`--check-bounds=auto`)

```

---

<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 26, 2023, 7:10am UTC](https://discourse.julialang.org/t/avoiding-recompilation-between-interactive-use-and-testing-by-making-testing-also-checkbounds-auto/100830/5 "2023-06-26T07:10:05Z")

</div>

Related to your question, I think you want to hack

> <https://github.com/JuliaLang/Pkg.jl/blob/edc137f46792d9373ca6d6f91907d55341226a52/src/API.jl#L422>

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [June 26, 2023, 7:22am UTC](https://discourse.julialang.org/t/avoiding-recompilation-between-interactive-use-and-testing-by-making-testing-also-checkbounds-auto/100830/6 "2023-06-26T07:22:13Z")

</div>

> [@oxinabox](#):
>
> is there an easy way to do that in my startup.jl?

No, because global flags like that need to be set before julia starts. `stattup.jl` runs after the global flags like `--check-bounds` are set. The test suite does that by launching a worker process where the test code is run, if I recall correctly.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [February 14, 2024, 2:57am UTC](https://discourse.julialang.org/t/avoiding-recompilation-between-interactive-use-and-testing-by-making-testing-also-checkbounds-auto/100830/7 "2024-02-14T02:57:52Z")

</div>

I have now been doing this since this comment, and it has been a huge enhancement to my life.  
I recommend everyone who is developing a lot of julia packages do this.

---

<div class="post-metadata">

**Author:** ![trahflow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/trahflow/32/30585_2.png) [@trahflow](https://discourse.julialang.org/u/trahflow)\
**Post date:** [February 20, 2024, 9:35am UTC](https://discourse.julialang.org/t/avoiding-recompilation-between-interactive-use-and-testing-by-making-testing-also-checkbounds-auto/100830/8 "2024-02-20T09:35:20Z")

</div>

@oxinabox you mean starting julia by default with `--check-bounds=yes`?  
Did you do it via a shell alias in the end?

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [February 21, 2024, 2:52am UTC](https://discourse.julialang.org/t/avoiding-recompilation-between-interactive-use-and-testing-by-making-testing-also-checkbounds-auto/100830/9 "2024-02-21T02:52:04Z")

</div>

I do something complicated.  
I have a bash script that starts my julia that I run from VS-Code because I want to run the VS-Code language server and the REPL using different versions of julia.  
(I want my REPL running something near nightly)

and that script is like

```julia
#!/usr/bin/env bash
set -e
if [-z "$JULIA_VSCODE_INTERNAL"]; then
	exec julia-crimes --check-bounds=yes "$@"
else
	exec julia +release --check-bounds=yes "$@"
fi

```

So it always passes the argument
