# Code block only for PackageCompiler and not for Revise

**URL:** <https://discourse.julialang.org/t/code-block-only-for-packagecompiler-and-not-for-revise/99870>\
**Category:** General Usage\
**Tags:** repl, revise, package-compiler\
**Created:** [June 5, 2023, 5:12am UTC](https://discourse.julialang.org/t/code-block-only-for-packagecompiler-and-not-for-revise/99870 "2023-06-05T05:12:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![xgdgsc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xgdgsc/32/608_2.png) [@xgdgsc](https://discourse.julialang.org/u/xgdgsc)\
**Post date:** [June 5, 2023, 5:12am UTC](https://discourse.julialang.org/t/code-block-only-for-packagecompiler-and-not-for-revise/99870/1 "2023-06-05T05:12:55Z")

</div>

I’ m searching for ways to workaround [can't use revise · Issue #166 · comonicon/Comonicon.jl · GitHub](https://github.com/comonicon/Comonicon.jl/issues/166) . When developing using Revise, Comonicon and `@ccallable` functions seem to cause Revise errors that needs restarting REPL. Is it possible to make some code block like the Comonicon macros and `@ccallable` wrapped block only valid when using PackageCompiler, or on the contrary detect if in REPL or Revise enviornment and don’ t try to Revise them?

Currently I comment them out when developing and comment back when building with PackageCompiler.

---

<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:** [June 5, 2023, 5:19am UTC](https://discourse.julialang.org/t/code-block-only-for-packagecompiler-and-not-for-revise/99870/2 "2023-06-05T05:19:50Z")

</div>

You probably want to do what PrecompileTools.jl is doing here:

> <https://github.com/JuliaLang/PrecompileTools.jl/blob/11410b2970041907c2396d374ad7893d6f89a118/src/workloads.jl#L66>

The following will be true when using PackageCompiler.jl (and during precompilation). It will be false for Revise.jl.

```julia
ccall(:jl_generating_output, Cint, ()) == 1

```

@tim.holy do you agree?

---

<div class="post-metadata">

**Author:** ![xgdgsc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xgdgsc/32/608_2.png) [@xgdgsc](https://discourse.julialang.org/u/xgdgsc)\
**Post date:** [June 5, 2023, 7:15am UTC](https://discourse.julialang.org/t/code-block-only-for-packagecompiler-and-not-for-revise/99870/3 "2023-06-05T07:15:17Z")

</div>

And I noticed when Revise is added to the Project. The compiled binary would give an error of `InitError(mod=:Revise)`… when given to another user that doesn’ t have access to my `.julia/juliaup/julia-1.9.0...`. Should Revise be added just globally?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [June 5, 2023, 2:07pm UTC](https://discourse.julialang.org/t/code-block-only-for-packagecompiler-and-not-for-revise/99870/4 "2023-06-05T14:07:10Z")

</div>

Does [`Revise.dont_watch_pkgs`](https://timholy.github.io/Revise.jl/stable/user_reference/#Revise.dont_watch_pkgs) help?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [June 5, 2023, 2:14pm UTC](https://discourse.julialang.org/t/code-block-only-for-packagecompiler-and-not-for-revise/99870/5 "2023-06-05T14:14:18Z")

</div>

Generally you should _not_ add Revise as a dependency of any package. The only exceptions are packages like Genie.jl that explicitly use Revise to provide dynamic updates of code as part of their own functionality. Otherwise, Revise and other “developer” tools should only ever be in your global environment.

Here’s my environment:

```julia
(@v1.9) pkg> st
Status `~/.julia/environments/v1.9/Project.toml`
  [1520ce14] AbstractTrees v0.4.4
  [6e4b80f9] BenchmarkTools v1.3.2
  [13f3f980] CairoMakie v0.10.5
  [f68482b8] Cthulhu v2.8.15
  [31a5f54b] Debugger v0.7.8
  [35a29f4d] DocumenterTools v0.1.16
  [5789e2e9] FileIO v1.16.1
  [e9467ef8] GLMakie v0.8.5
  [5903a43b] Infiltrator v1.6.3
  [c3a54625] JET v0.7.15 `~/.julia/dev/JET`
  [89398ba2] LocalRegistry v0.5.3
  [ee78f7c6] Makie v0.19.5
  [85b6ec6f] MethodAnalysis v0.4.13
  [a408fb95] PkgCacheInspector v1.0.0
  [14b8a8f1] PkgTemplates v0.7.36
  [21216c6a] Preferences v1.4.0
  [c46f51b8] ProfileView v1.7.1
  [92933f4c] ProgressMeter v1.7.2
  [295af30f] Revise v3.5.2
  [aa65fe97] SnoopCompile v2.10.7
  [e2b509da] SnoopCompileCore v2.10.0
⌅ [1e6cf692] TestEnv v1.9.3
  [e6125b7d] WhyNotEqual v0.2.0
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated`

```

As you can see, almost everything in here is a developer tool or plotting; AbstractTrees and ProgressMeter are the only two borderline cases. All of my “work” (research/coding/whatever) `project`s have their own custom environments that omit the developer-tool packages on this list.

This way, I have full access to lots of developer tools, but projects have the minimal stack of dependencies needed for their functionality.

---

<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:** [June 5, 2023, 5:27pm UTC](https://discourse.julialang.org/t/code-block-only-for-packagecompiler-and-not-for-revise/99870/6 "2023-06-05T17:27:42Z")

</div>

Wow. Thanks for sharing. That’s usually more than I’m willing to put in my global environment. I usually modify my environment stack when I want to use many of those tools.

---

<div class="post-metadata">

**Author:** ![xgdgsc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xgdgsc/32/608_2.png) [@xgdgsc](https://discourse.julialang.org/u/xgdgsc)\
**Post date:** [June 6, 2023, 1:10am UTC](https://discourse.julialang.org/t/code-block-only-for-packagecompiler-and-not-for-revise/99870/7 "2023-06-06T01:10:54Z")

</div>

Thanks. Maybe separating CLI and C call bindings to a separate package and use `dont_watch_pkgs` would work. I would try.
