MerosCrypto / Meros

An instant and feeless cryptocurrency for the future, secured by the Merit Caching Consensus Mechanism.
https://meroscrypto.io
Other
82 stars 19 forks source link

Setting data-dir with absolute path fails with OSError #256

Closed jerrosenberg closed 3 years ago

jerrosenberg commented 3 years ago

Running: ./Meros --data-dir /var/local/Meros

Results in:

/usr/local/src/Meros/Meros/src/Meros.nim(22) Meros
/usr/local/src/Meros/Meros/src/objects/ConfigObj.nim(311) newConfig
/nim/lib/system/assertions.nim(29) failedAssertImpl
/nim/lib/system/assertions.nim(22) raiseAssert
/nim/lib/system/fatal.nim(49) sysFatal
Error: unhandled exception: /usr/local/src/Meros/Meros/src/objects/ConfigObj.nim(311, 13) `false` Couldn't create 
the data directory due to an OSError: No such file or directory [AssertionError]

Running this works fine: ./Meros --data-dir "../../../../var/local/Meros"

kayabaNerve commented 3 years ago

Are you missing a ../? One to Meros, one to src, one to local, one to usr. That ends up as /usr/var/local/Meros (resolved relative), no?

jerrosenberg commented 3 years ago

No, my working directory is /usr/local/bin/meros/. The issue is not for running with the relative path. It's failing on the absolute path.

jerrosenberg commented 3 years ago

The culprit is here I believe: https://github.com/MerosCrypto/Meros/blob/master/src/objects/ConfigObj.nim#L307-L309

For an absolute path the first segment of the split is empty string.

kayabaNerve commented 3 years ago

Got it. I was confused about your working directory so I just wanted to rule that out.

Good catch :) Thanks for doing my work for me. I'll push out a fix before the net today.

kayabaNerve commented 3 years ago

@jerrosenberg Fixed! Thank you again for reporting this.