Failed to read configuration file. endpoints.ps1


I loop on this error: “Failed to read configuration file. Endpoints.ps1” and since then, impossible to use anything related to APIs.

Here are the logs :

2021-05-27T12:35:08.0664306+02:00  [INF] User profile is available. Using '"C:\Users\bsatoolsadmin\AppData\Local\ASP.NET\DataProtection-Keys"' as key repository and Windows DPAPI to encrypt keys at rest. (7ac5e29c)
2021-05-27T12:35:08.3353052+02:00  [INF] Starting sync... (a444e9b8)
2021-05-27T12:35:13.2858623+02:00  [INF] Starting C:\Program Files\PowerShell\7\pwsh.exe with command line  -NonInteractive -NoProfile -Command "& { [System.Reflection.Assembly]::LoadFrom('C:\Program Files (x86)\Universal\Host.dll') | Out-Null; [UniversalHost.AgentService]::StartApi(56837, 8084) }" (6eeeb9d3)
2021-05-27T12:35:13.2861026+02:00  [INF] Starting job using Process. (4d0a5a43)
2021-05-27T12:35:13.3252128+02:00  [ERR] Failed to read configuration file. endpoints.ps1 (71f87318)
System.ComponentModel.Win32Exception (2): The system cannot find the file specified.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at UniversalAutomation.JobProcessManager.StartProcessAsCurrentUser(String powerShellPath, String commandLine, Variable credential) in D:\a\universal\universal\src\Universal.Server\Services\JobProcessManager.cs:line 206
   at UniversalAutomation.JobProcessManager.StartApiProxy(Int32 port, ExecutionEnvironment environment) in D:\a\universal\universal\src\Universal.Server\Services\JobProcessManager.cs:line 227
   at Universal.Server.Services.ApiProxy.Start() in D:\a\universal\universal\src\Universal.Server\Services\ApiProxy.cs:line 101
   at Universal.Server.Services.ApiProxy.AddEndpointAsync(Endpoint callback) in D:\a\universal\universal\src\Universal.Server\Services\ApiProxy.cs:line 399
   at UniversalAutomation.Services.EndpointsConfigurationScript.OnReadAfterAddAsync(Endpoint endpoint) in D:\a\universal\universal\src\UniversalAutomation\Services\Configuration\Endpoints.cs:line 24
   at UniversalAutomation.Services.ConfigurationScript`1.ReadAsync(Boolean initialSync) in D:\a\universal\universal\src\UniversalAutomation\Services\Configuration\ConfigurationScript.cs:line 185
2021-05-27T12:35:14.1976478+02:00  [INF] Starting job using Process. (4d0a5a43)

I have already tried the following solutions:

  • stop the Powershell Universal service
  • delete all the contents of the repository folder
  • restart the service and wait for the git sync
    Same error message!
  • stop the Powershell Universal service
  • delete all the contents of the repository folder and the database.db file
  • restart the service and wait for the git sync
    Same error message!
  • stop the Powershell Universal service
  • delete the endpoint.ps1 file from VS Code and do a git sync
  • restart the service and wait for the git sync
  • Create a test endpoint with the web interface
    Same error message!
  1. Same thing but recreating the endpoint directly in the file.
    Same error message!

  • reinstall PowerShell Universal with the MSI
    Same error message

I’m running out of ideas on how to fix this problem.

Product: PowerShell Universal
Version: 1.5.19

It failing to launch powershell. What do you have in your settings.ps1 and environments.ps1?

Once again, thank you @adam

After commenting on the PowerShell 7 line in environments.ps1, I have no more worries.

I had to make a modification from my personal pc because the development server was not reachable, I suppose that is when the environments.ps1 file was automatically modified to list the versions of PowerShell that i have on this machine. Then the git synchronization sent the changes to my server.

A big thank you because I could have looked for a while and above all I could have reproduced the error without knowing.