MichaelChirico / r-bugs

A ⚠️read-only⚠️mirror of https://bugs.r-project.org/
20 stars 0 forks source link

[BUGZILLA #15070] When R_HOME is set, R writes a warning in stdout at startup breaking pipes. #4658

Open MichaelChirico opened 4 years ago

MichaelChirico commented 4 years ago

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.


METADATA

MichaelChirico commented 4 years ago

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.


METADATA

MichaelChirico commented 4 years ago

(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).


METADATA

MichaelChirico commented 4 years ago

The fix is adding >&2 at the end of line 31 of the main R script.


METADATA

MichaelChirico commented 4 years ago

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.


METADATA

MichaelChirico commented 4 years ago

I also consider this a bug, and I'd love for it to be fixed.

Since R is a data language, the separation between data output and diagnostic/informational/warning/error output seems particularly important to maintain.

In my case, I hit this when running R as a subprocess to gather some information. These "WARNING: ignoring environment value of R_HOME" strings were buried in the output, so the output was broken. Figuring out how to fix this R_HOME value became "unnecessarily necessary" just to un-break the output.

IMO this is more than just a "cultural" convention, it's a convention that, if R stuck to more strictly, would help in various other places than just this particular informational warning. For instance, various build tools (IDEs, continuous build environments, etc.) can color the stderr output red and stdout output black, which would really help users know where to look for different kinds of output or error messages.


METADATA