Error: package or namespace load failed for ‘utils

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Error: package or namespace load failed for ‘utils

lgautier
Hi,

When starting an embedded R I encounter the following issue under certain
conditions:

```
Error: package or namespace load failed for ‘utils’ in if (.identC(class1,
class2) || .identC(class2, "ANY")) TRUE else {:
 missing value where TRUE/FALSE needed
```
(more such errors for grDevices, graphics, and stats)

And in the end:

```
Warning messages:
1: package ‘utils’ in options("defaultPackages") was not found
2: package ‘grDevices’ in options("defaultPackages") was not found
3: package ‘graphics’ in options("defaultPackages") was not found
4: package ‘stats’ in options("defaultPackages") was not found
```

While the embedded R appears functional, no package can be loaded.

The erorr message from R (`missing value where TRUE/FALSE needed`) suggests
that R should be able to catch the underlying issue (I am yet to find what
it is) earlier and with this make the task of troubleshooting easier.

Best,


Laurent

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error: package or namespace load failed for ‘utils

R devel mailing list
Look at section 6.1 of the R Installation and Admin manual.

6.1 Default packages

The set of packages loaded on startup is by default

> getOption("defaultPackages")
[1] "datasets"  "utils"     "grDevices" "graphics"  "stats"     "methods"

(plus, of course, *base*) and this can be changed by setting the option in
startup code (e.g. in ~/.Rprofile). It is initially set to the value of the
environment variable R_DEFAULT_PACKAGES if set (as a comma-separated list).
Setting R_DEFAULT_PACKAGES=NULL ensures that only package *base* is loaded.

Changing the set of default packages is normally used to reduce the set for
speed when scripting: in particular not using *methods*will reduce the
start-up time by a factor of up to two. But it can also be used to
customize R, e.g. for class use. Rscript also checks the environment
variable R_SCRIPT_DEFAULT_PACKAGES; if set, this takes precedence over
R_DEFAULT_PACKAGES.
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Sun, Sep 8, 2019 at 8:42 AM Laurent Gautier <[hidden email]> wrote:

> Hi,
>
> When starting an embedded R I encounter the following issue under certain
> conditions:
>
> ```
> Error: package or namespace load failed for ‘utils’ in if (.identC(class1,
> class2) || .identC(class2, "ANY")) TRUE else {:
>  missing value where TRUE/FALSE needed
> ```
> (more such errors for grDevices, graphics, and stats)
>
> And in the end:
>
> ```
> Warning messages:
> 1: package ‘utils’ in options("defaultPackages") was not found
> 2: package ‘grDevices’ in options("defaultPackages") was not found
> 3: package ‘graphics’ in options("defaultPackages") was not found
> 4: package ‘stats’ in options("defaultPackages") was not found
> ```
>
> While the embedded R appears functional, no package can be loaded.
>
> The erorr message from R (`missing value where TRUE/FALSE needed`) suggests
> that R should be able to catch the underlying issue (I am yet to find what
> it is) earlier and with this make the task of troubleshooting easier.
>
> Best,
>
>
> Laurent
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error: package or namespace load failed for ‘utils

lgautier
Hi,

Thanks, but I am unsure this helps.

The point I am making is that an R error (about a missing value where a
boolean would be expected), originating from the package methods, is not
informative. This is indicating that a core R function involved in the
loading of an R packages may receive invalid arguments, and rather than the
current situation I believe that such invalid arguments should be
identified earlier with a more meaningful error message (as in an error
message leading to the root of the issue) produced.

L.

Le dim. 8 sept. 2019 à 12:58, William Dunlap <[hidden email]> a écrit :

