# Can \`startup.jl\` set different startup options for different Julia installations?

**URL:** <https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507>\
**Category:** General Usage\
**Tags:** question, startup, versions\
**Created:** [January 31, 2024, 11:34am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507 "2024-01-31T11:34:15Z")\
**Posts on this page:** 18\
**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:** [January 31, 2024, 11:34am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/1 "2024-01-31T11:34:15Z")

</div>

Two different versions of Julia are installed on Linux but there is only one `~/.julia/config/startup.jl`. I want to set different startup options for the two versions, can I? And how?

Thanks!

---

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [January 31, 2024, 11:36am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/2 "2024-01-31T11:36:16Z")

</div>

I think you can check the `VERSION` constant, according to [Strings · The Julia Language](https://docs.julialang.org/en/v1/manual/strings/#man-version-number-literals) you can do stuff like

```julia
if v"0.2" <= VERSION < v"0.3-"
    # do something specific to 0.2 release series
end

```

---

<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:** [January 31, 2024, 11:38am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/3 "2024-01-31T11:38:23Z")

</div>

Oh I see… Thanks a lot! 🤝 🤝

---

<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:** [January 31, 2024, 11:53am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/4 "2024-01-31T11:53:25Z")

</div>

Can I set different startup commands for different versions of Julia (or Julia in different installation directories)? And set different startup options according to the startup commands?

For example, I have two different Julia installations in `~/Julia1/` and `~/Julia2/` and they have different versions or the same version (can they?), and I want to start the Julia in `~/Julia1/` with command `julia1` and `julia2` for the other and let them load different startup options, can I?

---

<div class="post-metadata">

**Author:** ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)\
**Post date:** [January 31, 2024, 12:10pm UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/5 "2024-01-31T12:10:31Z")

</div>

Perhaps you want to set `JULIA_DEPOT_PATH` for the different installations, or for different versions?

