Bug 15070 - When R_HOME is set, R writes a warning in stdout at startup breaking pipes.
Summary: When R_HOME is set, R writes a warning in stdout at startup breaking pipes.
Status: VERIFIED WISHLIST
Alias: None
Product: R
Classification: Unclassified
Component: Startup (show other bugs)
Version: R 2.15.1
Hardware: All All
: P1 trivial
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2012-10-11 23:06 UTC by piccolbo
Modified: 2013-04-15 16:26 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description piccolbo 2012-10-11 23:06:29 UTC
Repro:

antonio$ export R_HOME=something; R --vanilla 2> /dev/null
WARNING: ignoring environment value of R_HOME

The question is: is this a bug? I can't prove it but let me build a case.

1. message, warning and error functions in R use stderr by default.
2. The unix culture is that stdout is for data, stderr for error messages or diagnostics, see e.g. Wikipedia's standard streams entry. I know R is not exclusively or even mainly a Unix program, but it sure is an important platform
3. if you use R in a pipe, which is my use case, this behavior is source of bugs and lack of interoperability with other programs.
4. I read experienced R developers describe writing package startup messages to stdout as a "buglet" and a package maintainer recently accepted to fix this behavior on my request, he's either nice or agrees with me or both. I don't see why packages should be held to a different standard, since the streams are shared.


I know R tries to strike a balance between being an interactive statistical analysis tool and a programming language, but this seems a case where the latter aspect can be enhanced at no apparent detriment to the  former.


Verified on centos and os x, I suspect this problem to be platform independent.
Comment 1 Brian Ripley 2012-10-20 08:57:51 UTC
This simply is not true.

There is an information message (not an error, not a diagnostic) if the value of R_HOME is set to a value *different from the one appropriate to that install of R*.

Why would anyone do that intentionally?  If it is not done, there is no message.

As to where messages are sent, it is a cultural convention to send error messages to stderr, but it is not common to do so for information messages intended for the end user.  The R front-end script does send error messages to stderr.
Comment 2 Ben Bolker 2012-10-22 00:41:38 UTC
(In reply to comment #0)
> Repro:
> 
> antonio$ export R_HOME=something; R --vanilla 2> /dev/null
> WARNING: ignoring environment value of R_HOME
> 
> The question is: is this a bug? I can't prove it but let me build a case.
> 
> 1. message, warning and error functions in R use stderr by default.
> 2. The unix culture is that stdout is for data, stderr for error messages or
> diagnostics, see e.g. Wikipedia's standard streams entry. I know R is not
> exclusively or even mainly a Unix program, but it sure is an important platform
> 3. if you use R in a pipe, which is my use case, this behavior is source of
> bugs and lack of interoperability with other programs.
> 4. I read experienced R developers describe writing package startup messages to
> stdout as a "buglet" and a package maintainer recently accepted to fix this
> behavior on my request, he's either nice or agrees with me or both. I don't see
> why packages should be held to a different standard, since the streams are
> shared.
> 
> 
> I know R tries to strike a balance between being an interactive statistical
> analysis tool and a programming language, but this seems a case where the
> latter aspect can be enhanced at no apparent detriment to the  former.
> 
> 
> Verified on centos and os x, I suspect this problem to be platform independent.


  I will just point out for whatever it's worth that this exact
issue has bitten me in the past (on Ubuntu 10.04).
Comment 3 piccolbo 2012-10-22 20:07:27 UTC
The fix is adding  >&2 at the end of line 31 of the main R script.
Comment 4 Giuseppe Acito 2013-04-12 12:44:46 UTC
*This is simply true*: what's the deal on redirecting this message to stderr (where it should be). That's not the result of a normal situation.

> Why would anyone do that intentionally?  If it is not done, there is no message.

Because software developers != admins. they boh may fail, but this would be a blocking situation or (worse) lead to use unnecessary caveats.

if it's not an error, not a diagnostic, why do you print it, do you honestly think that an average user pays attention that R_HOME is not set where it should be set?

Please fix.