Opened 15 months ago

Last modified 12 months ago

#24920 needs_info defect

Failing doctests in r.py on OpenSuSE with system readline

Reported by: rws Owned by:
Priority: critical Milestone: sage-8.2
Component: doctest coverage Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by rws)

From https://groups.google.com/forum/#!topic/sage-devel/AWGonGw0tvo

On OpenSuSE with system readline several doctests in r.py get the additional line printed: sh: /home/ralf/sage/local/lib/libreadline.so.6: no version information available (required by sh) which makes them fail.

sage -t --long --warn-long 47.0 src/sage/interfaces/r.py
**********************************************************************
File "src/sage/interfaces/r.py", line 790, in sage.interfaces.r.R.help
Failed example:
    r.help('c')
Expected:
    c                     package:base                     R Documentation
    ...
Got:
    sh: /home/ralf/sage/local/lib/libreadline.so.6: no version information available (required by sh)
    c                     package:base                     R Documentation
    <BLANKLINE>
    _C_o_m_b_i_n_e _V_a_l_u_e_s _i_n_t_o _a _V_e_c_t_o_r _o_r _L_i_s_t
    <BLANKLINE>
    _D_e_s_c_r_i_p_t_i_o_n:
    <BLANKLINE>
         This is a generic function which combines its arguments.
    <BLANKLINE>
         The default method combines its arguments to form a vector.  All
         arguments are coerced to a common type which is the type of the
         returned value, and all attributes except names are removed.
    <BLANKLINE>
    _U_s_a_g_e:
    <BLANKLINE>
         ## S3 Generic function
         c(...)
    <BLANKLINE>
         ## Default S3 method:
         c(..., recursive = FALSE, use.names = TRUE)
    <BLANKLINE>
    _A_r_g_u_m_e_n_t_s:
    <BLANKLINE>
         ...: objects to be concatenated.
    <BLANKLINE>
    recursive: logical.  If ‘recursive = TRUE’, the function recursively
              descends through lists (and pairlists) combining all their
              elements into a vector.
    <BLANKLINE>
    use.names: logical indicating if ‘names’ should be preserved.
    <BLANKLINE>
    _D_e_t_a_i_l_s:
    <BLANKLINE>
         The output type is determined from the highest type of the
         components in the hierarchy NULL < raw < logical < integer <
         double < complex < character < list < expression.  Pairlists are
         treated as lists, whereas non-vector components (such names and
         calls) are treated as one-element lists which cannot be unlisted
         even if ‘recursive = TRUE’.
    <BLANKLINE>
         Note that ‘factor’s are treated only via their internal ‘integer’
         codes; one proposal has been to use
    <BLANKLINE>
            c.factor <- function(..., recursive=TRUE) unlist(list(...), recursive=recursive)
    <BLANKLINE>
         if factor concatenation by ‘c()’ should give a ‘factor’.
    <BLANKLINE>
         ‘c’ is sometimes used for its side effect of removing attributes
         except names, for example to turn an array into a vector.
         ‘as.vector’ is a more intuitive way to do this, but also drops
         names.  Note that methods other than the default are not required
         to do this (and they will almost certainly preserve a class
         attribute).
    <BLANKLINE>
         This is a primitive function.
    <BLANKLINE>
    _V_a_l_u_e:
    <BLANKLINE>
         ‘NULL’ or an expression or a vector of an appropriate mode.  (With
         no arguments the value is ‘NULL’.)
    <BLANKLINE>
    _S_4 _m_e_t_h_o_d_s:
    <BLANKLINE>
         This function is S4 generic, but with argument list ‘(x, ...)’.
    <BLANKLINE>
    _R_e_f_e_r_e_n_c_e_s:
    <BLANKLINE>
         Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
         Language_.  Wadsworth & Brooks/Cole.
    <BLANKLINE>
    _S_e_e _A_l_s_o:
    <BLANKLINE>
         ‘unlist’ and ‘as.vector’ to produce attribute-free vectors.
    <BLANKLINE>
    _E_x_a_m_p_l_e_s:
    <BLANKLINE>
         c(1,7:9)
         c(1:5, 10.5, "next")
    <BLANKLINE>
         ## uses with a single argument to drop attributes
         x <- 1:4
         names(x) <- letters[1:4]
         x
         c(x)          # has names
         as.vector(x)  # no names
         dim(x) <- c(2,2)
         x
         c(x)
         as.vector(x)
    <BLANKLINE>
         ## append to a list:
         ll <- list(A = 1, c = "C")
         ## do *not* use
         c(ll, d = 1:3) # which is == c(ll, as.list(c(d = 1:3))
         ## but rather
         c(ll, d = list(1:3))  # c() combining two lists
    <BLANKLINE>
         c(list(A = c(B = 1)), recursive = TRUE)
    <BLANKLINE>
         c(options(), recursive = TRUE)
         c(list(A = c(B = 1, C = 2), B = c(E = 7)), recursive = TRUE)
**********************************************************************
File "src/sage/interfaces/r.py", line 1956, in sage.interfaces.r.RFunctionElement._instancedoc_
Failed example:
    print(length.__doc__)
Expected:
    length                 package:base                 R Documentation
    ...
    <BLANKLINE>
Got:
    sh: /home/ralf/sage/local/lib/libreadline.so.6: no version information available (required by sh)
    length                  package:base                   R Documentation
    <BLANKLINE>
    _L_e_n_g_t_h _o_f _a_n _O_b_j_e_c_t
    <BLANKLINE>
    _D_e_s_c_r_i_p_t_i_o_n:
    <BLANKLINE>
         Get or set the length of vectors (including lists) and factors,
         and of any other R object for which a method has been defined.
    <BLANKLINE>
    _U_s_a_g_e:
    <BLANKLINE>
         length(x)
         length(x) <- value
    <BLANKLINE>
    _A_r_g_u_m_e_n_t_s:
    <BLANKLINE>
           x: an R object.  For replacement, a vector or factor.
    <BLANKLINE>
       value: a non-negative integer or double (which will be rounded
              down).
    <BLANKLINE>
    _D_e_t_a_i_l_s:
    <BLANKLINE>
         Both functions are generic: you can write methods to handle
         specific classes of objects, see InternalMethods.  ‘length<-’ has
         a ‘"factor"’ method.
    <BLANKLINE>
         The replacement form can be used to reset the length of a vector.
         If a vector is shortened, extra values are discarded and when a
         vector is lengthened, it is padded out to its new length with
         ‘NA’s (‘nul’ for raw vectors).
    <BLANKLINE>
         Both are primitive functions.
    <BLANKLINE>
    _V_a_l_u_e:
    <BLANKLINE>
         The default method for ‘length’ currently returns a non-negative
         ‘integer’ of length 1, except for vectors of more than 2^31 - 1
         elements, when it returns a double.
    <BLANKLINE>
         For vectors (including lists) and factors the length is the number
         of elements.  For an environment it is the number of objects in
         the environment, and ‘NULL’ has length 0.  For expressions and
         pairlists (including language objects and dotlists) it is the
         length of the pairlist chain.  All other objects (including
         functions) have length one: note that for functions this differs
         from S.
    <BLANKLINE>
         The replacement form removes all the attributes of ‘x’ except its
         names, which are adjusted (and if necessary extended by ‘""’).
    <BLANKLINE>
    _W_a_r_n_i_n_g:
    <BLANKLINE>
         Package authors have written methods that return a result of
         length other than one (‘Formula’) and that return a vector of type
         ‘double’ (‘Matrix’), even with non-integer values (earlier
         versions of ‘sets’). Where a single double value is returned that
         can be represented as an integer it is returned as a length-one
         integer vector.
    <BLANKLINE>
    _R_e_f_e_r_e_n_c_e_s:
    <BLANKLINE>
         Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
         Language_.  Wadsworth & Brooks/Cole.
    <BLANKLINE>
    _S_e_e _A_l_s_o:
    <BLANKLINE>
         ‘nchar’ for counting the number of characters in character
         vectors, ‘lengths’ for getting the length of every element in a
         list.
    <BLANKLINE>
    _E_x_a_m_p_l_e_s:
    <BLANKLINE>
         length(diag(4))  # = 16 (4 x 4)
         length(options())  # 12 or more
         length(y ~ x1 + x2 + x3)  # 3
         length(expression(x, {y <- x^2; y+2}, x^y))  # 3
    <BLANKLINE>
         ## from example(warpbreaks)
         require(stats)
    <BLANKLINE>
         fm1 <- lm(breaks ~ wool * tension, data = warpbreaks)
         length(fm1$call)      # 3, lm() and two arguments.
         length(formula(fm1))  # 3, ~ lhs rhs
**********************************************************************
File "src/sage/interfaces/r.py", line 2046, in sage.interfaces.r.RFunction._instancedoc_
Failed example:
    print(length.__doc__)
Expected:
    length                 package:base                 R Documentation
    ...
    <BLANKLINE>
