How to skip precompilation on `using`/`import` (for any given package)?

I have a startup.jl file with

using Revise
using OhMyREPL
redirect_stderr(devnull) do
    @eval using AbbreviatedStackTraces
end

Since AbbreviatedStackTraces.jl doesn’t support precompilation, I silenced the warnings with the answer from How to disable the "skipping precompilation" info?. But, this still checks for precompiling, and adds even more overhead with redirect_stderr and @eval, slowing down REPL launch. Is there a way to tell Julia to not bother precompiling a given module?

P.S. Before redirecting stderr, this was the REPL

$ julia
Precompiling AbbreviatedStackTraces
  ? AbbreviatedStackTraces
[ Info: Precompiling AbbreviatedStackTraces [ac637c84-cc71-43bf-9c33-c1b4316be3d4]
[ Info: Skipping precompilation since __precompile__(false). Importing AbbreviatedStackTraces [ac637c84-cc71-43bf-9c33-c1b4316be3d4].
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.4 (2024-06-04)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia>

I think a better way would be to use atreplinit:

atreplinit() do repl
    @eval using OhMyREPL
    redirect_stderr(devnull) do
        @eval using AbbreviatedStackTraces
    end
end

This should make the REPL load faster and also make it work inside VS Code. Ref: issue #38

1 Like