# Creating decent julia's environment variable paths on UNIX-like system using XDG specs to avoid ~/.julia

**URL:** <https://discourse.julialang.org/t/creating-decent-julias-environment-variable-paths-on-unix-like-system-using-xdg-specs-to-avoid-julia/83276>\
**Category:** New to Julia\
**Tags:** installation, path\
**Created:** [June 23, 2022, 7:46pm UTC](https://discourse.julialang.org/t/creating-decent-julias-environment-variable-paths-on-unix-like-system-using-xdg-specs-to-avoid-julia/83276 "2022-06-23T19:46:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tapyu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tapyu/32/37182_2.png) [@tapyu](https://discourse.julialang.org/u/tapyu)\
**Post date:** [June 23, 2022, 7:46pm UTC](https://discourse.julialang.org/t/creating-decent-julias-environment-variable-paths-on-unix-like-system-using-xdg-specs-to-avoid-julia/83276/1 "2022-06-23T19:46:52Z")

</div>

As a brand-new `julia` programmer, I am striving to tidy up my `$HOME` dir in order to avoid bloating it up with a tons of dotfiles, and at same time, define sane paths to `julia` using [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html). The steps defined in the [Official instruction](https://julialang.org/downloads/platform/#running_julia) will generate the dir `~/.julia`, which is rather unpleasant… So I am trying a way out to this problem following sane UNIX path definitions.

After reading the `julia`’s environment variables and some discussions about it, I bite the bullet and tried to organize it in the following way (probably not the most optimized, so help me):

Firstly, I decided to put the extracted `julia/` directory inside `$XDG_DATA_HOME` as it is user-specific data files, right? So a ran

```julia
mv julia-1.7.2 $XDG_DATA_HOME

```

The julia’s documentation ask me to define the path to `julia`’s `bin/` dir as an env variable `$JULIA_BINDIR`. To do so, I defined in `~/.profile`:

```shell
# The absolute path of the directory containing the Julia executable -> ~/.local/share/julia-1.7.2/bin
export JULIA_BINDIR="$XDG_DATA_HOME/julia-1.7.2/bin"

```

The documentation also ask me to put the `julia` bin in the `$PATH`. Hence, I symlink

```shell
ln -s $XDG_DATA_HOME/julia-1.7.2/bin/julia ~/.local/bin/julia

```

because User-specific executable files shall be stored in `$HOME/.local/bin`. This resolve the problem of putting the `julia` into the `$PATH` as long as `~/.local/bin` is in it.

I would also like to put the data and config file of `julia` into `$XDG_DATA_HOME` and `$XDG_CONFIG_HOME`, respectively, which matches with the XDG Base Directory Specifications. So I added in my `.profile` the following env. variables:

```shell
# relative julia's data directory -> $JULIA_BINDIR/$DATAROOTDIR/julia/base -> ~/.local/share/julia/base
export DATAROOTDIR="../.."
# relative julia's config files -> $JULIA_BINDIR/$SYSCONFDIR/julia/startup.jl -> ~/.config/julia/startup.jl
export SYSCONFDIR="../../../../.config"

```

Both `$DATAROOTDIR` and `$SYSCONFDIR` are relative paths to the data directory and configuration file directory, respectively. With these environment variables, I am pointing the data dir at `$XDG_DATA_HOME/julia` and the config dir at `$XDG_CONFIG_HOME/julia`. To have such directories in theses paths, I symlinked again

```shell
ln -s $XDG_DATA_HOME/julia-1.7.2/share/julia $XDG_DATA_HOME/julia
ln -s $XDG_DATA_HOME/julia-1.7.2/etc/julia $XDG_CONFIG_HOME/julia

```

Moreover, I put the Julia history into `$XDG_STATE_HOME` as that path should be used to store “logs, history, recently used files”, but I barely see UNIX users using this dir. I just added to `.profile` the following line

```shell
export JULIA_HISTORY="$XDG_STATE_HOME/julia"

```

At moment, when I open up `julia` on terminal in REPL mode, my computer does not generate `~/.julia/` (thanks God), but I bet my way have flaws, so any contribution is welcome.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [June 23, 2022, 7:53pm UTC](https://discourse.julialang.org/t/creating-decent-julias-environment-variable-paths-on-unix-like-system-using-xdg-specs-to-avoid-julia/83276/2 "2022-06-23T19:53:09Z")

</div>

I agree using XDG would be nice, but there has been a long discussion with good points made against its use here: [Store settings and packages in XDG directories instead of ~/.julia · Issue #4630 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/4630)

I think the most productive way to engage this conversation would be at that github issue. I view it as something that does not have much of a chance of happening (a bit of a tragedy of the commons).

EDIT: To be fair, your goal is slightly different. It is not about making the default be XDG, but rather about making it possible to configure the use of XDG. That is probably something you would have much more success with.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [September 28, 2022, 4:39pm UTC](https://discourse.julialang.org/t/creating-decent-julias-environment-variable-paths-on-unix-like-system-using-xdg-specs-to-avoid-julia/83276/3 "2022-09-28T16:39:54Z")

</div>

The status of that issue is that there is willingness to support opting into XDG. There’s even a plan for where the different kinds of data should go. The only thing lacking is for someone to actually implement the plan and make a pull request. The overlap between people who want Julia to support XDG and people who are willing/able to implement that support appears to be the empty set.
