# How to find which code is generating a warning?

**URL:** https://discourse.julialang.org/t/how-to-find-which-code-is-generating-a-warning/130541
**Category:** New to Julia
**Created:** [July 7, 2025, 5:09pm UTC](https://discourse.julialang.org/t/how-to-find-which-code-is-generating-a-warning/130541 "2025-07-07T17:09:24Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [July 7, 2025, 7:25pm UTC](https://discourse.julialang.org/t/how-to-find-which-code-is-generating-a-warning/130541/2 "2025-07-07T19:25:54Z")

</div>

@Lilith posted a trick to do this here by turning those warnings into errors:

> [@Warning stack trace](https://discourse.julialang.org/t/warning-stack-trace/67516/2):
>
> Julia doesn’t store stack traces for warnings. However, warning messages are typically written to the stderr stream, so you can turn such warnings to errors (which do have stack traces) by redirecting stderr to a read-only stream: julia\> redirect\_stderr(open(touch(tempname()), "r")) IOStream(\<file ...\>) julia\> f() = @warn "Find me" f (generic function with 1 method) julia\> g() = f() g (generic function with 1 method) julia\> h() = g() h (generic function with 1 method) julia\> h() ERROR: Argu…

---

_[View the full topic](https://discourse.julialang.org/t/how-to-find-which-code-is-generating-a-warning/130541)._
