Skip to content

R 4.1.2 (arm build) will output for nothing when --interactive flag is passed

5 messages · YearNorth, Paul Keydel, Simon Urbanek

#
Dear developer:

On R 4.1.2 (arm build) in macOS 12.0.1, if call R from shell, when ?interactive flag is passed, it will output nothing.

To reproduce it:

```
echo "base::cat('Hello\\\\n')\\n" | R --no-save --interactive > test.txt

``

doesn?t yield the derised output

```
R version 4.1.2 (2021-11-01) -- "Bird Hippie?
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R

```

The desired output should have a line `> base::cat('Hello\\n')\n` in test.txt

This may be the critical problem for why `vscDebugger` (a R debugger for VSCode) does not work for arm build R.

See the discussion on github 
https://github.com/ManuelHentschel/VSCode-R-Debugger/issues/155#issuecomment-1014946738 <https://github.com/ManuelHentschel/VSCode-R-Debugger/issues/155#issuecomment-1014946738>
https://github.com/ManuelHentschel/VSCode-R-Debugger/issues/155#issuecomment-1017250405 <https://github.com/ManuelHentschel/VSCode-R-Debugger/issues/155#issuecomment-1017250405>

Thanks for your time reading and processing my email!

Best,
North
Year
#
Year,

that code doesn't output anything on stdout, because it is an error so it does show up on stderr:

$ echo "base::cat('Hello\\\\n')\\n" | R --silent --no-save --interactive
Error: unexpected '\\' in "base::cat('Hello\\n')\"

What you probably meant was 

$ echo 'cat("Hello\n")' | R --silent --no-save --interactive
Hello
which works as expected.

Cheers,
Simon
#
Dear all!

Thanks for reporting the issue. I observed the same problem, but I messaged not quickly enough...
In fact, it seems that the ARM build of R (4.1.2) cannot pick up the data piped in when the ?interactive flag is set. For reproducing I would suggest to use a simple ?print(2.718)? instead of the string below.

So, here is what I got, just copied from the terminal (macOS 12.1)

Pauls-Air:~ paul$ echo "print(2.718)" | R --quiet --no-save
[1] 2.718
Pauls-Air:~ paul$ echo "print(2.718)" | R --quiet --no-save --interactive

Pauls-Air:~ paul$

The first one gives the expected output, but when I force R to be in interactive mode, R somehow ignores the input from stdin. And we don?t know why :-)

Thanks for your time and help!

Best,
Paul

  
  
#
Paul,

thanks, you example is getting closer to the real issue which is that stdin is not treated as input if libedit is used and --interactive is specified:

R 4.1.2 arm64 binary:
$ echo x | R --quiet --no-save --interactive


Current (4.1.2 patched or devel - https://mac.R-project.org) R arm64 binary:
$ echo x | R --quiet --no-save --interactive
Error: object 'x' not found
The main difference is that the binaries are now using libreadline instead of Apple's libedit (see extSoftVersion()["readline"] ). So the short answer is update your R if that matters to you. I have not looked into the cause in libedit, so I don't know if that is a libedit bug or something we do.

Cheers,
Simon
#
Hey Simon!

Great! Thank you very much for the explanation!

I installed the 4.1.2 patched and this version solved the issue, i.e. R treats stdin correctly.

Cheers,
Paul