# Project Specific Startup.jl

**URL:** https://discourse.julialang.org/t/project-specific-startup-jl/101947
**Category:** General Usage
**Tags:** startup, drwatson
**Created:** [July 23, 2023, 3:18am UTC](https://discourse.julialang.org/t/project-specific-startup-jl/101947 "2023-07-23T03:18:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)
#### Post date: [July 23, 2023, 3:18am UTC](https://discourse.julialang.org/t/project-specific-startup-jl/101947/1 "2023-07-23T03:18:14Z")

</div>

Hello,

I am using DrWatson to manage some simulations for an upcoming conference. I am using some locally developed packages that do not include DrWatson in their dependencies.

They create some complicated data structures that I have my own methods defined for saving to file using HDF5.

I want to take advantage of the DrWatson [saving tools](https://juliadynamics.github.io/DrWatson.jl/dev/save/) so I need to overload `_wsave` per the docs. That’s fine - however I’d prefer not to have to do this in every script I create nor do I want to add DrWatson as a dependency to my packages.

I know that I can have methods be created on startup via `./julia/config/startup.jl` however I think(?) that is global. I’d like to confine the definition of these methods to a specific project/environment.

Does that make sense? What is the best method to achieve something like a local `startup.jl` that gets run any time I run Julia in a particular environment?

---

<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: [July 23, 2023, 3:44am UTC](https://discourse.julialang.org/t/project-specific-startup-jl/101947/2 "2023-07-23T03:44:04Z")

</div>

Your startup.jl could look like this:

```julia
const startup_project = Base.active_project()

if startup_project == "/home/mkitti/Project.toml"
    hello_world() = println("Hello World")
elseif startup_project == "/home/mkitti/secret_project/Project.toml"
   # something secret
end

```

This requires you to use `julia --project="folder/containing/a/project/toml"` for this to work.

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [July 23, 2023, 9:02am UTC](https://discourse.julialang.org/t/project-specific-startup-jl/101947/3 "2023-07-23T09:02:09Z")

</div>

> [@mkitti](#):
>
> This requires you to use `julia --project="folder/containing/a/project/toml"` for this to work.

Alternatively, if you use the VS Code extension, that’s done automatically when you start a session in a folder that contains a `Project.toml`.

---

<div class="post-metadata">

### Author: ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)
#### Post date: [July 23, 2023, 9:22am UTC](https://discourse.julialang.org/t/project-specific-startup-jl/101947/4 "2023-07-23T09:22:39Z")

</div>

Expanding on @mkitti’s answer, if you do not want to list all projects in your global `startup.jl` file, you can also make it load per-project `startup.jl` files if they are defined in the project root directory.

E.g put this in `~/.julia/config/startup.jl`

```julia
let startup_project = Base.active_project()
    startup_file = joinpath(dirname(startup_project), "startup.jl")
    if isfile(startup_file)
        @info "Loading Project-specific startup file" path=startup_file
        include(startup_file)
    end
end

```

and add a `startup.jl` file in the root directory of your project (alongside the `Project.toml` file)
