Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when library database directory doesn't exist #3808

Closed
simonvanderveldt opened this issue Dec 11, 2020 · 6 comments
Closed

Error when library database directory doesn't exist #3808

simonvanderveldt opened this issue Dec 11, 2020 · 6 comments
Labels
feature features we would like to implement

Comments

@simonvanderveldt
Copy link

Problem

When the directory the library database is contained in doesn't exist yet beets throws an error:

error: database file /home/simon/.local/share/beets/library.db cannot not be opened: unable to open database file

Expected behavior:
Beets creates the required (parent) directories

Version info: Current master (ed18551)

@wisp3rwind
Copy link
Member

I think this is intended behaviour, since it is quite common to have a music collection including the database on an external disk. When beets is accidentally run when the external drive is disconnected, no such parent directories should be created. I don't think there's an easy solution to detect whether this is the case (except for adding a configuration option to indicate that the collection is removable, but I'd say that's not really an improvement over creating the folder manually).

Semi-related: #1934

@simonvanderveldt
Copy link
Author

simonvanderveldt commented Dec 11, 2020

@wisp3rwind Thanks for the reply. To be clear, unlike the linked issue this is not about the music collection itself but about the database ("library", the key used in the config, isn't the clearest of names). But I guess people could have their database also on an external drive together with the music collection?

If that's really a thing that happens wouldn't it make more sense to show a message saying no database was found and ask if it should be created? When answering yes the missing directories can be created as well.

@wisp3rwind
Copy link
Member

@wisp3rwind Thanks for the reply. To be clear, unlike the linked issue this is not about the music collection itself but about the database ("library", the key used in the config, isn't the clearest of names). But I guess people could have their database also on an external drive together with the music collection?

Thanks for the clarification, and sorry for the belated reply! I did understand you correctly initially already. At least I have the db located next to my music collection. To be honest, I have no idea what is generally more common among beets users. So, I'd prefer not to create files/directories in that situation automatically.

If that's really a thing that happens wouldn't it make more sense to show a message saying no database was found and ask if it should be created? When answering yes the missing directories can be created as well.

Adding a prompt in that situation sounds very reasonable, we could add that. If you (or anyone else) would open a PR, that'd be perfect!

@wisp3rwind wisp3rwind reopened this Mar 23, 2021
@wisp3rwind wisp3rwind added the feature features we would like to implement label Mar 23, 2021
@alicezou
Copy link
Contributor

alicezou commented Mar 27, 2022

Hi, I added this feature as well as test cases for it. Here is my pull request.
#4327

I am trying to test on a ubuntu server, But somehow I cannot run tox successfully

(py39) ubuntu@ip-xxxxx:~/beets$ tox
GLOB sdist-make: /home/ubuntu/beets/setup.py
ERROR: invocation failed (exit code 1), logfile: /home/ubuntu/beets/.tox/log/GLOB-0.log
======================================= log start ========================================
sphinx-build -b man -d _build/doctrees   . _build/man
Running Sphinx v1.8.5

Extension error:
Could not import extension sphinx.builders.latex (exception: cannot import name 'contextfunction' from 'jinja2' (/home/ubuntu/.local/lib/python3.8/site-packages/jinja2/__init__.py))
make: *** [Makefile:117: man] Error 2
/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.9) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
  File "setup.py", line 52, in <module>
    build_manpages()
  File "setup.py", line 36, in build_manpages
    subprocess.check_call(['make', 'man'])
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', 'man']' returned non-zero exit status 2.

======================================== log end =========================================
ERROR: FAIL could not package project - v = InvocationError('/usr/bin/python3 setup.py sdist --formats=zip --dist-dir .tox/dist', 1)

@alicezou
Copy link
Contributor

alicezou commented Apr 9, 2022

Fixed in #4327
The issue probably can be closed. ;)

@sampsyo
Copy link
Member

sampsyo commented Apr 9, 2022

Indeed; thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature features we would like to implement
Projects
None yet
Development

No branches or pull requests

4 participants