> Look at section 6.1 of the R Installation and Admin manual.
>
> 6.1 Default packages
>
> The set of packages loaded on startup is by default
>
> > getOption("defaultPackages")
> [1] "datasets"  "utils"     "grDevices" "graphics"  "stats"     "methods"
>
> (plus, of course, *base*) and this can be changed by setting the option
> in startup code (e.g. in ~/.Rprofile). It is initially set to the value
> of the environment variable R_DEFAULT_PACKAGES if set (as a
> comma-separated list). Setting R_DEFAULT_PACKAGES=NULL ensures that only
> package *base* is loaded.
>
> Changing the set of default packages is normally used to reduce the set
> for speed when scripting: in particular not using *methods*will reduce
> the start-up time by a factor of up to two. But it can also be used to
> customize R, e.g. for class use. Rscript also checks the environment
> variable R_SCRIPT_DEFAULT_PACKAGES; if set, this takes precedence over
> R_DEFAULT_PACKAGES.
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Sun, Sep 8, 2019 at 8:42 AM Laurent Gautier <[hidden email]> wrote:
>
>> Hi,
>>
>> When starting an embedded R I encounter the following issue under certain
>> conditions:
>>
>> ```
>> Error: package or namespace load failed for ‘utils’ in if (.identC(class1,
>> class2) || .identC(class2, "ANY")) TRUE else {:
>>  missing value where TRUE/FALSE needed
>> ```
>> (more such errors for grDevices, graphics, and stats)
>>
>> And in the end:
>>
>> ```
>> Warning messages:
>> 1: package ‘utils’ in options("defaultPackages") was not found
>> 2: package ‘grDevices’ in options("defaultPackages") was not found
>> 3: package ‘graphics’ in options("defaultPackages") was not found
>> 4: package ‘stats’ in options("defaultPackages") was not found
>> ```
>>
>> While the embedded R appears functional, no package can be loaded.
>>
>> The erorr message from R (`missing value where TRUE/FALSE needed`)
>> suggests
>> that R should be able to catch the underlying issue (I am yet to find what
>> it is) earlier and with this make the task of troubleshooting easier.
>>
>> Best,
>>
>>
>> Laurent
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error: package or namespace load failed for ‘utils

R devel mailing list
In reply to this post by R devel mailing list
Also, check the settings of R_HOME and/or R_LIBS.
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Sun, Sep 8, 2019 at 9:58 AM William Dunlap <[hidden email]> wrote:

> Look at section 6.1 of the R Installation and Admin manual.
>
> 6.1 Default packages
>
> The set of packages loaded on startup is by default
>
> > getOption("defaultPackages")
> [1] "datasets"  "utils"     "grDevices" "graphics"  "stats"     "methods"
>
> (plus, of course, *base*) and this can be changed by setting the option
> in startup code (e.g. in ~/.Rprofile). It is initially set to the value
> of the environment variable R_DEFAULT_PACKAGES if set (as a
> comma-separated list). Setting R_DEFAULT_PACKAGES=NULL ensures that only
> package *base* is loaded.
>
> Changing the set of default packages is normally used to reduce the set
> for speed when scripting: in particular not using *methods*will reduce
> the start-up time by a factor of up to two. But it can also be used to
> customize R, e.g. for class use. Rscript also checks the environment
> variable R_SCRIPT_DEFAULT_PACKAGES; if set, this takes precedence over
> R_DEFAULT_PACKAGES.
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Sun, Sep 8, 2019 at 8:42 AM Laurent Gautier <[hidden email]> wrote:
>
>> Hi,
>>
>> When starting an embedded R I encounter the following issue under certain
>> conditions:
>>
>> ```
>> Error: package or namespace load failed for ‘utils’ in if (.identC(class1,
>> class2) || .identC(class2, "ANY")) TRUE else {:
>>  missing value where TRUE/FALSE needed
>> ```
>> (more such errors for grDevices, graphics, and stats)
>>
>> And in the end:
>>
>> ```
>> Warning messages:
>> 1: package ‘utils’ in options("defaultPackages") was not found
>> 2: package ‘grDevices’ in options("defaultPackages") was not found
>> 3: package ‘graphics’ in options("defaultPackages") was not found
>> 4: package ‘stats’ in options("defaultPackages") was not found
>> ```
>>
>> While the embedded R appears functional, no package can be loaded.
>>
>> The erorr message from R (`missing value where TRUE/FALSE needed`)
>> suggests
>> that R should be able to catch the underlying issue (I am yet to find what
>> it is) earlier and with this make the task of troubleshooting easier.
>>
>> Best,
>>
>>
>> Laurent
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error: package or namespace load failed for ‘utils

lgautier
R_HOME is not the issue, and I believe that R_LIBS is not involved with
packages such as "datasets", "utils", etc...
I suspect that the issue is around dynamic loading of C libraries, as
depending on the way the R shared library is called the issue is absent or
present, but the error reporting from R makes tracking this easy.

Le dim. 8 sept. 2019 à 13:22, William Dunlap <[hidden email]> a écrit :

