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

PermissionError: [Errno 13] Permission denied: 'db' #18

Open
argosopentech opened this issue Oct 1, 2023 · 8 comments
Open

PermissionError: [Errno 13] Permission denied: 'db' #18

argosopentech opened this issue Oct 1, 2023 · 8 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@argosopentech
Copy link
Owner

I sometimes see this error but it doesn't seem to cause issues.

Traceback (most recent call last):
  File "/home/libretranslate/LibreTranslate/env/bin/libretranslate", line 8, in <module>
    sys.exit(main())
  File "/home/libretranslate/LibreTranslate/env/lib/python3.10/site-packages/libretranslate/main.py", line 192, in main
    app = create_app(args)
  File "/home/libretranslate/LibreTranslate/env/lib/python3.10/site-packages/libretranslate/app.py", line 1069, in create_app
    Session(app)
  File "/home/libretranslate/LibreTranslate/env/lib/python3.10/site-packages/flask_session/__init__.py", line 54, in __init__
    self.init_app(app)
  File "/home/libretranslate/LibreTranslate/env/lib/python3.10/site-packages/flask_session/__init__.py", line 61, in init_app
    app.session_interface = self._get_interface(app)
  File "/home/libretranslate/LibreTranslate/env/lib/python3.10/site-packages/flask_session/__init__.py", line 90, in _get_interface
    session_interface = FileSystemSessionInterface(
  File "/home/libretranslate/LibreTranslate/env/lib/python3.10/site-packages/flask_session/sessions.py", line 322, in __init__
    self.cache = FileSystemCache(cache_dir, threshold=threshold, mode=mode)
  File "/home/libretranslate/LibreTranslate/env/lib/python3.10/site-packages/cachelib/file.py", line 65, in __init__
    os.makedirs(self._path)
  File "/usr/lib/python3.10/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: 'db'
@argosopentech argosopentech added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Oct 1, 2023
@manuelkamp
Copy link

I get the same error when trying to install a newer version

@danielmnb1
Copy link

does not work with this user

only skip the part of adding the user

and in the libretranslate.service file

user and group = root

and in nginx = the ip of the server

and it should work

@danielmnb1
Copy link

solution 2

create dir in /home/libretranslate/db

ready

@manuelkamp
Copy link

No, this does not solve it. I created directory /home/libretranslate/db (but there is one in /home/libretranslate/LibreTranslate/db already, where it should be).

I cannot skip part of adding user, because it is installed in python venv and not in root.

@manuelkamp
Copy link

manuelkamp commented Jan 7, 2024

OK, this is how i got the update working (note that it is now running under root venv and not libretranslate user anymore):

su libretranslate
sudo systemctl stop libretranslate
cp /root/libretranslate/LibreTranslate/libretranslate/templates/index.html /tmp/index.html
rm -rf ~/LibreTranslate
exit
git clone https://github.com/LibreTranslate/LibreTranslate.git ~/LibreTranslate
virtualenv ~/LibreTranslate/env
~/LibreTranslate/env/bin/pip install gunicorn
~/LibreTranslate/env/bin/pip install ~/LibreTranslate/ --no-cache-dir
~/LibreTranslate/env/bin/pip uninstall beautifulsoup4
~/LibreTranslate/env/bin/pip install beautifulsoup4==4.9.3
~/LibreTranslate/env/bin/libretranslate
nano /etc/systemd/system/libretranslate.service
edit and change user/path from /home/libretranslate to /root (don't forget to adapt to your url!):

[Unit]
Description=LibreTranslate WSGI with Gunicorn and Nginx
After=network.target

[Service]
User=root
Group=www-data
WorkingDirectory=/root/LibreTranslate
Environment="PATH=/root/LibreTranslate/env/bin"
ExecStart=/root/LibreTranslate/env/bin/gunicorn --workers 3 --bind unix:libretranslate.sock -m 007 wsgi:app(api_keys=True, req_limit="5", batch_limit="2", get_api_key_link="https://translate.somedomain.com/get-api-key")
Restart=always
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=mixed
TimeoutStopSec=1

[Install]
WantedBy=multi-user.target

systemctl daemon-reload
cp /tmp/index.html /root/LibreTranslate/libretranslate/templates/index.html
systemctl start libretranslate
systemctl enable libretranslate
nano /etc/nginx/sites-available/default
Also change home to root here (don't forget to adapt to your url!):

server {
    listen 80;
    server_name localhost translate.someserver.com;

    location / {
        include proxy_params;
        proxy_pass http://unix:/root/LibreTranslate/libretranslate.sock;
    }
}

nginx -t
systemctl restart nginx

for future updates just skip the first line (and later the "exit" command).

PS: it may be necessary to run nginx as root for this to work.

@falves1
Copy link

falves1 commented Jan 24, 2024

creating the directory /home/libretranslate/db does not allow the installation. Is there a real solution?
"Building wheels for collected packages: libretranslate
Building wheel for libretranslate (PEP 517) ... done
Created wheel for libretranslate: filename=libretranslate-1.5.5-py3-none-any.whl size=632627 sha256=d033f1f7e2f116978093177884054b4ab380fa804c6a953244b27a7bb2e9d4a9
Stored in directory: /tmp/pip-ephem-wheel-cache-bw64ejsg/wheels/6f/7f/9d/b7e065cb8e7956f9224c87b27cc2e1e3ceb2b4b85ae421755b
Successfully built libretranslate
Installing collected packages: libretranslate
Attempting uninstall: libretranslate
Found existing installation: libretranslate 1.5.5
Uninstalling libretranslate-1.5.5:
Successfully uninstalled libretranslate-1.5.5
Successfully installed libretranslate-1.5.5
Traceback (most recent call last):
File "/home/libretranslate/LibreTranslate/env/bin/libretranslate", line 8, in
sys.exit(main())
File "/home/libretranslate/LibreTranslate/env/lib/python3.8/site-packages/libretranslate/main.py", line 206, in main
app = create_app(args)
File "/home/libretranslate/LibreTranslate/env/lib/python3.8/site-packages/libretranslate/app.py", line 1093, in create_app
Session(app)
File "/home/libretranslate/LibreTranslate/env/lib/python3.8/site-packages/flask_session/init.py", line 54, in init
self.init_app(app)
File "/home/libretranslate/LibreTranslate/env/lib/python3.8/site-packages/flask_session/init.py", line 61, in init_app
app.session_interface = self._get_interface(app)
File "/home/libretranslate/LibreTranslate/env/lib/python3.8/site-packages/flask_session/init.py", line 90, in _get_interface
session_interface = FileSystemSessionInterface(
File "/home/libretranslate/LibreTranslate/env/lib/python3.8/site-packages/flask_session/sessions.py", line 322, in init
self.cache = FileSystemCache(cache_dir, threshold=threshold, mode=mode)
File "/home/libretranslate/LibreTranslate/env/lib/python3.8/site-packages/cachelib/file.py", line 65, in init
os.makedirs(self._path)
File "/usr/lib/python3.8/os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/usr/lib/python3.8/os.py", line 223, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: 'db'
$ Is there a paid service the would help to install this software? I am a consultant and I promised my employer that this would work.

@maxlinux2000
Copy link

please add this to /etc/sudoers.d/libretranslate

libretranslate ALL=NOPASSWD: /usr/local/bin/libretranslate

here my systemd service


root@debian:/etc/systemd/system# cat libretranslate.service 
[Unit]
Description=LibreTranslate
After=network.target
[Service]
User=libretranslate
Group=libretranslate
WorkingDirectory=/opt/libretranslate/
ExecStart=sudo  -u libretranslate /usr/local/bin/libretranslate --host 127.0.0.1 --port 5000
#--disable-files-translation
Restart=always
#CPUQuota=50%

[Install]
WantedBy=multi-user.target

@sunra
Copy link

sunra commented Sep 2, 2024

Debian 12.

root@libretranslate:~# su libretranslate
$ ~/LibreTranslate-init/setup.sh

Loaded support for 44 languages (88 models total)!
Traceback (most recent call last):
File "/home/libretranslate/LibreTranslate/env/bin/libretranslate", line 8, in
sys.exit(main())
^^^^^^
File "/home/libretranslate/LibreTranslate/env/lib/python3.11/site-packages/libretranslate/main.py", line 226, in main
app = create_app(args)
^^^^^^^^^^^^^^^^
File "/home/libretranslate/LibreTranslate/env/lib/python3.11/site-packages/libretranslate/app.py", line 1130, in create_app
Session(app)
File "/home/libretranslate/LibreTranslate/env/lib/python3.11/site-packages/flask_session/init.py", line 54, in init
self.init_app(app)
File "/home/libretranslate/LibreTranslate/env/lib/python3.11/site-packages/flask_session/init.py", line 61, in init_app
app.session_interface = self._get_interface(app)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/libretranslate/LibreTranslate/env/lib/python3.11/site-packages/flask_session/init.py", line 90, in _get_interface
session_interface = FileSystemSessionInterface(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/libretranslate/LibreTranslate/env/lib/python3.11/site-packages/flask_session/sessions.py", line 322, in init
self.cache = FileSystemCache(cache_dir, threshold=threshold, mode=mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/libretranslate/LibreTranslate/env/lib/python3.11/site-packages/cachelib/file.py", line 80, in init
os.makedirs(self._path)
File "", line 215, in makedirs
File "", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: 'db'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants