# Is this a good workflow with Julia environment?

**URL:** <https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 26, 2023, 2:59pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848 "2023-06-26T14:59:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [June 26, 2023, 2:59pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/1 "2023-06-26T14:59:04Z")

</div>

Will the following be a good workflow with Julia environment? Is there any bug in it? Or is there anything better to do?

The workflow:

1. Create a folder named `myProject` for a certain project.
2. Open folder `myProject` with VS Code.
3. Start Julia REPL in VS Code.
4. Under package management mode, type `activate .` to set up a Julia environment `myProject`.
5. Add some necessary packages in the environment `myProject`.
6. Create some `.jl` files in folder `myProject` to realize the function of the project.

---

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [June 26, 2023, 3:04pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/2 "2023-06-26T15:04:33Z")

</div>

Looks fine to me! Ofc this is not a package. For faster development, you will benefit greatly to use, i.e. load, `Revise.jl` in the REPL. If you want something more complicated and streamlined have a look at `DrWatson.jl`.

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [June 26, 2023, 3:09pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/3 "2023-06-26T15:09:28Z")

</div>

Thank you for your affirmation! 🤝 😃

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 26, 2023, 3:28pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/4 "2023-06-26T15:28:49Z")

</div>

For people stumbling on this in the future: we’re working on teaching this in a better way

[https://gdalle.github.io/ModernJuliaWorkflows/](https://gdalle.github.io/ModernJuliaWorkflows/)

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [June 26, 2023, 3:31pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/5 "2023-06-26T15:31:18Z")

</div>

Very nice! Thanks! 🤝 🤝

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [June 26, 2023, 3:47pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/6 "2023-06-26T15:47:03Z")

</div>

Note that creating a package with a full structure is not much harder: [Create new package · JuliaNotes.jl](https://m3g.github.io/JuliaNotes.jl/stable/new_package/#How-to-create-a-new-package)

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [June 26, 2023, 3:50pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/7 "2023-06-26T15:50:24Z")

</div>

Thanks! I’ll read that.

---

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [June 26, 2023, 3:52pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/8 "2023-06-26T15:52:15Z")

</div>

I would add that your functions should go in a different file than the scripts that call them. Why? Because it makes calling the functions more convenient, flexible, and efficient. If you put the function definitions in the same file as the script that calls them, then each time you `include` the script, the functions will have to be recompiled. But If, instead, you execute

```julia
using Revise

```

followed by

```julia
includet("my_functions.jl")

```

(Notice the “t” at the end of the `includet` function), where “my\_functions.jl” contains all your function definitions, then any edits you make to the function definitions are instantly and automatically sensed by Julia so that you are ready to run (or re-run) any scripts that depend on them. Note that the `includet` function only need be run once per Julia session in that project.

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [June 26, 2023, 3:54pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/9 "2023-06-26T15:54:10Z")

</div>

> [@WuSiren](#):
>
> The workflow:
> 
> 1. Create a folder named `myProject` for a certain project.
> 2. Open folder `myProject` with VS Code.
> 3. Start Julia REPL in VS Code.
> 4. Under package management mode, type `activate .` to set up a Julia environment `myProject`.
> 5. Add some necessary packages in the environment `myProject`.
> 6. Create some `.jl` files in folder `myProject` to realize the function of the project.

But I found that in this way I could no longer click to choose the environment in the VS Code’s status bar successfully. It tells “You opened a Julia package that is not part of your current environment. Do you want to activate a different environment?”

> [@What is a "shared environment"? When should I use a "shared environment"?](https://discourse.julialang.org/t/what-is-a-shared-environment-when-should-i-use-a-shared-environment/100828/12):
>
> In VSCode, in the bottom right, you can click to choose the environment.

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [June 26, 2023, 4:28pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/10 "2023-06-26T16:28:28Z")

</div>

Yes, I’m aware of this. Thanks!

But must I execute `using Revise` strictly after activating the project? I have added `using Revise ` to `~/.julia/config/startup.jl` to make sure `Revise` to be loaded on the Julia REPL startup. Maybe at that timepoint, the activated environment is still `@v1.x`.

---

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [June 26, 2023, 5:28pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/11 "2023-06-26T17:28:43Z")

</div>

> [@WuSiren](#):
>
> I have added `using Revise ` to `~/.julia/config/startup.jl` to make sure `Revise` to be loaded on the Julia REPL startup.

Perfect! Using `Revise` any time prior to the `includet` is all that is necessary.

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [June 27, 2023, 4:40am UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/12 "2023-06-27T04:40:52Z")

</div>

[Here](https://www.julia-vscode.org/docs/stable/userguide/env/#Julia-Environments) has mentioned this issue. But I can’t switch environments by the “Julia env” button successfully. Don’t know why.

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [June 27, 2023, 2:47pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/13 "2023-06-27T14:47:34Z")

</div>

Maybe showing us your file structure will help.

From what I can tell, your proposed workflow should not require an environment change. When you open `myProject` folder in VSCode, it should automatically switch to the environment `myProject` (defined by the `project.toml` file there). Then all your `.jl` files inside the `myProject` folder can also work with that environment. Check that you don’t have an extra `project.toml` somewhere in the structure and that `pwd()` in the REPL returns the `myProject` folder.

If you instead want to call your `myProject` functions from `.jl` files that live outside of that folder, then you will want to make `myProject` a package. (I believe all that would require is making a file `myProject/src/myProject.jl`. I don’t think you need to deal with git and Github.) Then you would make a new environment where the external `.jl` files live, and use `dev "path/to/myProject"` in that external environment.

> **myProject.jl**
>
> ```julia
> module myProject
> using PackageA, PackageB
> export functionX, functionY
> include("FileWithFunctionDefinitions.jl")
> end
> 
> ```

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 27, 2023, 9:29pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/14 "2023-06-27T21:29:29Z")

</div>

You can but you need to restart the VSCode REPL

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [June 28, 2023, 2:10pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/15 "2023-06-28T14:10:11Z")

</div>

Yes. Thanks!

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [June 28, 2023, 2:10pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/16 "2023-06-28T14:10:34Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Post date:** [June 28, 2023, 2:29pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/17 "2023-06-28T14:29:08Z")

</div>

You might find my comment [here](https://discourse.julialang.org/t/what-is-in-your-startup-jl/18228/31), and the two comments below useful. It assumes that you have already created a project folder containing some main `.jl` file, which you have opened in VScode.  
All of my projects start with these lines of code. Note that it does not matter if you start a project for the first time, or if you resume to it.

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [June 28, 2023, 2:40pm UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/18 "2023-06-28T14:40:58Z")

</div>

It’s worth learning. Thanks!

---

<div class="post-metadata">

**Author:** ![generic-user](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/generic-user/32/211923_2.png) [@generic-user](https://discourse.julialang.org/u/generic-user)\
**Post date:** [September 12, 2024, 8:02am UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/19 "2024-09-12T08:02:09Z")

</div>

> [https://gdalle.github.io/ModernJuliaWorkflows/](https://gdalle.github.io/ModernJuliaWorkflows/)

Hello, this link is not working anymore.

---

<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:** [September 12, 2024, 8:04am UTC](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848/20 "2024-09-12T08:04:37Z")

</div>

[https://modernjuliaworkflows.github.io/](https://modernjuliaworkflows.github.io/)

[Next page](https://discourse.julialang.org/t/is-this-a-good-workflow-with-julia-environment/100848.md?page=2)
