Bug 17432 - readLines function with R >= 3.5.0
Summary: readLines function with R >= 3.5.0
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: I/O (show other bugs)
Version: R 3.5.0
Hardware: x86_64/x64/amd64 (64-bit) Linux
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2018-06-01 09:41 UTC by Ralf Stubner
Modified: 2018-06-01 16:12 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Stubner 2018-06-01 09:41:32 UTC
This report corresponds to the discussion on r-devel: 
https://stat.ethz.ch/pipermail/r-devel/2018-May/076241.html

It is based on this question on SO:

https://stackoverflow.com/questions/50372043/readlines-function-with-new-version-of-r

Based on the OP's code I used the script

#######################################
create_matrix <- function() {
  cat("Write the numbers of vertices: ")
  user_input <- readLines("stdin", n=1)
  user_input <- as.numeric(user_input)
  print(user_input)
  }
create_matrix()
#######################################

and called it with "R -f ..." from the command line.

With 'R version 3.4.4 (2018-03-15) -- "Someone to Lean On"' the script
prints the inputed number as expected. With both 'R version 3.5.0
(2018-04-23) -- "Joy in Playing"' and 'R Under development (unstable)
(2018-05-19 r74746) -- "Unsuffered Consequences"' the script does not
continue after inputing a number.

All these tests where done using docker images from the rocker project,
i.e. effectively using Debian Linux.

In the subsequent discussions it has been identifed as an issue with the way R buffers standard input.
Comment 1 Michael Lawrence 2018-06-01 16:12:14 UTC
Thanks for the report; fixed now by disabling buffering on all terminal (file) connections.