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. The steps defined in the Official instruction 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
mv julia-1.7.2 $XDG_DATA_HOME
The julia’s documentation ask me to define the path to
bin/ dir as an env variable
$JULIA_BINDIR. To do so, I defined in
# 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
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
$XDG_CONFIG_HOME, respectively, which matches with the XDG Base Directory Specifications. So I added in my
.profile the following env. variables:
# 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"
$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
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
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.