getmango / Mango

Mango is a self-hosted manga server and web reader
https://getmango.app
MIT License
1.7k stars 120 forks source link

[Bug Report] `./mango` tries to create directory `./mango` #248

Closed DDzwiedziu closed 2 years ago

DDzwiedziu commented 2 years ago

Describe the bug I was following the guide from https://getmango.app/#/?id=quick-start Mango, when run for the first time, tries to create a directory by default named "mango" (probably here: https://github.com/hkalexling/Mango/blob/8a732804ae05d4480afd0646445acabc6808bdce/src/storage.cr#L38).

bookserver@bookserver:~$ chmod +x mango
bookserver@bookserver:~$ ./mango

              _|      _|
              _|_|  _|_|    _|_|_|  _|_|_|      _|_|_|    _|_|
              _|  _|  _|  _|    _|  _|    _|  _|    _|  _|    _|
              _|      _|  _|    _|  _|    _|  _|    _|  _|    _|
              _|      _|    _|_|_|  _|    _|    _|_|_|    _|_|
                                                    _|
                                                _|_|

Mango - Manga Server and Web Reader. Version 0.24.0

The config file /home/bookserver/.config/mango/config.yml does not exist. Dumping the default config there.
The config file has been created at /home/bookserver/.config/mango/config.yml.
[INFO]    2021/10/21 21:10:11 | The DB directory /home/bookserver/mango does not exist. Attempting to create it
Unhandled exception: Unable to create directory: '/home/bookserver/mango': File exists (File::AlreadyExistsError)
  from /usr/share/crystal/src/crystal/system/unix/dir.cr:65:13 in 'mkdir_p'
  from /__w/Mango/Mango/src/storage.cr:38:7 in 'default'
  from /__w/Mango/Mango/src/mango.cr:47:1 in '->'
  from /usr/share/crystal/src/primitives.cr:255:3 in 'start_parse'
  from /__w/Mango/Mango/src/mango.cr:137:1 in '__crystal_main'
  from /usr/share/crystal/src/crystal/main.cr:110:5 in 'main'
  from src/env/__libc_start_main.c:94:2 in 'libc_start_main_stage2'

To Reproduce Steps to reproduce the behavior:

  1. download Mango from Github,
  2. run ./mango,
  3. Mango will try to create the directory and bail

Expected behavior Normal startup should occur.

Environment (please complete the following information):

hkalexling commented 2 years ago

Hi, the problem is that you put the binary directly under your home directory. Please move it to somewhere like /usr/local/bin and run it.

DDzwiedziu commented 2 years ago
  1. The quickstart mentions no such thing.
  2. That's shifting blame, without giving a good reason for it.
  3. I will not install binaries manually into system directories.
  4. This is, again, not mentioned in the documentation.

So this is at least a caveat of the documentation.

hkalexling commented 2 years ago
  1. /user/local/bin is meant to store user installed binaries. It won't make it more secure if you put binaries in your home directory, as long as you are not running them as root.
  2. You don't have to install it in /user/local/bin, it was just a good practice. You can put it at /home/youruser/wherever/you/want/mango and it would still work. Just don't put it directly under your home directory.
  3. Yes I agree on the documentation not being entirely clear. Please feel free to submit a PR to either the README in this repo or the website at https://github.com/hkalexling/mango-website if you want. Thanks for bringing this up.
DDzwiedziu commented 2 years ago

Done: https://github.com/hkalexling/mango-website/pull/1