Permission error using m4b encoder, possible docker uid/gid related #718

Closed
opened 2026-04-24 23:18:03 +02:00 by adam · 1 comment
Owner

Originally created by @S-Mucalo on GitHub (Oct 26, 2022).

I am having a permissions error using the m4b encoder from the file management tools. I think the encoder is not using the AUDIOBOOKSHELF_UID/GID environment variables and causing errors trying to copy files from root user owned directories. The m4b encoder will copy the files into /metadata/cache/items/ as root. If the audiobookshelf user is not root, errors will occur after the encoding. No files will change in the original folder. I do not know if the error occurs without setting environment variables.

Audiobookshelf is installed with docker-compose:

  audiobookshelf:
    image: ghcr.io/advplyr/audiobookshelf
    container_name: audiobookshelf
    environment:
      - AUDIOBOOKSHELF_UID=1000
      - AUDIOBOOKSHELF_GID=1000
    ports:
      - 13378:80
    volumes:
      - /mnt/media/Books/Audiobook:/audiobooks
      - /docker/audiobookshelf/config:/config
      - /docker/audiobookshelf/metadata:/metadata
    restart: unless-stopped

permissions of the folders within the docker container seem ok to me:

/audiobooks $ ls -al
total 1453
drwxr-xr-x  109 node     node           109 Oct 26 10:53 .
drwxr-xr-x    1 root     root          4096 Oct 26 09:30 ..

/config $ ls -al
total 26
drwxr-xr-x   11 root     root            11 Jul  3 14:05 .
drwxr-xr-x    1 node     node          4096 Oct 26 09:30 ..
drwxr-xr-x    4 node     node             5 Apr 25  2022 authors
drwxr-xr-x    4 node     node             5 Apr 25  2022 collections
drwxr-xr-x    4 node     node             5 Jul  3 14:05 feeds
drwxr-xr-x    4 node     node             5 Apr 25  2022 libraries
drwxr-xr-x    4 node     node             5 Apr 25  2022 libraryItems
drwxr-xr-x    4 node     node             5 Apr 25  2022 series
drwxr-xr-x    4 node     node             5 Apr 25  2022 sessions
drwxr-xr-x    4 node     node             5 Apr 25  2022 settings
drwxr-xr-x    4 node     node             5 Apr 25  2022 users
/metadata $ ls -al
total 76
drwxr-xr-x    9 node     node             9 Apr 27 04:27 .
drwxr-xr-x    1 root     root          4096 Oct 26 09:30 ..
drwxr-xr-x    2 node     node            28 Apr 28 01:19 authors
drwxr-xr-x    2 node     node             2 Apr 25  2022 backups
drwxr-xr-x    5 node     node             5 Oct  6 06:07 cache
drwxr-xr-x    2 node     node             2 Apr 27 12:10 downloads
drwxr-xr-x  312 node     node           312 Oct 26 11:23 items
drwxr-xr-x    4 node     node             4 Apr 25  2022 logs
drwxr-xr-x    2 node     node             2 Apr 25  2022 streams

However, the metadata/cache/items where the m4b encoder does its thing has items created by root :

/metadata/cache/items $ ls -al
total 88
drwxr-xr-x    4 node     node             4 Oct 26 11:03 .
drwxr-xr-x    5 node     node             5 Oct  6 06:07 ..
drwxr-xr-x    2 root     root            28 Oct 26 10:16 li_2a870gfnm628b9rwrq
drwxr-xr-x    2 root     root            20 Oct 26 11:22 li_gmschfr9qarnrrojjw

The partial log file:

2022-10-26 11:03:47

INFO

Start m4b encode for li_gmschfr9qarnrrojjw - TaskId: encode-m4b_oclowq53r0h7cineho

2022-10-26 11:03:47

INFO

[DownloadWorker] FFMPEG concat started with command: ffmpeg -safe 0 -f concat -i /metadata/cache/items/li_gmschfr9qarnrrojjw/files.txt -y -loglevel error -map 0:a -acodec aac -ac 2 -b:a 64k -f mp4 /metadata/cache/items/li_gmschfr9qarnrrojjw/Isaac Asimov-Robot-I, Robot.m4b

2022-10-26 11:22:57

INFO

[DownloadWorker] worker ended

2022-10-26 11:22:59

ERROR

[AbMergeManager] Failed to move track "/audiobooks/Isaac Asimov/Isaac Asimov-Robots-#0,1-I Robot/Isaac Asimov-Robot-I, Robot/01 I, Robot 01.mp3" to "/metadata/cache/items/li_gmschfr9qarnrrojjw/01 I, Robot 01.mp3" Error: EACCES: permission denied, unlink '/audiobooks/Isaac Asimov/Isaac Asimov-Robots-#0,1-I Robot/Isaac Asimov-Robot-I, Robot/01 I, Robot 01.mp3'

2022-10-26 11:22:59

ERROR

[AbMergeManager] Failed to move track "/audiobooks/Isaac Asimov/Isaac Asimov-Robots-#0,1-I Robot/Isaac Asimov-Robot-I, Robot/02 Robbie.mp3" to "/metadata/cache/items/li_gmschfr9qarnrrojjw/02 Robbie.mp3" Error: EACCES: permission denied, unlink '/audiobooks/Isaac Asimov/Isaac Asimov-Robots-#0,1-I Robot/Isaac Asimov-Robot-I, Robot/02 Robbie.mp3'

...

Apologies if I have misinterpreted the errors.

