Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
When using R in power bi, I get the following error
Details: "ADO.NET: R script error.
Error in setwd("~/Documents/R") : cannot change working directory
Calls: .First -> options -> setwd
Can you please help me?
Cheers Jeff.
Solved! Go to Solution.
Hi @puskas63 ,
try below steps
Check the directory path: Verify that the directory "/Documents/R" exists and is accessible. Ensure that the tilde () is correctly interpreted as your home directory. You can try providing an absolute path instead, such as "C:/Users/YourUsername/Documents/R", to ensure accuracy.
Verify permissions: Make sure you have the necessary permissions to access and modify the directory. Ensure that you have read and write permissions for the directory "~/Documents/R" or the absolute path you're using.
Use a different working directory: Instead of changing the working directory in your R script, consider using absolute paths for any files or directories you need to access within your script. This eliminates the need to change the working directory and avoids potential issues related to directory changes.
Check R runtime environment: Ensure that the R runtime environment in Power BI has the necessary privileges to modify directories. You may need to consult your IT department or system administrator to verify the R runtime environment's permissions.
Try a different location: If changing the working directory is not essential for your script, you can try running it without modifying the directory. This approach avoids potential conflicts related to directory changes.
Update R packages: Make sure you have the latest versions of R packages installed in your R environment. Outdated packages might cause compatibility issues or unexpected behavior.
Hi @puskas63 ,
try below steps
Check the directory path: Verify that the directory "/Documents/R" exists and is accessible. Ensure that the tilde () is correctly interpreted as your home directory. You can try providing an absolute path instead, such as "C:/Users/YourUsername/Documents/R", to ensure accuracy.
Verify permissions: Make sure you have the necessary permissions to access and modify the directory. Ensure that you have read and write permissions for the directory "~/Documents/R" or the absolute path you're using.
Use a different working directory: Instead of changing the working directory in your R script, consider using absolute paths for any files or directories you need to access within your script. This eliminates the need to change the working directory and avoids potential issues related to directory changes.
Check R runtime environment: Ensure that the R runtime environment in Power BI has the necessary privileges to modify directories. You may need to consult your IT department or system administrator to verify the R runtime environment's permissions.
Try a different location: If changing the working directory is not essential for your script, you can try running it without modifying the directory. This approach avoids potential conflicts related to directory changes.
Update R packages: Make sure you have the latest versions of R packages installed in your R environment. Outdated packages might cause compatibility issues or unexpected behavior.