make deploy-managed-agent.sh run on windows - #116
Open
rootkiller6788 wants to merge 2 commits into
Open
Conversation
Path.read_text() uses the locale default encoding, so on a non-utf-8 system (windows, gbk) it chokes on the em-dashes and accented chars that appear in the cookbook schemas. Make the read explicit.
Two things break the script on windows/git-bash:
1. The python in yaml2json opens the manifest with the locale default
encoding, which is gbk on a Chinese windows box. The cookbook yaml
is utf-8 (em-dashes everywhere), so safe_load blows up.
2. The native jq.exe writes CRLF line endings. Every $(jq -r ...)
value carries a trailing carriage return, so `-d` on a skill path
fails ("skill path not found"), the system.file existence check
misses, and the DRYRUN_<name> 1 lines are passed to --argjson with
a trailing CR, which jq refuses to parse as a number.
Read the manifest as utf-8 and strip CR from jq output lines. The
pipes are no-ops on unix where jq emits plain LF.
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tried to run the cookbook checks on a Windows box and they fell over in two ways.
validate.py and the yaml2json helper in the deploy script read files with the locale default encoding. On a system where that isn't utf-8 (Windows defaults to gbk), the cookbook yaml — which is full of em-dashes — blows up with UnicodeDecodeError before validation even starts.
The deploy script reads every
$(jq -r ...)value without trimming carriage returns. The native jq.exe on Windows emits CRLF line endings, so a skill path comes back as.../cold-start-interview\r.[[ -d ]]then fails with "skill path not found", and the dry-run agent ids get a trailing CR that jq refuses to parse as a number in--argjson.The fix is small and safe: read the manifests as utf-8 explicitly, and pipe jq output through
tr -d '\r'. On Linux/macOS jq emits plain LF, so those pipes are no-ops.Verified on Windows/git-bash: before the change
deploy-managed-agent.sh reg-monitor --dry-rundied with "skill path not found"; after it, all five cookbooks dry-run clean andscripts/test-cookbooks.shpasses.