# Revise with Requires?

**URL:** <https://discourse.julialang.org/t/revise-with-requires/19347>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 7, 2019, 9:58am UTC](https://discourse.julialang.org/t/revise-with-requires/19347 "2019-01-07T09:58:07Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [January 7, 2019, 9:58am UTC](https://discourse.julialang.org/t/revise-with-requires/19347/1 "2019-01-07T09:58:07Z")

</div>

Is there a way of getting Revise working on files included with Requires? My experience is files included in a @require block don’t get updated with Revise.

---

<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:** [January 7, 2019, 10:36am UTC](https://discourse.julialang.org/t/revise-with-requires/19347/2 "2019-01-07T10:36:09Z")

</div>

If you can put together a simple demo that I can copy/paste and reproduce the issue, there’s a chance this is fixable.

---

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [January 7, 2019, 11:34am UTC](https://discourse.julialang.org/t/revise-with-requires/19347/3 "2019-01-07T11:34:32Z")

</div>

Seeing this involves file loading I made a test [package](https://github.com/rafaqz/ReviseTest.jl). Load with this script:

```julia
]dev https://github.com/rafaqz/ReviseTest.jl
using Revise
using ReviseTest
using Images # trigger the @require block

julia> testfunc()
1

# Then change the output of testfunc() in YOURDEVFOLDER/ReviseTest/src/testfile.jl
julia> testfunc()
1

# It should still return 1...

```

---

<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:** [January 8, 2019, 3:48pm UTC](https://discourse.julialang.org/t/revise-with-requires/19347/4 "2019-01-08T15:48:19Z")

</div>

There’s a potential solution [here](https://github.com/timholy/Revise.jl/pull/232). Comments, testing, and/or help figuring out why it doesn’t work on Windows would be appreciated.

---

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [January 8, 2019, 11:40pm UTC](https://discourse.julialang.org/t/revise-with-requires/19347/5 "2019-01-08T23:40:14Z")

</div>

Thanks! That works perfectly on linux. Sorry I can’t test on windows.

The only issue is `@require` blocks are getting awfully long, and not really DRY. It would be great if Requires could notify Revise automatically of new files, but I understand the performance issue is probably more important.

---

<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:** [December 12, 2019, 9:00am UTC](https://discourse.julialang.org/t/revise-with-requires/19347/6 "2019-12-12T09:00:15Z")

</div>

This now works if you use Requires 1.x and Revise 2.4.

It is likely that many packages need to bump their `[compat]` for Requires 1.x.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [December 12, 2019, 10:16am UTC](https://discourse.julialang.org/t/revise-with-requires/19347/7 "2019-12-12T10:16:20Z")

</div>

@tim.holy thank you for the update. This is an issue that always affected my development workflow. I wonder if this Requires.jl + Revise.jl combination could be made part of the language? That is, users wouldn’t need to use the packages explicitly in their projects, and the macro `@require` would be exported by default from some stdlib.

Requires.jl, Requires.jl, OhMyREPL.jl, TestSetExtensions.jl and other packages are so useful in day-to-day Julia programming, they improve user experience by a lot in my opinion.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [December 12, 2019, 11:23am UTC](https://discourse.julialang.org/t/revise-with-requires/19347/8 "2019-12-12T11:23:13Z")

</div>

I am assuming you are suggesting that these packages are bundled as standard libraries? Just note that Revise.jl _alone_ had 5 releases in the past 30 days, while Julia (with the standard libraries) is released roughly 2-3 times a year.

Just `pkg> add`ing these is not that much of a hassle; from then on the user experience is the same.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [December 12, 2019, 12:00pm UTC](https://discourse.julialang.org/t/revise-with-requires/19347/9 "2019-12-12T12:00:44Z")

</div>

No, I’m suggesting that users can just develop their packages with a simple @require macro in their **init** function. The automatic recompilation of Revise.jl would be built-in and no need for adding the packages as dependencies in Project.toml etc.

Imagine that you’re are newcomer, there is a lot to grasp just to develop a package with optional dependencies and automatic recompilation.

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [December 12, 2019, 12:05pm UTC](https://discourse.julialang.org/t/revise-with-requires/19347/10 "2019-12-12T12:05:00Z")

</div>

There is a Pkg issue for conditional dependencies with a proposal and discussions: [https://github.com/JuliaLang/Pkg.jl/issues/1285](https://github.com/JuliaLang/Pkg.jl/issues/1285), which looks like a better way to do it than requires and more likely to make it in to a standard library (Pkg).

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [December 12, 2019, 12:23pm UTC](https://discourse.julialang.org/t/revise-with-requires/19347/11 "2019-12-12T12:23:24Z")

</div>

I am sorry, but I don’t understand what you are proposing. Are you talking about ` __init__ ()`? How is it related to Revise.jl?

The functionality provided by Revise.jl is not tied to packages, or even modules, and is orthogonal to optimal dependencies. It’s just that in practice it was not working until recent updates.

Hopefully optional dependencies will just be managed by the loader at some point so package developers will not have to use these hacks, and Revise.jl will just continue to provide a great, but essentially independent convenience feature.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [December 12, 2019, 12:47pm UTC](https://discourse.julialang.org/t/revise-with-requires/19347/12 "2019-12-12T12:47:52Z")

</div>

I thought my comment was clear, but I will try to rephrase it for you to follow.

Imagine you are a newcomer and you have no idea about Revise.jl Requires.jl. now you simply want to start coding your package with optional dependencies, interactively changing the code, and running scripts to test. What do you do? Well, this should just work the newcomer thinks. What is the current reality though? Oh I need to add Requires.jl to my Project.toml, I need to import it in the module. I then need to edit my **init** function to add a call with @require, oops but that needs a hash code that I need to lookup somewhere. Ok found it. Now let’s try to rerun the test script. Oops it didn’t update. I need to import Revise.jl in my test script… is it clear the issue? Do you agree this experience isn’t the smoothest?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [December 12, 2019, 12:48pm UTC](https://discourse.julialang.org/t/revise-with-requires/19347/13 "2019-12-12T12:48:36Z")

</div>

I agree that optional dependencies could be handled on the Pkg side. That would make life easier.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [December 12, 2019, 12:51pm UTC](https://discourse.julialang.org/t/revise-with-requires/19347/14 "2019-12-12T12:51:44Z")

</div>

The runtime loading of code that Requires does has some issues (no precompilation and not easy to do “static compilation”). I think an “official” conditional dependency strategy need to solve those problems.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [December 12, 2019, 1:11pm UTC](https://discourse.julialang.org/t/revise-with-requires/19347/15 "2019-12-12T13:11:26Z")

</div>

There are many things to unpack here.

First, while I agree that everything should be as smooth as possible, I don’t think that the notion of code activated by optional dependencies is such a standard or widespread feature as you imply — not all languages have something similar built-in. It is certainly useful, but I don’t think that it’s something newbies should or will start with. Indeed the whole thing could be smoother, but it is just one of the many minor annoyances that are in the process of being improved.

Second, that “hash code” (the package UUID) will remain an essential part of the process, and has to be specified like in other contexts — see [one of the recent proposals](https://github.com/JuliaLang/Pkg.jl/issues/1285#issuecomment-544677191). Tooling of course can make it easier to manage when unambiguous (like `pkg> add` does now).

Third (and sorry to keep repeating this) Revise.jl is a convenience feature _conceptually_ unrelated to conditional code loading. Of course the implementation isn’t, but now that it works smoothly it is not something that affects users.

Finally, Requires.jl is essentially very clever hack, and everyone agrees that a mechanism like this should be supported by the loader directly. It is very likely to be part of the language in the medium run, once the details are hammered out.
