Learn more about SQL Server tools

mssqltips logo
 

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Whitepapers          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories

 

Unable to communicate with the runtime for 'R' script in SQL Server


By:   |   Read Comments (4)   |   Related Tips: More > SQL Server 2016

Quickly Resolve Performance Problems for IIS, .NET and SQL Server       >>>   Get Started


Problem

When trying to run R scripts in SQL Server a runtime error for 'R' script was raised.  You get the following error "Unable to communicate with the runtime for "R" script. Please check the requirements of 'R' runtime". This is shown in the below screenshot.  What does this mean and how do you fix this?

Unable to communicate with the runtime for "R" script. Please check the requirements of 'R' runtime
Solution

The error message might make you think it is a permission issue, but if you are familiar with 'R' you might know that 'R' doesn't like spaces in the folder path and this is what we are going to investigate.

This issue is related to the working directory for the R Services and if you are facing this error, the first thing to do is check the path for the working directory for R Services. If you didn't change the default file locations during the R Services installation then there is a good chance that the R Services working directory path has folder names with spaces and it's necessary to change the working directory to a path with no spaces.

Changing R Services Working Directory

To change the working directory, edit the rlauncher.config file that can be found in C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn (default location).

Changing R Services Working Directory

If your disk is formatted to accept old 8.3 format file names you can just set the working directory with this format:

If your disk is formatted to accept old 8.3 format file names you can just set the working directory with this format

Alternatively you can change the working directory to a path that doesn't have spaces in the folder names and save the file.  If you do this you will need to copy the full subfolder structure and grant necessary permissions for the R accounts (see next section).

Alternatively you can change the working directory to a path that doesn't have spaces in the folder names

Moving R Services Subfolder and Files (only if working directory moved)

This step only needs to be done if you changed the working directory location.

I used robocopy to copy the entire folder structure. I used the (/E) to get all folders and files and the (/SEC) to keep the respective folder permissions.

robocopy C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\ExtensibilityData C:\R\ExtensibilityData /E /SEC

Note that target folder should already be created and the correct permissions set for the MSSQLLaunchpad service account.

Note that target folder should already be created and the correct permissions set for the MSSQLLaunchpad service account

Check all subfolders to make sure the correct permissions have been set for the MSSQLLaunchpad service account and respective MSSQLSERVERnn account.

Check all subfolders to make sure the correct permissions have been set for the MSSQLLaunchpad service account and respective MSSQLSERVERnn account

Restart SQL Server Launchpad Service

Restart the MSSQLLaunchpad service.

Restart SQL Server Launchpad Service

You should now be able to run the 'R' script without any more issues.

You should now be able to run the 'R' script without any more issues
Conclusion

When I wrote this tip there was not much information in Microsoft's documentation about the issue with spaces in folder names for R Services.  Fortunately this is somewhat well known with people that work with 'R', so with a little research and troubleshooting I was able to get this working.  Hopefully this tip can help someone in the future that faces this issue and has no clue how to solve it.

Next Steps


Last Update:


signup button

next tip button



About the author
MSSQLTips author Vitor Montalvao Vitor Montalv„o is a SQL Server engineer with 20 years of experience in SQL Server, specializing in performance & tuning, data modelling, migration and security.

View all my tips
Related Resources





Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Notify for updates 


SQL tips:

*Enter Code refresh code     



Thursday, February 09, 2017 - 8:21:22 AM - Vitor Montalv„o Back To Top

 Thank you for the update.

I did an update from RTM to SP1 but never did an update from CTP (usually I just delete the VM and create a new one when working with CTP).

 

Cheers.


Thursday, February 09, 2017 - 5:50:41 AM - Burt Back To Top

 Thanks Vitor,

R Services was installed at the same time.

I set the working directory path with a 8.3 format file name, and did restart the Launchpad service successfully.

It seems that there are CTP versions of R Services hanging around on this PC, which apparantly I need to uninstall first.

https://msdn.microsoft.com/en-US/library/mt653951.aspx

 

 


Thursday, February 02, 2017 - 7:47:57 AM - Vitor Montalv„o Back To Top

 Hi Burt,

Did you install R Services at same time that you installed SQL Server 2016 instance?

I'm asking that because if you installed after, make sure you apply the same hotfixes as you applied for your SQL Server 2016 instance (they should me at same version level).

And just for check, did you set the working directory path with a 8.3 format file name or did you go for moving the working directory to a new folder without spaces in the name?

And for sanity check, restart the Launchpad service after performing the necessary changes in the config file.

Cheers


Thursday, February 02, 2017 - 6:44:45 AM - Burt Back To Top

 folder path appears to be ok ad folder permissions, but I am still getting this error.

Any other clues please

 


Learn more about SQL Server tools