You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Newline management is complicated because of the differences between different systems like Windows (CRLF) and Linux/Unix (LF). The general wisdom is for editors and tools to either always use the native newline encoding of the OS or to respect the encoding found in the file. However, our observation is that vcpkg.exe on Windows will happily turn the CRLF encoding of all the newlines in the vcpkg.json file from CRLF to LF, even if there's no other change done to the file (if the baseline doesn't change).
Environment
OS: Windows 11
Compiler: No compiler. We get vcpkg via Nuget feed internal to Microsoft. Version says "2024-08-01-fd884a0d390d12783076341bd43d77c3a6a15658". Internal package is Microsoft.Build.Vcpkg, version 2024.9.23.234-98aa63962.
To Reproduce
Steps to reproduce the behavior:
Ensure there's a valid vcpkg.json file using Windows newline encoding (CRLF).
Run "vcpkg.exe x-update-baseline --add-initial-baseline" command.
Verify the newline encoding of the file now, it will have been changed to LF.
Expected behavior
Expect either the native OS newline encoding (CRLF) or the same encoding found in the file (if preexisting), to be used when writing any text files.
Failure logs
This is a behavioral failure. I don't think logs are relevant, but can provide them given instructions.
Additional context
We were adding the "vcpkg.exe x-update-baseline --add-initial-baseline" command to an automated script in order to keep the baseline up to date, but as soon as it's run the file becomes modified according to git (with "core.autocrlf=true").
vcpkg should strive to be user-friendly in everything it does. I find this anything but. I can see in the tool's source that the original JSON implementer added a newline to the JsonStyle structure, but:
It's default-initialized to Lf.
It's set to CrLf in vcpkg::Json::<unnamed>::Parser::next(), but that style is not preserved to be used when writing the file back.
Instead the vcpkg::Json::parse_object() function abandons it so the stringizer that converts the JSON back to string form uses the default-initialized Lf in its JsonStyle structure.
The fact that the parser sets this style but doesn't really use it seems to indicate that the original intent was to use it when writing back the file, but this was likely never done.
This discussion was converted from issue #41227 on September 29, 2024 10:22.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Describe the bug
Newline management is complicated because of the differences between different systems like Windows (CRLF) and Linux/Unix (LF). The general wisdom is for editors and tools to either always use the native newline encoding of the OS or to respect the encoding found in the file. However, our observation is that vcpkg.exe on Windows will happily turn the CRLF encoding of all the newlines in the vcpkg.json file from CRLF to LF, even if there's no other change done to the file (if the baseline doesn't change).
Environment
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Expect either the native OS newline encoding (CRLF) or the same encoding found in the file (if preexisting), to be used when writing any text files.
Failure logs
This is a behavioral failure. I don't think logs are relevant, but can provide them given instructions.
Additional context
We were adding the "vcpkg.exe x-update-baseline --add-initial-baseline" command to an automated script in order to keep the baseline up to date, but as soon as it's run the file becomes modified according to git (with "core.autocrlf=true").
vcpkg should strive to be user-friendly in everything it does. I find this anything but. I can see in the tool's source that the original JSON implementer added a newline to the
JsonStyle
structure, but:Lf
.CrLf
invcpkg::Json::<unnamed>::Parser::next()
, but that style is not preserved to be used when writing the file back.Instead the
vcpkg::Json::parse_object()
function abandons it so the stringizer that converts the JSON back to string form uses the default-initializedLf
in itsJsonStyle
structure.The fact that the parser sets this style but doesn't really use it seems to indicate that the original intent was to use it when writing back the file, but this was likely never done.
I may be convinced to implement a fix.
Beta Was this translation helpful? Give feedback.
All reactions