LibreTranslate-init
LibreTranslate-init copied to clipboard
PermissionError: [Errno 13] Permission denied: 'db'
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'
I get the same error when trying to install a newer version
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
solution 2
create dir in /home/libretranslate/db
ready
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.
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.
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
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
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