dlang / dub

Package and build management system for D
MIT License
676 stars 227 forks source link

`dub convert -s -f json > dub.json` fails #1649

Open ghost opened 5 years ago

ghost commented 5 years ago

On linux, cd to DUB repository and execute

dub convert -s -f json > dub.json

to get an empty json and the message

rawRead must take a non-empty buffer

This is minor issue since to convert to a file we can just do

dub convert -f json
WebFreak001 commented 5 years ago

Piping seems to create a new file before dub is executed which dub seems to prefer. It should probably prefer dub.sdl over dub.json (or other way around) if one of them is empty

Geod24 commented 5 years ago

This is not a dub issue, but a common issue when trying to process a file and write to it. The > is executed first, opening and clearing the file. Try cat dub.json > dub.json and you will get the same result.

WebFreak001 commented 5 years ago

there is still an issue that dub uses an empty dub.json over a functional dub.sdl with that though

Geod24 commented 5 years ago

Right, I missed the part where there is only a dub.sdl and no dub.json to begin with.

Sounds like a simple enough fix, but it leads to another question: what if dub.json is malformed ? Or well-formed but doesn't build ? Under which condition(s) should such a fallback happen ?

WebFreak001 commented 5 years ago

I would just complain if both contain something and ignore a completely empty one just for this purpose. Though maybe it's not the cleanest way to do. Maybe piping into a different file and moving afterwards would be the cleanest way to do this after all