install R packages on OS X

210 views
Skip to first unread message

Kirill Vankov

unread,
Jun 16, 2011, 10:44:36 AM6/16/11
to sage-support
I was hoping that new release 4.7 will fix the problem, seeing that
the ticket 5634 has been closed. However, I just tried to install a
new package and got an error message:

=====
Detected SAGE64 flag
Building Sage on OS X in 64-bit mode
----------------------------------------------------------------------
| Sage Version 4.7, Release Date: 2011-05-23 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: r.install_packages('actuar')

R version 2.10.1 (2009-12-14)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> options(repos="http://cran.r-project.org/"); install.packages("actuar")
trying URL 'http://cran.r-project.org/src/contrib/actuar_1.1-2.tar.gz'
Content type 'application/x-gzip' length 1457732 bytes (1.4 Mb)
opened URL
==================================================
downloaded 1.4 Mb

* installing *source* package ‘actuar’ ...
** libs
Warning: R include directory is empty -- perhaps need to install R-
devel.rpm or similar
make: /Users/buildbot/build/sage/bsd-1/bsd_64_binary/build/sage-4.7/
local/lib/R/share/make/shlib.mk: No such file or directory
make: *** No rule to make target `/Users/buildbot/build/sage/bsd-1/
bsd_64_binary/build/sage-4.7/local/lib/R/share/make/shlib.mk'. Stop.
ERROR: compilation failed for package ‘actuar’
* removing ‘/Applications/Sage-4.7-OSX-64bit-10.6.app/Contents/
Resources/sage/local/lib/R/library/actuar’

The downloaded packages are in
‘/private/var/folders/D8/D8+XDdMDEJ4XIybIIPvnt++++TQ/-Tmp-/RtmpZeAJMz/
downloaded_packages’
Updating HTML index of packages in '.Library'
Warning messages:
1: In install.packages("actuar") :
installation of package 'actuar' had non-zero exit status
2: In file.create(f.tg) :
cannot create file '/Users/buildbot/build/sage/bsd-1/bsd_64_binary/
build/sage-4.7/local/lib/R/doc/html/packages.html', reason 'No such
file or directory'
3: In tools:::unix.packages.html(.Library) :
cannot create HTML package index
>

real 0m3.328s
user 0m0.927s
sys 0m0.196s
Please restart Sage in order to use 'actuar'.
sage:
=====

I do not understand, am I missing something on my Mac or the way sage
has been compiled for Mac still does not support R packages
installation?

Regards,
Kirill

kcrisman

unread,
Jun 16, 2011, 11:13:42 AM6/16/11
to sage-support


On Jun 16, 10:44 am, Kirill Vankov <kirill.van...@gmail.com> wrote:
> I was hoping that new release 4.7 will fix the problem, seeing that
> the ticket 5634 has been closed. However, I just tried to install a

The errors reported there were of a different nature, primarily
related to us long ago not having installed the suggested packages in
R.

> new package and got an error message:

That is sad!

> =====
> Detected SAGE64 flag
> Building Sage on OS X in 64-bit mode

Does this happen every time you start Sage? That is odd.


> ----------------------------------------------------------------------
> | Sage Version 4.7, Release Date: 2011-05-23                         |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
> sage: r.install_packages('actuar')
>
> Warning: R include directory is empty -- perhaps need to install R-
> devel.rpm or similar
> make: /Users/buildbot/build/sage/bsd-1/bsd_64_binary/build/sage-4.7/
> local/lib/R/share/make/shlib.mk: No such file or directory
> make: *** No rule to make target `/Users/buildbot/build/sage/bsd-1/
> bsd_64_binary/build/sage-4.7/local/lib/R/share/make/shlib.mk'.  Stop.
> ERROR: compilation failed for package ‘actuar’
> =====
>
> I do not understand, am I missing something on my Mac or the way sage
> has been compiled for Mac still does not support R packages
> installation?
>

Unfortunately, we still have some hard links that are created during
installation of the R package. These are incredibly tricky to track
down. Presumably you have no directories like the ones in

'/Users/buildbot/build/sage/bsd-1/bsd_64_binary/build/sage-4.7/local/
lib/R/doc/html/packages.html'

There are several open tickets to fix this sort of thing, but no one
has been working on them lately - presumably due to not understanding
enough about the issues. Others may have some comments.

The workaround for you is pretty simple, though it will take a few
hours of sleep for it to happen.

1) Download the *source* to Sage, e.g. at http://www.sagemath.org/download-source.html

2) Follow the instructions to build Sage from source. It consists of
going into a certain directory in Terminal and typing "make".

3) Wait a few hours.

4) Now try to install your package!

http://trac.sagemath.org/sage_trac/ticket/8274 is probably where this
should get fixed. I'll put something about this there.


Good luck! I use R optional packages all the time, so I hope it
should work for you if you build from source.

- kcrisman

amaseam

unread,
Jun 16, 2011, 12:12:11 PM6/16/11
to sage-s...@googlegroups.com
On 2011-06-16 kcrisman wrote:

>
> On Jun 16, 10:44 am, Kirill Vankov wrote:
>> Detected SAGE64 flag
>> Building Sage on OS X in 64-bit mode
>
> Does this happen every time you start Sage?  That is odd.

About that, see trac tickets 10303, 11077, 9960:
http://trac.sagemath.org/sage_trac/ticket/10303
http://trac.sagemath.org/sage_trac/ticket/11077
http://trac.sagemath.org/sage_trac/ticket/9960

Kirill Vankov

unread,
Jun 17, 2011, 5:07:43 AM6/17/11
to sage-support
> > Detected SAGE64 flag
> > Building Sage on OS X in 64-bit mode
>
> Does this happen every time you start Sage?  That is odd.

Yes, it does. But I really had never noticed, since usually I start
sage not from terminal

> down.  Presumably you have no directories like the ones in
>
> '/Users/buildbot/build/sage/bsd-1/bsd_64_binary/build/sage-4.7/local/
> lib/R/doc/html/packages.html'

Indeed I have no this type of directories. Moreover, I tried to make
one, but it did not help.

> The workaround for you is pretty simple, though it will take a few
> hours of sleep for it to happen.
>
> 1) Download the *source* to Sage, e.g. athttp://www.sagemath.org/download-source.html
> 2) Follow the instructions to build Sage from source.  It consists of
> going into a certain directory in Terminal and typing "make".
> 3) Wait a few hours.
> 4) Now try to install your package!

I'll try. Thank you for your suggestions.

Kirill

George

unread,
Jun 17, 2011, 6:45:08 AM6/17/11
to sage-support
On 17 June, 06:07, Kirill Vankov <kirill.van...@gmail.com> wrote:
> > > Detected SAGE64 flag
> > > Building Sage on OS X in 64-bit mode
>
> > Does this happen every time you start Sage?  That is odd.
>
> Yes, it does.  But I really had never noticed, since usually I start
> sage not from terminal
>
> > down.  Presumably you have no directories like the ones in
>
> > '/Users/buildbot/build/sage/bsd-1/bsd_64_binary/build/sage-4.7/local/
> > lib/R/doc/html/packages.html'

I also ran into the problem of incorrect directories in R using
sage-4.6.2-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux. R
stores these settings in the following text files:

sage/local/lib/R/bin/R
sage/local/lib/R/bin/libtool
sage/local/lib/R/etc/Makeconf
sage/local/lib/R/etc/ldpath
sage/local/lib/R/etc/Renviron
sage/local/bin/R

so simply replacing the bad paths with the ones that match your
installation worked for me.

The R documentation mentions other ways to override the default
settings of the variables on a per-user basis.

> Indeed I have no this type of directories.  Moreover, I tried to make
> one, but it did not help.
>
> > The workaround for you is pretty simple, though it will take a few
> > hours of sleep for it to happen.
>
> > 1) Download the *source* to Sage, e.g. athttp://www.sagemath.org/download-source.html
> > 2) Follow the instructions to build Sage from source.  It consists of
> > going into a certain directory in Terminal and typing "make".
> > 3) Wait a few hours.
> > 4) Now try to install your package!

Seems like overkill if R is the only package that stores paths a build
time.

kcrisman

unread,
Jun 17, 2011, 11:21:20 AM6/17/11
to sage-support

