Skip to content

Problem with R-2.1.0: install.packages() doesn't work

14 messages · Waichler, Scott R, Roger D. Peng, Uwe Ligges +4 more

#
I installed R-2.1.0 from source on a Linux box running Red Hat
Enterprise Linux WS release 4 but install.packages() wouldn't work (see
below).  When I install R-2.0.1 from RPM on the same system, everything
is fine.

Version 2.1.0  (2005-04-18), ISBN 3-900051-07-0
. . .
--- Please select a CRAN mirror for use in this session ---
Error in inherits(x, "factor") : Object "res" not found
Scott Waichler
Pacific Northwest National Laboratory
scott.waichler at pnl.gov
#
What happens if you don't set the 'CRAN' option via 'options()' 
first and just run 'install.packages()'?

-roger
Waichler, Scott R wrote:
#
Waichler, Scott R wrote:

            
options(CRAN = ...) is outdated. See ?options.
Quite probably you have no X11 connection to this machine.
R tries to ask you which CRAN mirror you are going to choose, and it 
fails to present the tcltk window.
You might want to call
   chooseCRANmirror(graphics=FALSE)
and
   setRepositories(graphics=FALSE)
prior to install.packages().

Uwe Ligges
#
Roger D. Peng wrote:

            
Should be the same as long as no CRAN mirror has been choosen and X11 is 
not accessible (see my other message). The code needs to be a bit more 
defensive here - or present a better error message.

Uwe Ligges
#
On Fri, 2005-04-22 at 17:48 +0200, Uwe Ligges wrote:
I have the same problem after building R-2.1.0 from source on Fedora
Core 3. The suggestion above fixes this, but what do you mean by "Quite
probably you have no X11 connection on this machine"? I'm guessing you
don't mean that X11 is not "running" (I use Gnome for my desktop).

Manuel
#
On Fri, 2005-04-22 at 15:44 -0400, Manuel Morales wrote:
For both Scott and Manuel,

Can you post back with the output of:
It should look something like:
jpeg      png    tcltk      X11 http/ftp  sockets   libxml     fifo
    TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE
  cledit  IEEE754    iconv
    TRUE     TRUE     TRUE


Pay attention specifically to the values under 'tcltk' and 'X11'. Having
built from source tarballs, I am wondering if something got borked in
the build of the tcltk package or you don't have the X11 (xorg) devel
RPMS installed.

If the latter problem (X11) is the issue, you should not be able to
create any plots to the screen either so try:
and see if a graphic window comes up.


Marc Schwartz
#
Manuel Morales <Manuel.A.Morales at williams.edu> writes:
Gnome runs on top of X11, so that's not possible. However, if you're
running remotely, or for some reason lost your DISPLAY setting, you
might not have a connection to X11.

There's a buglet somewhere. AFAICS, we end up calling
chooseCRANmirror() with the default graphics=TRUE, even when
capabilities("X11") is FALSE. Probably easiest to fix inside menu(),
so that it produces the text menu if asked for a graphics menu with
insufficient capabilities.
#
On Fri, 2005-04-22 at 15:42 -0500, Marc Schwartz wrote:
This is what I got:
jpeg      png    tcltk      X11 http/ftp  sockets   libxml     fifo
    TRUE     TRUE    FALSE     TRUE     TRUE     TRUE     TRUE     TRUE
  cledit  IEEE754    iconv
    TRUE     TRUE     TRUE

I recompiled after downloading the tc and tk development packages, which
gave tcltk as TRUE. update.packages() works if tcltk is enabled, but it
seems not to revert to the non-graphical interface otherwise...
#
On Fri, 2005-04-22 at 18:00 -0400, Manuel Morales wrote:
Ok. So that suggests a problem with capabilities(tcltk) == FALSE, which
will be the result of not having the tcl/tk devel RPMS installed.

To Peter's prior post, my read of the code for menu() suggests that
there is a problem in the conditional code:
function (choices, graphics = FALSE, title = "")
...

The code check there is:

    if (graphics) {
        if (.Platform$OS.type == "windows" || .Platform$GUI ==
            "AQUA") {
            res <- select.list(choices, multiple = FALSE, title = title)
            return(match(res, choices, nomatch = 0))
        }
        else if (.Platform$OS.type == "unix" && capabilities("tcltk") &&
            capabilities("X11"))
            res <- tcltk::tk_select.list(choices, multiple = FALSE,
                title = title)
        return(match(res, choices, nomatch = 0))
    }


If my read is correct, it looks like there might be a missing brace pair
for the 'else if' part?

Shouldn't that section read:

   if (graphics) {
        if (.Platform$OS.type == "windows" || .Platform$GUI ==
            "AQUA") {
            res <- select.list(choices, multiple = FALSE, title = title)
            return(match(res, choices, nomatch = 0))
        }
        else if (.Platform$OS.type == "unix" && capabilities("tcltk") &&
            capabilities("X11")) { # <<<<<< NOTE OPEN BRACE HERE >>>>>>
            res <- tcltk::tk_select.list(choices, multiple = FALSE,
                title = title)
            return(match(res, choices, nomatch = 0))
        } # <<<<<< NOTE CLOSE BRACE HERE >>>>>
    }


Without the braces, it will get to:

 return(match(res, choices, nomatch = 0))

whether all of the checks are TRUE or not, the latter being the case at
least for Manuel.


HTH,

Marc Schwartz
#
Hi all,

In follow up to my message earlier, I spent some time applying the
modification to the menu() function that I referenced earlier. I also
recompiled a local copy of R on my FC3 system using:

./configure --without-tcltk

This results in:
jpeg      png    tcltk      X11 http/ftp  sockets   libxml     fifo
    TRUE     TRUE    FALSE     TRUE     TRUE     TRUE     TRUE     TRUE
  cledit  IEEE754    iconv
    TRUE     TRUE     TRUE


The first time around, I ran the menu() function unchanged and got the
same error that Scott and Manuel reported earlier:

Error in inherits(x, "factor") : Object "res" not found

'res' is the value returned from the tcltk function tk.select.list()
used in menu().

This appeared for the series of functions that call menu(), such as
update.packages(), install.packages(), chooseCRANmirror(), contrib.url
(), etc.

After modifying the menu function, I was able to get:
--- Please select a CRAN mirror for use in this session ---
CRAN mirror

 1: Australia               2: Austria
 3: Brasil (PR)             4: Brasil (MG)
 5: Brasil (SP 1)           6: Brasil (SP 2)
 7: Canada (BC)             8: Canada (ON)
 9: Denmark                10: France (Toulouse)
11: France (Lyon)          12: France (Paris)
13: Germany (Berlin)       14: Germany (Koeln)
15: Germany (Mainz)        16: Germany (Muenchen)
17: Hungary                18: Italy (Arezzo)
19: Italy (Ferrara)        20: Japan (Aizu)
21: Japan (Tsukuba)        22: Poland
23: Portugal               24: Slovenia (Besnica)
25: Slovenia (Ljubljana)   26: South Africa
27: Spain                  28: Switzerland (Zuerich)
29: Switzerland (Bern 1)   30: Switzerland (Bern 2)
31: Turkey                 32: Taiwan
33: UK (Bristol)           34: UK (London)
35: USA (CA 1)             36: USA (CA 2)
37: USA (MA)               38: USA (MI)
39: USA (NC)               40: USA (PA 1)
41: USA (PA 2)             42: USA (WA)


Selection:


So, with the modification in menu() and without tcltk available, the
text menu now comes up properly.

The proposed patch for .../src/library/utils/menu.R is attached.

HTH,

Marc Schwartz

-------------- next part --------------
--- R-2.1.0/src/library/utils/R/menu.R	2005-04-18 05:18:57.000000000 -0500
+++ R-2.1.0-patch/src/library/utils/R/menu.R	2005-04-22 22:08:23.000000000 -0500
@@ -6,9 +6,10 @@
             res <- select.list(choices, multiple=FALSE, title=title)
             return(match(res, choices, nomatch = 0))
         } else if(.Platform$OS.type == "unix"
-                && capabilities("tcltk") && capabilities("X11"))
+                && capabilities("tcltk") && capabilities("X11")) {
             res <- tcltk::tk_select.list(choices, multiple=FALSE, title=title)
             return(match(res, choices, nomatch = 0))
+        }    
     }
     nc <- length(choices)
     if(length(title) && nchar(title[1])) cat(title[1], "\n")
#
Thanks for your work on this topic, Marc, but the bug has already been 
fixed by Brian 4 days ago (see below).

Uwe



========
r33976 | ripley | 2005-04-19 05:38:51 -0400 (Tue, 19 Apr 2005) | 1 line
Changed paths:
    M /trunk/NEWS
    M /trunk/src/library/utils/R/menu.R

missing braces
========
Marc Schwartz wrote:

            
#
On Sat, 2005-04-23 at 16:14 +0200, Uwe Ligges wrote:
Thanks Uwe.

It was a nice workout for these aging neurons...  ;-)

Did I miss a bug report on this? I don't recall seeing a report come
through and a quick review of r-devel and the bug tracking system does
not turn up anything.

In either case, glad to see that it is fixed.

I have also downloaded a copy of the 2.1.0 patched tarball and noted
that it is fixed there (Version 2.1.0 Patched (2005-04-20)), so for
anyone compiling from source get a copy of:

ftp://ftp.stat.math.ethz.ch/Software/R/R-patched.tar.gz

Best regards,

Marc
2 days later
#
On Fri, 22 Apr 2005, Uwe Ligges wrote:

            
It was a bug, already (by last Friday) corrected in R-patched:

     o   Typo in menu(graphics=TRUE) meant it failed on Unix if tcltk
         was not available.
#
On Sat, 23 Apr 2005, Marc Schwartz wrote:

            
The vast majority of the bug fixes are not from formal bug reports but 
from things spotted by R-core members either when using R (as here) or 
from reading the code (normally to find something else).  (90% of those
documented for 2.1.0.)