mikefarah / yq

yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor
https://mikefarah.gitbook.io/yq/
MIT License
12.36k stars 602 forks source link

Windows 11: [ERROR] Failed to remove temp file at file_utils.go:25 tryRemoveTempFile #2020

Open eissar opened 7 months ago

eissar commented 7 months ago

yq (https://github.com/mikefarah/yq/) version v4.43.1 Operating system: Windows 11 24H2 Attempted choco install /exe Install from releases, same error on each.

The command I ran:

yq --front-matter=extract 01.md --verbose

Was trying to get the front matter of a single file so I could try doing more complex things. The yaml front matter is just:

---
date: "2024-04-01"
---

But running

yq --front-matter=extract 01.md

Prints to console: date: "2024-04-01" [ERROR] 00:01:07 Failed to remove temp file: C:\Users\USER\AppData\Local\Temp\temp815380285

The function looks like it's literally just calling "os.Remove" so it's pretty strange. Would appreciate any help or quick guidance! Tomorrow will try installing on another windows machine to see if I get the same error.

Verbose command output below: yq --front-matter=extract 01.md --verbose [DEBUG] 23:54:22 utils.go:174 maybeFile checking '01.md' is a file [DEBUG] 23:54:23 utils.go:181 maybeFile error: , dir: false [DEBUG] 23:54:23 utils.go:183 maybeFile result: true [DEBUG] 23:54:23 utils.go:236 processArgs processed args: [01.md] [DEBUG] 23:54:23 utils.go:174 maybeFile checking '01.md' is a file [DEBUG] 23:54:23 utils.go:181 maybeFile error: , dir: false [DEBUG] 23:54:23 utils.go:183 maybeFile result: true [DEBUG] 23:54:23 format.go:112 FormatStringFromFilename checking file extension '01.md' for auto format detection [DEBUG] 23:54:23 format.go:116 FormatStringFromFilename detected format 'md' [DEBUG] 23:54:23 utils.go:72 initCommand Unknown file format extension 'md', defaulting to yaml [DEBUG] 23:54:23 utils.go:97 initCommand Using input format yaml [DEBUG] 23:54:23 utils.go:98 initCommand Using output format yaml [DEBUG] 23:54:23 evaluate_sequence_command.go:119 evaluateSequence using front matter handler [DEBUG] 23:54:23 front_matter.go:61 Split yamlTempFile: C:\Users\USER\AppData\Local\Temp\temp3702331487 [DEBUG] 23:54:23 expression_parser.go:28 ParseExpression Parsing expression: [] [DEBUG] 23:54:23 expression_postfix.go:46 ConvertToPostfix postfix processing currentToken ) [DEBUG] 23:54:23 expression_postfix.go:126 ConvertToPostfix opstackLen: 0 [DEBUG] 23:54:23 expression_postfix.go:137 ConvertToPostfix PostFix Result: [DEBUG] 23:54:23 candidate_node_yaml.go:109 UnmarshalYAML UnmarshalYAML !!map [DEBUG] 23:54:23 candidate_node_yaml.go:122 UnmarshalYAML UnmarshalYAML - a mapping node [DEBUG] 23:54:23 candidate_node_yaml.go:109 UnmarshalYAML UnmarshalYAML !!str [DEBUG] 23:54:23 candidate_node_yaml.go:117 UnmarshalYAML UnmarshalYAML - a scalar [DEBUG] 23:54:23 candidate_node_yaml.go:109 UnmarshalYAML UnmarshalYAML !!str [DEBUG] 23:54:23 candidate_node_yaml.go:117 UnmarshalYAML UnmarshalYAML - a scalar [DEBUG] 23:54:23 candidate_node_yaml.go:145 UnmarshalYAML UnmarshalYAML - finished mapping node [DEBUG] 23:54:23 data_tree_navigator.go:54 GetMatchingNodes getMatchingNodes - nothing to do [DEBUG] 23:54:23 printer.go:73 PrintResults PrintResults for 1 matches [DEBUG] 23:54:23 printer.go:100 PrintResults print sep logic: p.firstTimePrinting: false, previousDocIndex: 0 [DEBUG] 23:54:23 printer.go:101 PrintResults D0, P, MappingNode (!!map)::2 kids [DEBUG] 23:54:23 encoder_yaml.go:77 Encode encoderYaml - going to print D0, P, MappingNode (!!map)::2 kids [DEBUG] 23:54:23 candidate_node_yaml.go:182 MarshalYAML MarshalYAML to yaml: !!map [DEBUG] 23:54:23 candidate_node_yaml.go:201 MarshalYAML original style: 0 [DEBUG] 23:54:23 candidate_node_yaml.go:202 MarshalYAML original: D0, P, MappingNode (!!map)::2 kids, tag: !!map, style: 0, kind: false [DEBUG] 23:54:23 candidate_node_yaml.go:182 MarshalYAML MarshalYAML to yaml: !!str [DEBUG] 23:54:23 candidate_node_yaml.go:190 MarshalYAML MarshalYAML - scalar: date [DEBUG] 23:54:23 candidate_node_yaml.go:182 MarshalYAML MarshalYAML to yaml: !!str [DEBUG] 23:54:23 candidate_node_yaml.go:190 MarshalYAML MarshalYAML - scalar: 2024-04-01 date: "2024-04-01" [DEBUG] 23:54:23 printer.go:150 PrintResults done printing results [DEBUG] 23:54:23 file_utils.go:25 tryRemoveTempFile Removing temp file: C:\Users\USER\AppData\Local\Temp\temp3702331487 [ERROR] 23:54:23 file_utils.go:28 tryRemoveTempFile Failed to remove temp file: C:\Users\USER\AppData\Local\Temp\temp3702331487

eissar commented 7 months ago

Getting the same error on a different fresh windows install. yq (https://github.com/mikefarah/yq/) version v4.43.1, windows 11 23H2. Installed from winget.

mikefarah commented 5 months ago

Weird - yq does create a temporary file when processing front-matter; seems like the OS doesn't let it clean up after. Not sure why that would be the case. That said, although it logs an error it should still complete; just means there will be extra temp files in that temp directory...

shemraz commented 5 months ago

Also getting this error from installation of v4.44.2 via scoop, running Windows 11 24H2. Might become more of an inconvenient issue if running yq inside a loop, i.e. in a script.