> Also, check the settings of R_HOME and/or R_LIBS.
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Sun, Sep 8, 2019 at 9:58 AM William Dunlap <[hidden email]> wrote:
>
>> Look at section 6.1 of the R Installation and Admin manual.
>>
>> 6.1 Default packages
>>
>> The set of packages loaded on startup is by default
>>
>> > getOption("defaultPackages")
>> [1] "datasets"  "utils"     "grDevices" "graphics"  "stats"     "methods"
>>
>> (plus, of course, *base*) and this can be changed by setting the option
>> in startup code (e.g. in ~/.Rprofile). It is initially set to the value
>> of the environment variable R_DEFAULT_PACKAGES if set (as a
>> comma-separated list). Setting R_DEFAULT_PACKAGES=NULL ensures that only
>> package *base* is loaded.
>>
>> Changing the set of default packages is normally used to reduce the set
>> for speed when scripting: in particular not using *methods*will reduce
>> the start-up time by a factor of up to two. But it can also be used to
>> customize R, e.g. for class use. Rscript also checks the environment
>> variable R_SCRIPT_DEFAULT_PACKAGES; if set, this takes precedence over
>> R_DEFAULT_PACKAGES.
>> Bill Dunlap
>> TIBCO Software
>> wdunlap tibco.com
>>
>>
>> On Sun, Sep 8, 2019 at 8:42 AM Laurent Gautier <[hidden email]>
>> wrote:
>>
>>> Hi,
>>>
>>> When starting an embedded R I encounter the following issue under certain
>>> conditions:
>>>
>>> ```
>>> Error: package or namespace load failed for ‘utils’ in if
>>> (.identC(class1,
>>> class2) || .identC(class2, "ANY")) TRUE else {:
>>>  missing value where TRUE/FALSE needed
>>> ```
>>> (more such errors for grDevices, graphics, and stats)
>>>
>>> And in the end:
>>>
>>> ```
>>> Warning messages:
>>> 1: package ‘utils’ in options("defaultPackages") was not found
>>> 2: package ‘grDevices’ in options("defaultPackages") was not found
>>> 3: package ‘graphics’ in options("defaultPackages") was not found
>>> 4: package ‘stats’ in options("defaultPackages") was not found
>>> ```
>>>
>>> While the embedded R appears functional, no package can be loaded.
>>>
>>> The erorr message from R (`missing value where TRUE/FALSE needed`)
>>> suggests
>>> that R should be able to catch the underlying issue (I am yet to find
>>> what
>>> it is) earlier and with this make the task of troubleshooting easier.
>>>
>>> Best,
>>>
>>>
>>> Laurent
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error: package or namespace load failed for ‘utils

lgautier
In reply to this post by lgautier
In case a search engine leads someone with the same issue here, I am
documenting the point I reached:

I can reproduce the issue with a small example when forcing R to not load
any package at startup time (using an Renviron file):
```
package <- "utils"
lib.loc <- "<fill this according to your R install>"
ns <- loadNamespace(package, lib.loc)
```

The code path goes through `registerS3methods(nsInfo$S3methods, package,
env)` and there to:

```
if (methods::is(genfun, "genericFunction"))
```

The evaluation of `methods::is` reaches the line triggering the error as
`.identC(class1, class2)` and `.identC(class2, "ANY")` both return `NA` and
`NA || NA` is not defined:

```
> if (NA || NA) { cat("here\n") }
Error in if (NA || NA) { : missing value where TRUE/FALSE needed
```

As I understand it `.identC()` should never return `NA`, and if the case
this would mean that R itself is an unstable state (something at the C
level that should not have happened has happened) but this was not caught
earlier.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error: package or namespace load failed for‘utils

Kurt Hornik-5
>>>>> Laurent Gautier writes:

> In case a search engine leads someone with the same issue here, I am
> documenting the point I reached:

> I can reproduce the issue with a small example when forcing R to not load
> any package at startup time (using an Renviron file):
> ```
> package <- "utils"
> lib.loc <- "<fill this according to your R install>"
> ns <- loadNamespace(package, lib.loc)
> ```

I cannot reproduce this using current R-devel or R-patched.  After
starting with R_DEFAULT_PACKAGES=NULL,

R> search()
[1] ".GlobalEnv"   "Autoloads"    "package:base"
R> loadedNamespaces()
[1] "compiler" "tools"    "base"    
R> package <- "utils"
R> lib.loc <- file.path(R.home(), "library")
R> ns <- loadNamespace(package, lib.loc)
R> loadedNamespaces()
[1] "compiler" "tools"    "utils"    "base"    

-k