Got:
    sh: /home/ralf/sage/local/lib/libreadline.so.6: no version information available (required by sh)
    length                  package:base                   R Documentation
    <BLANKLINE>
    _L_e_n_g_t_h _o_f _a_n _O_b_j_e_c_t
    <BLANKLINE>
    _D_e_s_c_r_i_p_t_i_o_n:
    <BLANKLINE>
         Get or set the length of vectors (including lists) and factors,
         and of any other R object for which a method has been defined.
    <BLANKLINE>
    _U_s_a_g_e:
    <BLANKLINE>
         length(x)
         length(x) <- value
    <BLANKLINE>
    _A_r_g_u_m_e_n_t_s:
    <BLANKLINE>
           x: an R object.  For replacement, a vector or factor.
    <BLANKLINE>
       value: a non-negative integer or double (which will be rounded
              down).
    <BLANKLINE>
    _D_e_t_a_i_l_s:
    <BLANKLINE>
         Both functions are generic: you can write methods to handle
         specific classes of objects, see InternalMethods.  ‘length<-’ has
         a ‘"factor"’ method.
    <BLANKLINE>
         The replacement form can be used to reset the length of a vector.
         If a vector is shortened, extra values are discarded and when a
         vector is lengthened, it is padded out to its new length with
         ‘NA’s (‘nul’ for raw vectors).
    <BLANKLINE>
         Both are primitive functions.
    <BLANKLINE>
    _V_a_l_u_e:
    <BLANKLINE>
         The default method for ‘length’ currently returns a non-negative
         ‘integer’ of length 1, except for vectors of more than 2^31 - 1
         elements, when it returns a double.
    <BLANKLINE>
         For vectors (including lists) and factors the length is the number
         of elements.  For an environment it is the number of objects in
         the environment, and ‘NULL’ has length 0.  For expressions and
         pairlists (including language objects and dotlists) it is the
         length of the pairlist chain.  All other objects (including
         functions) have length one: note that for functions this differs
         from S.
    <BLANKLINE>
         The replacement form removes all the attributes of ‘x’ except its
         names, which are adjusted (and if necessary extended by ‘""’).
    <BLANKLINE>
    _W_a_r_n_i_n_g:
    <BLANKLINE>
         Package authors have written methods that return a result of
         length other than one (‘Formula’) and that return a vector of type
         ‘double’ (‘Matrix’), even with non-integer values (earlier
         versions of ‘sets’). Where a single double value is returned that
         can be represented as an integer it is returned as a length-one
         integer vector.
    <BLANKLINE>
    _R_e_f_e_r_e_n_c_e_s:
    <BLANKLINE>
         Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
         Language_.  Wadsworth & Brooks/Cole.
    <BLANKLINE>
    _S_e_e _A_l_s_o:
    <BLANKLINE>
         ‘nchar’ for counting the number of characters in character
         vectors, ‘lengths’ for getting the length of every element in a
         list.
    <BLANKLINE>
    _E_x_a_m_p_l_e_s:
    <BLANKLINE>
         length(diag(4))  # = 16 (4 x 4)
         length(options())  # 12 or more
         length(y ~ x1 + x2 + x3)  # 3
         length(expression(x, {y <- x^2; y+2}, x^y))  # 3
    <BLANKLINE>
         ## from example(warpbreaks)
         require(stats)
    <BLANKLINE>
         fm1 <- lm(breaks ~ wool * tension, data = warpbreaks)
         length(fm1$call)      # 3, lm() and two arguments.
         length(formula(fm1))  # 3, ~ lhs rhs
**********************************************************************
3 items had failures:
   1 of   2 in sage.interfaces.r.R.help
   1 of   3 in sage.interfaces.r.RFunction._instancedoc_
   1 of   4 in sage.interfaces.r.RFunctionElement._instancedoc_
    [260 tests, 3 failures, 2.63 s]
----------------------------------------------------------------------
sage -t --long --warn-long 47.0 src/sage/interfaces/r.py  # 3 doctests failed

Change History (9)

comment:1 in reply to: ↑ description Changed 15 months ago by jdemeyer

Which doctests fail and precisely how do they fail?

comment:2 Changed 15 months ago by rws

  • Description modified (diff)

comment:3 Changed 15 months ago by rws

  • Description modified (diff)

Can #24919 fix this, possibly by checking for system readline at start of build?

comment:4 Changed 15 months ago by rws

  • Status changed from new to needs_info

comment:5 Changed 14 months ago by vbraun

Looks like R is somewhere setting LD_LIBRARY_PATH when rendering docs. It shouldn't, we don't need nor want it. In particular, sh should just use the system libraries.

comment:6 Changed 14 months ago by vbraun

Looks like R depends on setting its own LD_LIBRARY_PATH in local/lib/R/etc/ldpaths, thats terrible.

comment:8 Changed 12 months ago by fbissey

Debian and sage-on-gentoo now use https://anonscm.debian.org/cgit/debian-science/packages/sagemath.git/tree/debian/patches/dt-r-no-readline.patch because R hangs with newer readline. I suspect it would also help here.

comment:9 Changed 12 months ago by rws

Cannot confirm. Still fails with that patch. In principle readline is already linked in R, so you may be able to switch off its usage, but the library is still loaded.

Note: See TracTickets for help on using tickets.