LLI Wiki — My Digital Knowledge Base

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

  1. Restart Windows in Safe Mode: in msconfig (%windir%\system32\msconfig.exe), open the Boot tab, select "Safe boot" and "Minimal", then apply and restart.
  2. 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:

  1. Enable 8.3 names on D: (see above).
  2. 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
  1. 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) and rgdal_1.2-5.zip (compiled).
  2. Compile the sp package 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"
  1. 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)
  1. 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

Mastodon LLIMastodon SocialFosstodon