Adding single-file Julia module to path in v1.0

I have a single-file module which I would like to add to my loading path. Previously in Julia 0.6, I had this in my ~/.bashrc:

if [ -n "$JULIA_LOAD_PATH" ]; then
    export JULIA_LOAD_PATH=$MODULEPATH:${JULIA_LOAD_PATH}
else
    export JULIA_LOAD_PATH=$MODULEPATH
fi

If I do this in Julia 1.0, I cannot load any other modules, and Julia interprets this path as the path containing all modules, which is not what I want. So far, no matter what I try I have not managed to be able to load both my module and Base modules simply by altering an environment variable.

Any ideas?

It’s unrelated to “single-file julia module”.

Sorry, could you dumb it down for me? I have seen that answer and I still don’t understand how I can fix the behavior to work in 1.0.

The issue is that the default path is overwritten.
You need to tell julia that you still want the default.
You do this by putting “an empty entry in LOAD_PATH” (actually JULIA_LOAD_PATH).
Entries are separated by : so just make sure you have an : at the beginning or end or a :: in the middle.

1 Like

So I should just do this, right?

if [ -n "$JULIA_LOAD_PATH" ]; then
    export JULIA_LOAD_PATH=$MODULEPATH:${JULIA_LOAD_PATH}:
else
    export JULIA_LOAD_PATH=$MODULEPATH:
fi

This seems to work!

Both branches do the same thing, which is why the empty path expansion works the way it does. In other words you can just do:

export JULIA_LOAD_PATH=“$MODULEPATH:$JULIA_LOAD_PATH”

If JULIA_LOAD_PATH is already set it will get spliced in, if not then the default load path will get spliced in.

3 Likes