status-im / nim-stew

stew is collection of utilities, std library extensions and budding libraries that are frequently used at Status, but are too small to deserve their own git repository.
139 stars 18 forks source link

io2 readAllBytes / readAllFile does not work at compile time #145

Open kdeme opened 1 year ago

kdeme commented 1 year ago

Using readAllBytes / readAllFile / ... or rather the underlying readFile cannot be used at compile time because of usage of toOpenArray. Hitting practically this issue: https://github.com/nim-lang/Nim/issues/19969

Circumventing the usage of toOpenArray makes you then hit:

`/nim-stew/stew/io2.nim(1220, 21) Error: cannot 'importc' variable at compile time; stat`

Which has to do with posix.stat usage for getting the file size.

I realize that these are more Nim issues than nim-stew/io2 issues, but still creating an issue here to track, as because of this I end up working around it by still using std/io its readFile. (Same appears to have been done in nimbus-eth2).

ringabout commented 1 year ago

https://github.com/nim-lang/Nim/issues/19969 has been fixed by https://github.com/nim-lang/Nim/pull/20586