Originally created by @S-Mucalo on GitHub (Oct 26, 2022). I am having a permissions error using the m4b encoder from the file management tools. I think the encoder is not using the AUDIOBOOKSHELF_UID/GID environment variables and causing errors trying to copy files from root user owned directories. The m4b encoder will copy the files into /metadata/cache/items/ as root. If the audiobookshelf user is not root, errors will occur after the encoding. No files will change in the original folder. I do not know if the error occurs without setting environment variables. Audiobookshelf is installed with docker-compose: ``` audiobookshelf: image: ghcr.io/advplyr/audiobookshelf container_name: audiobookshelf environment: - AUDIOBOOKSHELF_UID=1000 - AUDIOBOOKSHELF_GID=1000 ports: - 13378:80 volumes: - /mnt/media/Books/Audiobook:/audiobooks - /docker/audiobookshelf/config:/config - /docker/audiobookshelf/metadata:/metadata restart: unless-stopped ``` permissions of the folders within the docker container seem ok to me: ``` /audiobooks $ ls -al total 1453 drwxr-xr-x 109 node node 109 Oct 26 10:53 . drwxr-xr-x 1 root root 4096 Oct 26 09:30 .. ``` ``` /config $ ls -al total 26 drwxr-xr-x 11 root root 11 Jul 3 14:05 . drwxr-xr-x 1 node node 4096 Oct 26 09:30 .. drwxr-xr-x 4 node node 5 Apr 25 2022 authors drwxr-xr-x 4 node node 5 Apr 25 2022 collections drwxr-xr-x 4 node node 5 Jul 3 14:05 feeds drwxr-xr-x 4 node node 5 Apr 25 2022 libraries drwxr-xr-x 4 node node 5 Apr 25 2022 libraryItems drwxr-xr-x 4 node node 5 Apr 25 2022 series drwxr-xr-x 4 node node 5 Apr 25 2022 sessions drwxr-xr-x 4 node node 5 Apr 25 2022 settings drwxr-xr-x 4 node node 5 Apr 25 2022 users ``` ``` /metadata $ ls -al total 76 drwxr-xr-x 9 node node 9 Apr 27 04:27 . drwxr-xr-x 1 root root 4096 Oct 26 09:30 .. drwxr-xr-x 2 node node 28 Apr 28 01:19 authors drwxr-xr-x 2 node node 2 Apr 25 2022 backups drwxr-xr-x 5 node node 5 Oct 6 06:07 cache drwxr-xr-x 2 node node 2 Apr 27 12:10 downloads drwxr-xr-x 312 node node 312 Oct 26 11:23 items drwxr-xr-x 4 node node 4 Apr 25 2022 logs drwxr-xr-x 2 node node 2 Apr 25 2022 streams ``` However, the metadata/cache/items where the m4b encoder does its thing has items created by root : ``` /metadata/cache/items $ ls -al total 88 drwxr-xr-x 4 node node 4 Oct 26 11:03 . drwxr-xr-x 5 node node 5 Oct 6 06:07 .. drwxr-xr-x 2 root root 28 Oct 26 10:16 li_2a870gfnm628b9rwrq drwxr-xr-x 2 root root 20 Oct 26 11:22 li_gmschfr9qarnrrojjw ``` The partial log file: ``` 2022-10-26 11:03:47 INFO Start m4b encode for li_gmschfr9qarnrrojjw - TaskId: encode-m4b_oclowq53r0h7cineho 2022-10-26 11:03:47 INFO [DownloadWorker] FFMPEG concat started with command: ffmpeg -safe 0 -f concat -i /metadata/cache/items/li_gmschfr9qarnrrojjw/files.txt -y -loglevel error -map 0:a -acodec aac -ac 2 -b:a 64k -f mp4 /metadata/cache/items/li_gmschfr9qarnrrojjw/Isaac Asimov-Robot-I, Robot.m4b 2022-10-26 11:22:57 INFO [DownloadWorker] worker ended 2022-10-26 11:22:59 ERROR [AbMergeManager] Failed to move track "/audiobooks/Isaac Asimov/Isaac Asimov-Robots-#0,1-I Robot/Isaac Asimov-Robot-I, Robot/01 I, Robot 01.mp3" to "/metadata/cache/items/li_gmschfr9qarnrrojjw/01 I, Robot 01.mp3" Error: EACCES: permission denied, unlink '/audiobooks/Isaac Asimov/Isaac Asimov-Robots-#0,1-I Robot/Isaac Asimov-Robot-I, Robot/01 I, Robot 01.mp3' 2022-10-26 11:22:59 ERROR [AbMergeManager] Failed to move track "/audiobooks/Isaac Asimov/Isaac Asimov-Robots-#0,1-I Robot/Isaac Asimov-Robot-I, Robot/02 Robbie.mp3" to "/metadata/cache/items/li_gmschfr9qarnrrojjw/02 Robbie.mp3" Error: EACCES: permission denied, unlink '/audiobooks/Isaac Asimov/Isaac Asimov-Robots-#0,1-I Robot/Isaac Asimov-Robot-I, Robot/02 Robbie.mp3' ... ``` Apologies if I have misinterpreted the errors.
adam added the waitingunable to reproduce labels 2026-04-24 23:18:03 +02:00
adam closed this issue 2026-04-24 23:18:04 +02:00
Author
Owner

@advplyr commented on GitHub (Oct 26, 2022):

It looks like the error is happening when removing the file from your /audiobooks folder. Does abs have the permissions to move that file?

The item cache folder gets the permissions and owner changed after all the files are moved around.

@advplyr commented on GitHub (Oct 26, 2022): It looks like the error is happening when removing the file from your `/audiobooks` folder. Does abs have the permissions to move that file? The item cache folder gets the permissions and owner changed after all the files are moved around.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#718