> > > The workaround for you is pretty simple, though it will take a few
> > > hours of sleep for it to happen.
>
> > > 1) Download the *source* to Sage, e.g. athttp://www.sagemath.org/download-source.html
> > > 2) Follow the instructions to build Sage from source.  It consists of
> > > going into a certain directory in Terminal and typing "make".
> > > 3) Wait a few hours.
> > > 4) Now try to install your package!
>
> Seems like overkill if R is the only package that stores paths a build
> time.
>

You're right, but not everyone understands what 'replacing bad paths'
is - it's a tricky business, at least for me. These are instructions
that don't require a lot of background.

The real problem is that "R's spkg-install is a mess", as one Trac
ticket says. Probably somewhere in there lies the answer to not hard-
coding these things. But it will take a lot of work by someone who
knows R and Sage's build process to fix that. Please feel free to
try! We'd love the help; R is a very important part of Sage which is
underutilized right now.

- kcrisman

Kirill Vankov

unread,
Jun 17, 2011, 1:38:46 PM6/17/11
to sage-support
After four and a half hours of compillation my sage looks good,
even though I received one warning message
"dvipng command 'dvipng' cannot be run (needed for math display),
check the pngmath_dvipng setting"

The R-package installation option works.
Starting sage in terminal do not produce
Detected SAGE64 flag
Building Sage on OS X in 64-bit mode
messages as before.

I still did not kill the sage.app installation and I will try to fix
"bad" paths as well as suggested by George.

Regards,
Kirill

Kirill Vankov

unread,
Jun 20, 2011, 11:49:38 AM6/20/11
to sage-support
Once I moved the compiled sage into /usr/local/ I cannot install
additional R-packages anymore. Have to move it back.

It is better to instruct whoever is going to compile sage on Mac to do
so at the final destination folder.

K.

kcrisman

unread,
Jun 20, 2011, 12:07:35 PM6/20/11
to sage-support


On Jun 20, 11:49 am, Kirill Vankov <kirill.van...@gmail.com> wrote:
> Once I moved the compiled sage into /usr/local/ I cannot install
> additional R-packages anymore.  Have to move it back.

You shouldn't have to move it anywhere; Sage doesn't have to live
anyplace in particular. Is it only after you move it that you
encounter problems? Maybe you have permission issues there?

At any rate, I install new packages fairly frequently in R on my Mac,
so it's important to clarify exactly what makes this break when you
compile Sage from source. Thanks for any additional details you can
provide.

> It is better to instruct whoever is going to compile sage on Mac to do
> so at the final destination folder.

No, because there is no such folder by default - I doubt that many Mac
users would even know what /usr/local is, for instance.
Unfortunately, we will have to actually fix this hardcoding, which is
often a very subtle and difficult thing to track down :(

- kcrisman

Kirill Vankov

unread,
Jun 21, 2011, 9:02:47 AM6/21/11
to sage-support
> You shouldn't have to move it anywhere; Sage doesn't have to live
> anyplace in particular.  Is it only after you move it that you
> encounter problems?    Maybe you have permission issues there?

Yes, the problems were only with R packages and only after I moved
entire sage folder. I did not want it into my temporary downloads
location... The problem was with hard-coded paths, not the
permissions. Anyway, the fix was easy. I opened all the files listed
above by George:

sage/local/lib/R/bin/R
sage/local/lib/R/bin/libtool
sage/local/lib/R/etc/Makeconf
sage/local/lib/R/etc/ldpath
sage/local/lib/R/etc/Renviron
sage/local/bin/R

and edited obvious lines containing hardcoded paths (using find-
replace-all at once). I think it is relatively easy for general
distribution of Sage compiled for Mac write a post-installation script
fixing these lines, in assumption that final destination will be of /
Applications/Sage.app type.

> No, because there is no such folder by default - I doubt that many Mac
> users would even know what /usr/local is, for instance.

Agree, but I have more Linux experience, than Mac. I just started to
work with Mac and do not know how to convert compiled program into
proper .app application, therefore /usr/local/ was a prefered option
for me.

K.
Reply all
Reply to author
Forward
0 new messages