This article describes a scenario in which you created or edited a requirements.txt file while in your Workspace and did not sync your project files. Now when you try to restart your Workspace, you are getting a message that there is an error in your requirements.txt file and your Workspace will not start.
An error in your requirements.txt prevents your Workspace from starting, but you can't edit it because you never synced it to your Project Files.
Since the requirements.txt file is read and run with each execution, this file essentially syncs itself without any explicit sync action being performed. This means that you can eventually get a valid version of your requirements.txt synced between your Project Files and Workspace, it just takes a few attempts at starting the Workspace.
This situation and resolution is described below:
requirements.txt is Created in the Workspace
I've made a new requirements.txt in my Workspace, which for demo purposes has an intentionally invalid line.
I stopped my Workspace without syncing my changes, meaning there is no requirements.txt in my Project Files.
Error at next Workspace startup
Even though I didn't sync my requirements.txt file, it still exists in my Workspace and is going to be read the next time I start my Workspace. However, due to the invalid text, my Workspace errors and will not start!
Editing the requirements.txt
Even though my attempt at restarting my Workspace failed, my requirements.txt was run and has appeared in my Project Files. I can now open it and edit it to fix my invalid text.
Starting my Workspace Again
I saved my edits to requirements.txt and now I'll start my Workspace again. But as we can see it's errored out again! Even though my requirements.txt file was updated in the Project Files, the one inside my Workspace was not updated yet. However, even though this Workspace startup has failed, when the requirements.txt file was run it updated the version that existed in my Workspace.
Starting my Workspace Again...Again
Though my last attempt at starting my Workspace failed, it made one valuable change to the requirements.txt file in the Workspace: it updated it to match the edited version I made in my Project Files. So, if I go to start my Workspace again...
Success! The Workspace opens, and we can see that the changes I applied to the requirements.txt from the Project Files dashboard have been applied.
*Note: this process might create a file called "requirements-theirs-deleted.txt". You can review the contents of this file, but in most situations you won't need anything from there and it's fine to delete it.
If you are facing this issue but no requirements.txt appears in the Project Files, there is another workaround to attempt which involves creating a new Environment to rename the requirements.txt file: Creating an Environment to rename the requirements.txt file in your Workspace