# Project-specific startup.jl file

**URL:** <https://discourse.julialang.org/t/project-specific-startup-jl-file/116933>\
**Category:** General Usage\
**Tags:** pkg\
**Created:** [July 12, 2024, 2:56am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933 "2024-07-12T02:56:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ettersi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ettersi/32/6829_2.png) [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Post date:** [July 12, 2024, 2:56am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933/1 "2024-07-12T02:56:53Z")

</div>

I have many script-style small projects that I frequently need to switch between. Currently, I’m using the following two-step process to “launch” a project:

```julia
> julia --project=path/to/project
julia> includet("path/to/project/startup.jl")
# Now I'm in the state where I want to be: 
# a fresh REPL with `path/to/project/Project.toml` 
# as environment and all the content of `startup.jl`
# preloaded. 

```

Since I have to do this often and often under time pressure (e.g. live demo), it would be really nice if these two steps could be broken down to one. Does Julia have a mechanism for this?

Some options I have considered and why they aren’t quite what I want:

- Launch Julia using

- Add something like this to the global `startup.jl`:

- Activate the correct environment at the beginning of `path/to/project/startup.jl`.  
🙅‍♂️ It’s still a two-step process: I still need to first launch `julia` (now without args), then I need to do `includet("path/to/project/startup.jl")`.

---

<div class="post-metadata">

**Author:** ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)\
**Post date:** [July 12, 2024, 3:50am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933/2 "2024-07-12T03:50:26Z")

</div>

You could make local `startup.jl` files work via code loading in your global `config/startup.jl`

---

<div class="post-metadata">

**Author:** ![ettersi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ettersi/32/6829_2.png) [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Post date:** [July 12, 2024, 3:59am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933/3 "2024-07-12T03:59:20Z")

</div>

> [@tecosaur](#):
>
> You could make local `startup.jl` files work via code loading in your global `config/startup.jl`

That’s this solution, no?

> [@ettersi](#):
>
> Add something like this to the global `startup.jl`:
> 
> ```julia
> using Pkg
> startup_jl = joinpath(Pkg.project().path, "startup.jl")
> if isfile(startup_jl)
> includet(startup_jl)
> end
> 
> ```
> 
> 🙅‍♂️ Not self-contained.

What I mean by “not self-contained” is that I can’t then send my projects to someone else and expect my scripts to behave properly on their machine (without configure their `startup.jl` first).

---

<div class="post-metadata">

**Author:** ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)\
**Post date:** [July 12, 2024, 4:01am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933/4 "2024-07-12T04:01:59Z")

</div>

> [@ettersi](#):
>
> That’s this solution, no?

I don’t think I was clear. I think it’s _the_ solution, and it’s a ultimately good thing that you can’t trivially make a malicious project that executes code just by invoking `julia --project=foo` without loading any files or packages.

What sort of stuff do you have in these per-project `startup.jl`s?

---

<div class="post-metadata">

**Author:** ![PatrickHaecker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/patrickhaecker/32/222891_2.png) [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Post date:** [July 12, 2024, 4:08am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933/5 "2024-07-12T04:08:59Z")

</div>

I think you might be looking for

```julia
julia --project=path/to/project -ie 'include("path/to/project/startup.jl")"'

```

This is the (very) short form of `--interactive -e`.

---

<div class="post-metadata">

**Author:** ![ettersi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ettersi/32/6829_2.png) [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Post date:** [July 12, 2024, 4:22am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933/6 "2024-07-12T04:22:27Z")

</div>

> [@tecosaur](#):
>
> What sort of stuff do you have in these per-project `startup.jl`s?

Small scripts wrapped in functions.

> [@PatrickHaecker](#):
>
> I think you might be looking for
> 
> ```julia-auto
> julia --project=path/to/project -ie 'include("path/to/project/startup.jl")"'
> 
> ```
> 
> This is the (very) short form of `--interactive -e`.

Yup, this will do. Thank you!

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [July 12, 2024, 7:32am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933/7 "2024-07-12T07:32:47Z")

</div>

```julia
julia -L my_script.jl -i

```

---

<div class="post-metadata">

**Author:** ![ettersi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ettersi/32/6829_2.png) [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Post date:** [July 12, 2024, 7:55am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933/8 "2024-07-12T07:55:30Z")

</div>

What does `-f` do? I don’t see it documented in `julia --help`…

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [July 12, 2024, 7:59am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933/9 "2024-07-12T07:59:16Z")

</div>

Sorry, I managed to copy the letter wrong, was supposed to be `L`, not `f`, I edited the post to avoid confusion:

```julia
-L, --load <file>	Load <file> immediately on all processors

```

---

<div class="post-metadata">

**Author:** ![ettersi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ettersi/32/6829_2.png) [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Post date:** [July 12, 2024, 8:49am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933/10 "2024-07-12T08:49:39Z")

</div>

Sweet, that’s technically even better except I assume files loaded with `-l` won’t be `Revise`able?

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [July 12, 2024, 9:56am UTC](https://discourse.julialang.org/t/project-specific-startup-jl-file/116933/11 "2024-07-12T09:56:34Z")

</div>

Personally, I always have a [Makefile](https://github.com/JuliaQuantumControl/QuantumControl.jl/blob/master/Makefile) that organizes development tasks (`make test`, `make docs`). This always includes `make devrepl`, which loads up a customized REPL for interactive testing and working on the documentation.
