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

By:   |   Comments (7)   |   Related: > SQL Server 2016


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


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



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.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips



Comments For This Article




Friday, March 1, 2024 - 3:10:50 PM - Mike Back To Top (92031)
It does not work in Win 11 and SQL Server 2022. Can you create a new article about it?

Thursday, April 9, 2020 - 2:33:19 AM - Gert Kruger Back To Top (85308)

Thank you for some direction on this.  I changed the working directory by moving it to a location which did not contain any spaces in the file path and checked permissions but that did not work.  However, after changing the directory to the shorter path description E:\R\ExtensibilityData (without changing any permissions), it worked.  It seems to me that the length of the file system path was the issue rather than permissions in my case.


Wednesday, May 16, 2018 - 11:50:27 AM - mv_gibson Back To Top (75955)

 

 Thank you for this!  I ran into the same error when trying to get started, and this was a quick fix.  Just to note for others, depending on your install and upgrades, the ExtensibilityData folder may be in a previous or later version of the MSSQL1* folders...look around for it or pay attention when you open the rlauncher.config file...it may lead you to the correct folder.


Thursday, February 9, 2017 - 8:21:22 AM - Vitor Montalvão Back To Top (46132)

 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 9, 2017 - 5:50:41 AM - Burt Back To Top (46125)

 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 2, 2017 - 7:47:57 AM - Vitor Montalvão Back To Top (45803)

 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 2, 2017 - 6:44:45 AM - Burt Back To Top (45801)

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

Any other clues please

 















get free sql tips
agree to terms