Elixir File.read returns empty data when accessing / proc / cpuinfo
Like @ José, the mentioned proc fs is special because the contents of the file are generated on the fly. If you look at the file sizes in / proc, you will see that they are 0 size.
I believe, therefore, the read function does not return anything, the file is empty!
The workaround is to force read the number of bytes anyway, in Erlang you can do:
{ok, FD} = file:open("/proc/cpuinfo", [read]). file:read(FD, 1024). To read all contents, continue to read a fixed number of bytes until EOF returns with read .
Entries in proc live under a special file system called procfs, and I believe Erlang does not support reading from it. Additional information: https://unix.stackexchange.com/questions/121702/what-happens-when-i-run-the-command-cat-proc-cpuinfo