readProcess problem under Windows with R
Summary
readProcess from module System.Process works in most cases with R, but there is one scenario where it does not, under Windows. At the Windows prompt, typing "R CMD config --cppflags" displays the compiler include flags needed to compile using R library. But if this same command is issued using: readProcess "R" ["CMD", "config", "--cppflags", "--quiet", "--slave"], the message "R was not built as a library" is returned, and the return list is empty. Where this message comes from and why it is issued is explained in a comment below, but it is not clear why this only happens with readProcess.
Steps to reproduce
-- Load and run this source using GHCi...
import System.Environment(setEnv,getEnv)
import System.Process(readProcess)
main :: IO ()
main = do
str <- readProcess "R" ["CMD", "config", "--cppflags",
"--quiet", "--slave"] ""
putStrLn str
return ()
Expected behavior
Output should look like
-IC:/PROGA1/R/R-411.1/include (or something like this)
Environment
- GHC version used: 8.10.4
Optional:
- Operating System: Windows 10
- System Architecture: X86_64