snowtrack / snowfs

SnowFS v1 - a fast, scalable version control file storage for graphic files :art:
https://www.snowtrack.io
GNU General Public License v3.0
1.3k stars 43 forks source link

Error: spawn lsof ENOENT on snow init #247

Open belkarx opened 3 years ago

belkarx commented 3 years ago

Describe the bug After compiling snow, if I try to run snow init (while in a newly created directory), node spits out

node:events:342
      throw er; // Unhandled 'error' event
      ^

Error: spawn lsof ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
    at onErrorNT (node:internal/child_process:480:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
    at onErrorNT (node:internal/child_process:480:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn lsof',
  path: 'lsof',
  spawnargs: [ '-X', '-F', 'pcan', '+D', 'hey' ]
}

The .snow folder is still created, however if I try to run snow add . (and a few other snow commands), I get the error

No HEAD found
fatal: no reference nor HEAD found

In .snow/log/mainlog, there is 1 line: 1633564812686 -0700 $> init: initialized at /home/[filepath]/test_snow, so the repo seems to have initialized successfully, but all other (non-log) folders in .snow are empty.

To Reproduce Steps to reproduce the behavior: [be using zsh/linux/ext4]

  1. Compile snow via the instructions on the README
  2. Create a folder, switch to it, and snow init ^ this will cause a node error
  3. copy a file into the current folder and execute snow add . ^ this will raise a "no HEAD found" error

Expected behavior snow init shouldn't throw any errors, and snow add . shouldn't fail

Desktop (please complete the following information):

Additional context I'm a node newbie so maybe I made some sort of obvious mistake ... if I did, I'm sorry for wasting your time

sebastianrath commented 3 years ago

Hey belkrax, thanks so much for your report! Interesting, it seems your Linux OS doesn't support lsof. If you change this line:

https://github.com/Snowtrack/snowfs/blob/c1e27daaf92b79c9524c5d8cf8a70e600862b1d8/src/io_context.ts#L700

to

return Promise.resolve();

you should be more successful. Could you try this again and we go to the next step to find a solution for the missing lsof process on your system.

belkarx commented 3 years ago

I grabbed the lsof package (in hindsight the issue was obvious but I'm unused to node error messages) and everything works now. Thank you!

sebastianrath commented 3 years ago

I still think there is room for improvement in this code. We can either improve the error message, find an alternative on Linux, or skip lsof on machines where it doesn't exist