How to import a package at startup in Julia REPL, if available

I would like to import the package anytime when I run REPL. Inclusion ~/.juliarc.jlat the beginning:

if isinteractive()
    using Humanize
end

But if I run juliaon a machine without this package, REPL does not start.

So, I tried the following:

if isinteractive()
    try
        using Humanize
    catch
    end
end

but due to the rules of definition Julia is now Humanizenot even available in the global namespace.

What is the best solution?

+4
source share
1 answer

Try the following: a hack bit until something better appears in the database:

humanize_exists = isdir(Pkg.dir("Humanize"))
if humanize_exists && isinteractive(); using Humanize; end
+3
source

All Articles