The discussion [here](https://discourse.julialang.org/t/julia-depot-path-and-julia-project/73745/) appears to be related, but I don’t know whether it’s relevant.

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [January 31, 2024, 4:40pm UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/6 "2024-01-31T16:40:21Z")

</div>

If you want to manage multiple Julia versions I’d strongly recommend JuliaUp: [GitHub - JuliaLang/juliaup: Julia installer and version multiplexer](https://github.com/JuliaLang/juliaup)

Then you can do `julia +1.8` etc to run a specific version.

---

<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:** [January 31, 2024, 8:42pm UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/7 "2024-01-31T20:42:20Z")

</div>

> [@WuSiren](#):
>
> I have two different Julia installations in `~/Julia1/` and `~/Julia2/` and they have different versions or the same version (can they?), and I want to start the Julia in `~/Julia1/` with command `julia1` and `julia2` for the other and let them load different startup options, can I?

You can use a symbolic link or shell alias to use the desired name for invoking a particular Julia installation. Inside your startup.jl file you can use `Base.julia_cmd()[1]` to determine which one was invoked and conditionally execute different statements.

---

<div class="post-metadata">

**Author:** ![mnemnion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mnemnion/32/206596_2.png) [@mnemnion](https://discourse.julialang.org/u/mnemnion)\
**Post date:** [January 31, 2024, 8:48pm UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/8 "2024-01-31T20:48:51Z")

</div>

There’s no need to make symlinks, the output of `Base.julia_cmd()` includes the full path, so you could do this sort of conditional:

```julia
if occursin("/Julia1/", Base.julia_cmd()
   # Do your Julia1 stuff here 
elseif occursin("/Julia2", Base.julia_cmd()
   # Do your Julia2 stuff here 
end

```

Note that searching for `~/Julia1/` won’t work because the path is fully qualified, it won’t contain the shortcut `~` but rather the full name of the user directory.

---

<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:** [January 31, 2024, 11:57pm UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/9 "2024-01-31T23:57:48Z")

</div>

> [@mnemnion](#):
>
> There’s no need to make symlinks

Did you read the full request? Specifically:

> [@WuSiren](#):
>
> I want to start the Julia in `~/Julia1/` with command `julia1` and `julia2` for the other…

He wants to use commands other than “`julia`” to launch Julia.

---

<div class="post-metadata">

**Author:** ![mnemnion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mnemnion/32/206596_2.png) [@mnemnion](https://discourse.julialang.org/u/mnemnion)\
**Post date:** [February 1, 2024, 12:22am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/10 "2024-02-01T00:22:50Z")

</div>

> [@PeterSimon](#):
>
> He wants to use commands other than “`julia`” to launch Julia.

This is readily accomplished by naming the binaries `julia1` and `julia2`.

---

<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:** [February 1, 2024, 12:31am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/11 "2024-02-01T00:31:19Z")

</div>

Based on the following information provided by the author of juliaup, it seems to be to be inadvisable to change the name of a file installed by juliaup:

> [@Why does juliaup delete the old versions?](https://discourse.julialang.org/t/why-does-juliaup-delete-the-old-versions/108193/5):
>
> in general with Juliaup you should consider everything inside the `~/.julia/juliaup` folder as managed by Juliaup and you should not modify anything there by hand

---

<div class="post-metadata">

**Author:** ![mnemnion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mnemnion/32/206596_2.png) [@mnemnion](https://discourse.julialang.org/u/mnemnion)\
**Post date:** [February 1, 2024, 12:57am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/12 "2024-02-01T00:57:35Z")

</div>

It’s generally inadvisable to go changing the layout and names of files in a directory managed by another program, yes.

But this does not apply to a copy of the Julia binary stored in, as the original post indicates, `~/Julia1/` and `~/Julia2/`, those can be named whatever one wishes. `julia1` and `julia2`, for example.

---

<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:** [February 1, 2024, 1:11am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/13 "2024-02-01T01:11:56Z")

</div>

You’re right. But if the OP takes the good advice offered earlier in this thread and uses juliaup to manage his future installs, then he should be aware that renaming those executables is not a good idea.

---

<div class="post-metadata">

**Author:** ![mnemnion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mnemnion/32/206596_2.png) [@mnemnion](https://discourse.julialang.org/u/mnemnion)\
**Post date:** [February 1, 2024, 1:25am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/14 "2024-02-01T01:25:11Z")

</div>

It’s worth knowing that `juliaup` uses some indirection to manage versions, and that the actual binaries are found in `~/.julia/juliaup/$VERSION/bin`. Those can be symlinked or copied. Symlinks to `~/.juliaup/bin/julia` won’t work, because there’s a JSON file in `~/.juliaup` which the actual binary in question relies on to launch the currently-configured version of Julia.

So to OP: `juliaup` is the best way to manage multiple versions of Julia, and if you want to put different versions in different directories, you can find them in the directory above. If you do symlink them, `Base.julia_cmd()` will show the actual binary path, so if you want to put logic in `startup.jl` which depends on the directory of the binary, you can either write that based on the directory where you find them, or copy the binaries into your directory, both will work.

---

<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:** [February 1, 2024, 3:28am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/15 "2024-02-01T03:28:20Z")

</div>

@PeterSimon @mnemnion :

Great! That’s exactly what I want! Thank you and everyone here for your kind help! Your answers are eye-opening! 😃 🤝 🤝 🤝

---

<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:** [February 1, 2024, 3:32am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/16 "2024-02-01T03:32:53Z")

</div>

I still have a small question: will it be legal if I have two Julia installations with the same version but in different directories?

---

<div class="post-metadata">

**Author:** ![mnemnion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mnemnion/32/206596_2.png) [@mnemnion](https://discourse.julialang.org/u/mnemnion)\
**Post date:** [February 1, 2024, 3:38am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/17 "2024-02-01T03:38:22Z")

</div>

> [@WuSiren](#):
>
> will it be legal if I have two Julia installations with the same version but in different directories?

This should be no problem, they will use the same packages, which should be ok: you can still configure any given environment to use different versions of a package, it’s just that the compiled caches will be shared on a per-version basis. I can’t imagine that will cause you problems.

---

<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:** [February 1, 2024, 3:41am UTC](https://discourse.julialang.org/t/can-startup-jl-set-different-startup-options-for-different-julia-installations/109507/18 "2024-02-01T03:41:01Z")

</div>

I see! Thanks a lot! 🤝 🤝
