How do I reload a module in an active Julia session after an edit?

后端 未结 5 1355
青春惊慌失措
青春惊慌失措 2020-12-04 16:07

2018 Update: Be sure to check all the responses, as the answer to this question has changed multiple times over the years. At the time of this update, the <

5条回答
  •  粉色の甜心
    2020-12-04 16:48

    I wanted to create a new module from scratch, and tried the different answers with 1.0 and didn’t get a satisfactory result, but I found the following worked for me:

    From the Julia REPL in the directory I want to use for my project I run

    pkg> generate MyModule
    

    This creates a subdirectory like the following structure:

    MyModule
    ├── Project.toml
    └── src
        └── MyModule.jl
    

    I put my module code in MyModule.jl. I change to the directory MyModule (or open it in my IDE) and add a file Scratch.jl with the following code:

    Pkg.activate(“.”)
    using Revise
    import MyModule
    

    Then I can add my code to test below and everything updates without reloading the REPL.

提交回复
热议问题