Enable 8.3 short names on Windows and use them for R Services
Check and enable 8.3 short names with fsutil, create a short name for a folder, and apply the method to an R Services installation on drive D:.
Some older programs and scripts still expect the 8.3 short name of a path, such as PROGRA~1 for Program Files. This article shows how to check and enable 8.3 names, create a short name for a folder, and apply the same method to an R Services installation on the D: drive.
Check and enable 8.3 short names
Open a command prompt as administrator:
fsutil 8dot3name query
fsutil behavior set disable8dot3 0
fsutil 8dot3name query D:
The last command checks a single volume (here D:). To see the short names of the items in a folder, use dir /X.
Create a short name for a folder
- Restart Windows in Safe Mode: in
msconfig(%windir%\system32\msconfig.exe), open the Boot tab, select "Safe boot" and "Minimal", then apply and restart. - From a command prompt run as administrator:
fsutil file setshortname "C:\Program Files" PROGRA~1
Temporary workaround to keep scripts working: create a junction.
mklink /J "C:\PROGRA~1" "C:\Program Files"
Example: R Services installed on D:
- Enable 8.3 names on D: (see above).
- Restart in Safe Mode, then create the short names:
fsutil file setshortname "D:\program files" PROGRA~1
fsutil file setshortname "D:\program files\Microsoft SQL Server" MICROS~2
fsutil file setshortname "D:\program files\Microsoft SQL Server\MSSQL13.MSSQLSERVER" MSSQL1~1.MSS
fsutil file setshortname "D:\program files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\R_SERVICES" R_SERV~2
- Install the C compiler toolchain (Rtools33). Copy the packages to a local folder, for example
D:\install\R:sp_1.2-5.tar.gz(source) andrgdal_1.2-5.zip(compiled). - Compile the
sppackage from a command prompt run as administrator:
"D:/Program Files/Microsoft SQL Server/MSSQL13.MSSQLSERVER/R_SERVICES/bin/R.exe" CMD INSTALL --library="D:/Program Files/Microsoft SQL Server/MSSQL13.MSSQLSERVER/R_SERVICES/library" "D:\install\R\sp_1.2-5.tar.gz"
- Install
rgdal:
"D:/Program Files/Microsoft SQL Server/MSSQL13.MSSQLSERVER/R_SERVICES/bin/RScript.exe" -e "install.packages('D:/install/R/rgdal_1.2-5.zip', repos=NULL,lib='D:/Program Files/Microsoft SQL Server/MSSQL13.MSSQLSERVER/R_SERVICES/library')"
Optional alternative from an R session:
libPath <- "D:/Program Files/Microsoft SQL Server/MSSQL13.MSSQLSERVER/R_SERVICES/library"
install.packages("D:/install/R/rgdal_1.2-5.zip", repos=NULL, lib=libPath)
- Test from SQL Server:
EXEC sp_execute_external_script
@language =N'R',
@script=N'library(sp)
OutputDataSet<-data.frame(obj=ls(pos=2)[2:3])',
@input_data_1 =N'SELECT 1 AS hello'
WITH RESULT SETS (([hello] varchar(100) not null));
GO
The test returned two functions from the sp package: addAttrToGeom and areaSpatialGrid.
Notes
MSSQL13.MSSQLSERVERis the folder name of the default instance of SQL Server 2016; replace it with your instance folder.- Short names are set per volume, so the paths must match the drive where the software is installed.
- The
C:path used for the optional R step in the original note was replaced with theD:installation path used everywhere else in this article.