I have the awkward problem that when executing a specific powershell command (calling a powershell Module located in ~/WindowsPowerShell/Modules/) in R via system2(command = 'powershell', args = someStringVariable)
it will only return "127".
Other - simpler - invocations of the module manage to produce results. But as soon as one of the three parameters (ie a [MDX] query gets a bit more complex) or reaches a certain length/size it just returns '127'.
The real bug though seems to be that both the simple query and the complex one can be moved back and fourth to a normal Powershell ISE window via copy/paste respectively readClipboard()
respectively writeClipboard()
(used the latter R function to avoid STRG+C and/or STRG+V for moving the simpler Module call parameters, that work correct in R, identically from R to powershell) and these will produce correct results (ie write a result file).
So my questions would be:
- Has anyone experienced similar behavior with system2 and powershell
- Are there maybe any restrictions on the length of args in system2 that I am not aware of?
- Could this be a version issue (between powershell and R)
OS: WINDOWS 10 Enterprise 1803
Other system info: Powershell Version: $PSVersionTable.PSVersion = 5.1.17134 (Rev 765)
R.version:
platform i386-w64-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 3
minor 4.2
year 2017
month 09
day 28
svn rev 73368
language R
version.string R version 3.4.2 (2017-09-28)
nickname Short Summer
Hope someone has useful experience to share …
The case gets even weirder when running the same functionality on a different machine, where the only notable difference are some package versions, everything works like a charm.
Here is a list of the differing librarz versions. But I would never expect that version differences on libraries can or should have any effect on system2
since this is part of the base package. Version.x
is the pkg version on my machine, Version.y
is the version on the machine, where system2
works smoothly, the identical ones are not shown here.
Package Version.x Version.y identical
6 assertthat 0.2.1 0.2.0 FALSE
7 backports 1.1.4 1.1.1 FALSE
13 BH 1.69.0-1 1.65.0-1 FALSE
16 boot 1.3-22 1.3-20 FALSE
20 caTools 1.17.1.1 1.17.1 FALSE
27 codetools 0.2-16 0.2-15 FALSE
28 colorspace 1.4-1 1.3-2 FALSE
36 data.table 1.12.2 1.10.4-3 FALSE
38 DBI 1.0.0 0.7 FALSE
42 digest 0.6.18 0.6.12 FALSE
47 dplyr 0.8.3 0.7.4 FALSE
51 evaluate 0.14 0.10.1 FALSE
63 forecast 8.7 8.2 FALSE
64 foreign 0.8-71 0.8-69 FALSE
65 formatR 1.6 1.5 FALSE
66 Formula 1.2-3 1.2-2 FALSE
70 ggplot2 3.2.0 2.2.1 FALSE
81 gtable 0.3.0 0.2.0 FALSE
83 highr 0.8 0.6 FALSE
90 httr 1.4.0 1.3.1 FALSE
91 httr 1.4.0 1.3.1 FALSE
93 jsonlite 1.6 1.5 FALSE
95 knitr 1.23 1.17 FALSE
98 lattice 0.20-38 0.20-35 FALSE
100 lazyeval 0.2.2 0.2.1 FALSE
102 lme4 1.1-21 1.1-14 FALSE
103 lmtest 0.9-37 0.9-35 FALSE
106 markdown 1.0 0.8 FALSE
107 MASS 7.3-51.4 7.3-47 FALSE
114 mgcv 1.8-28 1.8-20 FALSE
115 mime 0.7 0.5 FALSE
122 munsell 0.5.0 0.4.3 FALSE
124 nlme 3.1-140 3.1-131 FALSE
128 openssl 1.3 0.9.9 FALSE
135 plogr 0.2.0 0.1-1 FALSE
142 quadprog 1.5-7 1.5-5 FALSE
143 quantreg 5.41 5.34 FALSE
147 R6 2.4.0 2.2.2 FALSE
151 Rcpp 1.0.1 0.12.14 FALSE
160 reshape2 1.4.3 1.4.2 FALSE
162 rlang 0.4.0 0.3.99.9003 FALSE
169 rstudioapi 0.10 0.7 FALSE
171 sandwich 2.5-1 2.4-0 FALSE
172 scales 1.0.0 0.5.0 FALSE
175 shiny 1.3.2 1.0.5 FALSE
177 sourcetools 0.1.7 0.1.6 FALSE
188 stringi 1.4.3 1.1.6 FALSE
189 stringr 1.4.0 1.2.0 FALSE
199 tibble 2.1.3 1.3.4 FALSE
200 timeDate 3043.102 3042.101 FALSE
206 tseries 0.10-47 0.10-42 FALSE
207 TTR 0.23-4 0.23-2 FALSE
213 viridisLite 0.3.0 0.2.0 FALSE
215 withr 2.1.2 2.1.0 FALSE
216 XML 3.98-1.19 3.98-1.9 FALSE
218 xtable 1.8-4 1.8-2 FALSE
219 xts 0.11-2 0.10-0 FALSE
220 yaml 2.2.0 2.1.14 FALSE
221 zoo 1.8-6 1.8-0 FALSE
I have come to conclude that this is a RStudio bug - another weird feature for example this command, which will run in RStudios Terminal when R is started in the Terminal but not in RStudios Console.
system2("powershell", args = "Con-XLCube 'Data source=https://someCubeServer/connection/string.dll;Provider=MSOLAP;Initial Catalog=Database;' 'Select Non Empty {[Measures].[Amount]} On Columns, Non Empty ( AddCalculatedMembers ( {[Account].[Account Type].[Account Type].Members} ) * ( ( { [Account].[SAP Account Number].&[1730001202],[Account].[SAP Account Number].&[4917324009],[Account].[SAP Account Number].&[4917325006],[Account].[SAP Account Number].&[4917399001],[Account].[SAP Account Number].&[5977300003],[Account].[SAP Account Number].&[4977300006]} * ( AddCalculatedMembers ( {[Account].[SAP Description Long].[SAP Description Long].Members} ) * ( AddCalculatedMembers ( {[Folder].[Folders Short Name].[Folders Short Name].Members} ) * ( AddCalculatedMembers ( {[Counterparty].[Full Name].[Full Name].Members} ) * ( AddCalculatedMembers ( {[Account].[Legal Entity Partner Code].[Legal Entity Partner Code].Members} ) * ( AddCalculatedMembers ( {[Trade].[Bundle Id].[Bundle Id].Members} ) * ( AddCalculatedMembers ( {[Trade].[EMIR One Confirmation].[EMIR One Confirmation].Members} ) * ( AddCalculatedMembers ( {[Trade].[Internal Reference].[Internal Reference].Members} ) * ( AddCalculatedMembers ( {[Trade].[Trade Id].[Trade Id].Members} ) * ( AddCalculatedMembers ( {[Product].[Product Type].[Product Type].Members} ) * ( AddCalculatedMembers ( {[Product].[EG Product Type].[EG Product Type].Members} ) * ( AddCalculatedMembers ( {[Product].[Product Currency].[Product Currency].Members} ) * ( AddCalculatedMembers ( {[Product].[Product Currency2].[Product Currency2].Members} ) * ( Except ( AddCalculatedMembers ( {[Accounting Event].[Accounting Event Type].[Accounting Event Type].Members} ) , {[Accounting Event].[Accounting Event Type].&[CLOSING]} ) * AddCalculatedMembers ( {[Currency].[Currency].[Currency].Members} ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) On Rows From [Postings] Where ([Processing Org].[Mandant].&[104],[Account].[Standard].&[IFRS],[Booking Date].[Booking Day].&[20190628],[Currency Translation Date].[Day].&[20190628],[Cumulation Type].[Cumulation Type].&[1],[Posting Status].[Posting Status].&[SENT]) Cell Properties VALUE' 'C:\\Users\\USERID\\AppData\\Local\\Temp\\RtmpY9VjYM\\Test.csv'")
I have also noticed that when the command is run in the RStudio Terminal window a powershell message "Searching for Available Modules" flickers up (somehow within/across it). Could this be some process interfering in the RStudio Console but not in RGui and Terminal R? If it so, why does it not interfer on the other machine ("y")? Is there some Powershell setting I am missing or forgot to set or set wrong on machine "x"?