Add packages as root?

356 views
Skip to first unread message

Alasdair McAndrew

unread,
Jan 4, 2014, 8:57:39 PM1/4/14
to julia...@googlegroups.com
I have installed julia (from git, and then compiled) on my Ubuntu 12.04 system - and my initial impressions are very positive.  I installed it in /opt/julia.  However, I'm not sure how to add packages into this directory so that they can be accessed by a normal user.

If I run julia as root, I can download and install packages, but they aren't there when I run julia as myself.

Is there any way of installing packages in a centrally accessible location (like my /opt/julia)?

Thanks!

Spencer Russell

unread,
Jan 4, 2014, 9:43:27 PM1/4/14
to julia...@googlegroups.com
When you install packages they go into ~/.julia, so you can just install them as your normal user.

Or are you looking to install them in one place to be shared between multiple users?

-s

Alasdair McAndrew

unread,
Jan 5, 2014, 6:46:58 AM1/5/14
to julia...@googlegroups.com, s...@mit.edu
I can install packages as myself; that's fine.  I'm just wondering if they can be installed centrally, so as to be available to all users.

John Myles White

unread,
Jan 5, 2014, 11:35:32 AM1/5/14
to julia...@googlegroups.com
I believe there is a Julia environment variable that lets you control where packages will be located, but I can’t seem to recall what it is. If you knew that variable, you could have every user specify in the .juliarc that packages should be loaded from this alternative location.

— John

Elliot Saba

unread,
Jan 5, 2014, 1:19:03 PM1/5/14
to julia...@googlegroups.com

JULIA_PKGDIR is what you are looking for.

AntonSea

unread,
Jan 5, 2014, 2:06:48 PM1/5/14
to julia...@googlegroups.com
It would be great if the manual could present in just one place a list of some of these environment variables

Antonio

Stefan Karpinski

unread,
Jan 5, 2014, 2:49:08 PM1/5/14
to Julia Users
I think that's not really what's being asked for here. Julia looks in JULIA_PKGDIR, which defaults to ~/.julia, but it also looks in the paths in the LOAD_PATH global variable, which on my system defaults to this:

julia> LOAD_PATH
2-element Array{Union(UTF8String,ASCIIString),1}:
 "/Users/stefan/projects/julia/usr/local/share/julia/site/v0.3"
 "/Users/stefan/projects/julia/usr/share/julia/site/v0.3"

If you have a system-installed julia, it should have system directories in LOAD_PATH by default. Thus, you can clone package repos there and they will be found when loading packages. However, the package manager will not do this for you – unless you set JULIA_PKGDIR to one of those directories. So you may want to run julia as root and temporarily set the JULIA_PKGDIR environment variable to one of the default LOAD_PATH entries to use Pkg to install system-wide packages. After that, those packages will be visible but the package manager will consider them to be pre-installed.

Alasdair McAndrew

unread,
Jan 6, 2014, 7:53:43 AM1/6/14
to julia...@googlegroups.com
Yes, my LOAD_PATH gives very similar results.  Following some other threads the commands (within Julia run as root):

ENV["JULIA_PKGDIR"] = "/opt/julia/usr/share/julia/site/v0.3"
Pkg.init()

followed by a few Pkg.add's, did the trick.  However, Pkg.installed() (as a user, not root) shows nothing, because the packages aren't in the user directory.  As a user, I have to set JULIA_PKGDIR as for root, for the packages to show up.

This is all good - thank you very much!

-Alasdair

Alasdair McAndrew

unread,
Jan 6, 2014, 7:59:13 AM1/6/14
to julia...@googlegroups.com

Maurice Diamantini

unread,
Apr 19, 2016, 11:22:38 AM4/19/16
to julia-users
Hi,

Since two years have passed since the original question, is there now a standard way to install some packages for them to be available for all the users?
If not wat is the actuel hack to do that?

Thank you very much,
-- Maurice
 

Yichao Yu

unread,
Apr 19, 2016, 12:04:09 PM4/19/16
to Julia Users
On Tue, Apr 19, 2016 at 11:22 AM, Maurice Diamantini
<maurice.d...@gmail.com> wrote:
> Hi,
>
> Since two years have passed since the original question, is there now a
> standard way to install some packages for them to be available for all the
> users?
> If not wat is the actuel hack to do that?

You can install into `LOAD_PATH`. `Pkg` operations are still not well
supported though (even the read-only ones)

Maurice Diamantini

unread,
Apr 20, 2016, 5:13:35 AM4/20/16
to julia-users
Thank you very much, I'll do that.
But I hope there will be a better way to do that before the 1.0 Julia version!
-- Maurice
Reply all
Reply to author
Forward
0 new messages