> The code path goes through `registerS3methods(nsInfo$S3methods, package,
> env)` and there to:

> ```
> if (methods::is(genfun, "genericFunction"))
> ```

> The evaluation of `methods::is` reaches the line triggering the error as
> `.identC(class1, class2)` and `.identC(class2, "ANY")` both return `NA` and
> `NA || NA` is not defined:

> ```
>> if (NA || NA) { cat("here\n") }
> Error in if (NA || NA) { : missing value where TRUE/FALSE needed
> ```

> As I understand it `.identC()` should never return `NA`, and if the case
> this would mean that R itself is an unstable state (something at the C
> level that should not have happened has happened) but this was not caught
> earlier.

> [[alternative HTML version deleted]]

> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error: package or namespace load failed for ‘utils

Martin Maechler
In reply to this post by lgautier
>>>>> Laurent Gautier
>>>>>     on Sun, 15 Sep 2019 15:01:09 -0400 writes:

    > In case a search engine leads someone with the same issue
    > here, I am documenting the point I reached:

    > I can reproduce the issue with a small example when
    > forcing R to not load any package at startup time (using
    > an Renviron file): ``` package <- "utils" lib.loc <-
    > "<fill this according to your R install>" ns <-
    > loadNamespace(package, lib.loc) ```

    > The code path goes through
    > `registerS3methods(nsInfo$S3methods, package, env)` and
    > there to:

    > ``` if (methods::is(genfun, "genericFunction")) ```

    > The evaluation of `methods::is` reaches the line
    > triggering the error as `.identC(class1, class2)` and
    > `.identC(class2, "ANY")` both return `NA` and `NA || NA`
    > is not defined:

    > ```
    >> if (NA || NA) { cat("here\n") }
    > Error in if (NA || NA) { : missing value where TRUE/FALSE
    > needed ```

    > As I understand it `.identC()` should never return `NA`,

that understanding is correct, it should return TRUE or FALSE,
nothing else.

    > and if the case this would mean that R itself is an
    > unstable state (something at the C level that should not
    > have happened has happened) but this was not caught
    > earlier.

yes.. something like that...
My current diagnosis would be that something in your embedding of R happened
in a way that "broke R entirely" ...
but note that I know almost nothing about embedding R.

Martin

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error: package or namespace load failed for ‘utils

lgautier
Thanks to all that looked at it and tried to answer.

I am reporting here what I found in the end, in the hope it helps someone
with a similar issue solve it quicker than I solved the one I had:

Having

int R_NaInt;

rather than

extern int R_NaInt;

in the header / C definitions of the cffi interface (part of the header
definitions have to be copied/prepared to be digestable by the C parser
used Python's cffi interface) was enough to send R into a confused state at
initialization (but without an obvious error message).


Le lun. 16 sept. 2019 à 03:55, Martin Maechler <[hidden email]>
a écrit :

> >>>>> Laurent Gautier
> >>>>>     on Sun, 15 Sep 2019 15:01:09 -0400 writes:
>
>     > In case a search engine leads someone with the same issue
>     > here, I am documenting the point I reached:
>
>     > I can reproduce the issue with a small example when
>     > forcing R to not load any package at startup time (using
>     > an Renviron file): ``` package <- "utils" lib.loc <-
>     > "<fill this according to your R install>" ns <-
>     > loadNamespace(package, lib.loc) ```
>
>     > The code path goes through
>     > `registerS3methods(nsInfo$S3methods, package, env)` and
>     > there to:
>
>     > ``` if (methods::is(genfun, "genericFunction")) ```
>
>     > The evaluation of `methods::is` reaches the line
>     > triggering the error as `.identC(class1, class2)` and
>     > `.identC(class2, "ANY")` both return `NA` and `NA || NA`
>     > is not defined:
>
>     > ```
>     >> if (NA || NA) { cat("here\n") }
>     > Error in if (NA || NA) { : missing value where TRUE/FALSE
>     > needed ```
>
>     > As I understand it `.identC()` should never return `NA`,
>
> that understanding is correct, it should return TRUE or FALSE,
> nothing else.
>
>     > and if the case this would mean that R itself is an
>     > unstable state (something at the C level that should not
>     > have happened has happened) but this was not caught
>     > earlier.
>
> yes.. something like that...
> My current diagnosis would be that something in your embedding of R
> happened
> in a way that "broke R entirely" ...
> but note that I know almost nothing about embedding R.
>
> Martin
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel