Open apintorp opened 1 year ago
For those of you who don't want to download and extract the contents of the zip file, I've done this in a sandbox and provide the content of the captain-definition contained within:
{
"schemaVersion": 2,
"dockerfilePath": "./Dockerfile"
}
The contents of the file include CRLF Windows formatted return lines. The file needs to have these changed to normal line feed, or just LF. This would be denoted as a \n or would appear as LF in some editors.
I remove CRs
and also remove everything
still happen same issue
How are you attempting to deploy your app?
Ok, after reviewing the code I found out that on the file utils\ValidationsHandler.ts
there is the function function validateDefinitionFile()
to validate the captain-definition
file.
There is this lines of code where specified that the file be will read it with encode utf8:
content = JSON.parse(
fs.readFileSync('./captain-definition', 'utf8')
)
In my case my file was encoded on UTF8-BOM so the wrong encoding make the JSON.Parserand fail. After convert it to UTF8 now it works. The git commit shows that the file was changed after the conversion.
I was about to start writing a fix to this but I ignore what are the side effects about this particular issue since it can actually break the caprover server.
So I just let you know guys what I found so you can decide the best approach to it.
Byte Order Marked files have crept up periodically in the last 25+ years of my software development experience. Often, they appear after the corrupt file transfers over FTP or going between Mac and PC. I've also seen them created out of thin air by editing an existing file in Nodepad.exe in Windows.
Super annoying. I'm glad it's solved.
Now that you mention Windows Notepad.exe, I saw when the developer create the captain-definition file and, guest what? He use it to created the file.
Please add a warning on the documentation that don't create or edit the files with Windows Notepad.
Thanks so much for your help @maietta
What is the problem? When trying to deploy app via CLI, no matter all the format fixes we try, caprover cli keeps saying the definition file is not a valid Json
Steps to reproduce the problem: Just try to run the command over the attached file on zip
caprover deploy
Windows 11 Caprover Cli Version 2.2.3 Node Version v18.14.0
Output of the following command on your server: captain-definition.zip