alexemanuelol / rustplusplus

A NodeJS Discord Bot that uses the rustplus.js library to utilize the power of the Rust+ Companion App with additional Quality-of-Life features.
GNU General Public License v3.0
198 stars 99 forks source link

Error: ENOENT: no such file or directory, open './src/resources/images/maps/1013878657959350352_map_clean.png #63

Closed fakerli closed 2 years ago

fakerli commented 2 years ago

When I try to start the service after server reboot it doesn't work:

Error: ENOENT: no such file or directory, open './src/resources/images/maps/1013878657959350352_map_clean.png' at Object.openSync (node:fs:594:3) at Object.writeFileSync (node:fs:2207:35) at Map.writeMapClean (/home/rustplus/rustPlusPlus/src/structures/Map.js:252:18) at Map.resetImageAndMeta (/home/rustplus/rustPlusPlus/src/structures/Map.js:246:20) at new Map (/home/rustplus/rustPlusPlus/src/structures/Map.js:201:14) at Object.execute (/home/rustplus/rustPlusPlus/src/rustplusEvents/connected.js:48:28) at processTicksAndRejections (node:internal/process/task_queues:96:5) { errno: -2, syscall: 'open', code: 'ENOENT', path: './src/resources/images/maps/1013878657959350352_map_clean.png'

The files in this directory are:

rustplus@xxx:~/rustPlusPlus/src/resources/images/maps$ ls 1013878657959350352_map_clean.png 1013878657959350352_map_full.png 388411283105644555_map_clean.png 388411283105644555_map_full.png

fakerli commented 2 years ago

if I change the code in Map.js from

image: ./src/resources/images/maps/${this.rustplus.guildId}_map_clean.png,

to

image: /home/rustplus/rustPlusPlus/src/resources/images/maps/${this.rustplus.guildId}_map_clean.png,

it hangs at:

[Error: ENOENT: no such file or directory, open './src/resources/fonts/PermanentMarker.fnt'] { errno: -2, code: 'ENOENT', syscall: 'open', path: './src/resources/fonts/PermanentMarker.fnt'

fakerli commented 2 years ago

It works if I cd into the dir but not if I use node /home/rustplus/rustPlusPlus/.

psykzz commented 2 years ago

It's because file open is based on process.cwd(), not on __dirname. If you want to try out the docker branch it will resolve that issue.

alexemanuelol commented 2 years ago

Fixed in cd67be375a203ebd5c8e869482e2d98c36ff56d0