[GH-ISSUE #51] Panic with message "No space left on device" #42

Closed
opened 2026-02-27 19:28:29 +03:00 by kerem · 9 comments
Owner

Originally created by @sashahilton00 on GitHub (Jan 29, 2018).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/51

Issue by joerg-krause
Friday Mar 17, 2017 at 09:51 GMT
Originally opened as https://github.com/plietar/librespot/issues/166


When playling long tracks on my embedded device with about 36MB of free RAM, librespot panics with: thread 'main' panicked at 'called Result::unwrap()on anErr value: Error { repr: Os { code: 28, message: "No space left on device" } }'.

For example using this track (45:31). Is there a way not to load the whole song into RAM?

Originally created by @sashahilton00 on GitHub (Jan 29, 2018). Original GitHub issue: https://github.com/librespot-org/librespot/issues/51 <a href="https://github.com/joerg-krause"><img src="https://avatars2.githubusercontent.com/u/6870896?v=4" align="left" width="96" height="96" hspace="10"></img></a> **Issue by [joerg-krause](https://github.com/joerg-krause)** _Friday Mar 17, 2017 at 09:51 GMT_ _Originally opened as https://github.com/plietar/librespot/issues/166_ ---- When playling long tracks on my embedded device with about 36MB of free RAM, librespot panics with: `thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 28, message: "No space left on device" } }'`. For example using [this](https://open.spotify.com/track/0Kbvz9ZjihrcE1Vd1dDCZh) track (45:31). Is there a way not to load the whole song into RAM?
kerem 2026-02-27 19:28:29 +03:00
Author
Owner

@sashahilton00 commented on GitHub (Jan 29, 2018):

Comment by plietar
Friday Mar 17, 2017 at 14:37 GMT


Interesting, I never really considered very large tracks.
librespot doesn't load the whole song into RAM, but it downloads it into /tmp, which may be the same thing if that is mounted as a tmpfs.

As a temporary workaround, you can change this line from NamedTempFile::new() to NamedTempFile::new_in("/somewhere/not/in/ram").

Ideally, if a cache directory is specified we can just use $CACHE/temp automatically for that.

<!-- gh-comment-id:361262161 --> @sashahilton00 commented on GitHub (Jan 29, 2018): <a href="https://github.com/plietar"><img src="https://avatars0.githubusercontent.com/u/1489775?v=4" align="left" width="48" height="48" hspace="10"></img></a> **Comment by [plietar](https://github.com/plietar)** _Friday Mar 17, 2017 at 14:37 GMT_ ---- Interesting, I never really considered very large tracks. librespot doesn't load the whole song into RAM, but it downloads it into `/tmp`, which may be the same thing if that is mounted as a tmpfs. As a temporary workaround, you can change [this line from `NamedTempFile::new()`](https://github.com/plietar/librespot/blob/eb49ff34f1fa5aa032d71573cb91101f315c1a34/src/audio_file.rs#L68) to `NamedTempFile::new_in("/somewhere/not/in/ram")`. Ideally, if a cache directory is specified we can just use `$CACHE/temp` automatically for that.
Author
Owner

@sashahilton00 commented on GitHub (Jan 29, 2018):

Comment by joerg-krause
Friday Mar 17, 2017 at 17:52 GMT


Thanks, I will try this. In fact, this track is an extreme. It my also happen for tracks having a length of six or seven minutes, depending on the free RAM left.

<!-- gh-comment-id:361262185 --> @sashahilton00 commented on GitHub (Jan 29, 2018): <a href="https://github.com/joerg-krause"><img src="https://avatars2.githubusercontent.com/u/6870896?v=4" align="left" width="48" height="48" hspace="10"></img></a> **Comment by [joerg-krause](https://github.com/joerg-krause)** _Friday Mar 17, 2017 at 17:52 GMT_ ---- Thanks, I will try this. In fact, this track is an extreme. It my also happen for tracks having a length of six or seven minutes, depending on the free RAM left.
Author
Owner

@sashahilton00 commented on GitHub (Jan 29, 2018):

Comment by joerg-krause
Thursday Mar 23, 2017 at 12:10 GMT


On second thought, my system is NAND flash based. So, using anything else than the RAM for caching is not a good idea. So, I need a bigger RAM?

<!-- gh-comment-id:361262208 --> @sashahilton00 commented on GitHub (Jan 29, 2018): <a href="https://github.com/joerg-krause"><img src="https://avatars2.githubusercontent.com/u/6870896?v=4" align="left" width="48" height="48" hspace="10"></img></a> **Comment by [joerg-krause](https://github.com/joerg-krause)** _Thursday Mar 23, 2017 at 12:10 GMT_ ---- On second thought, my system is NAND flash based. So, using anything else than the RAM for caching is not a good idea. So, I need a bigger RAM?
Author
Owner

@sashahilton00 commented on GitHub (Jan 29, 2018):

Comment by plietar
Thursday Mar 23, 2017 at 13:25 GMT


Pretty much. A solution would be to change librespot to break up the files in blocks of say 500KB, and delete them automatically (if cache is disabled) once it has moved on to the next one. This is a large-ish change, so it's unlikely I'll be able to implement it anytime soon unfortunately.

<!-- gh-comment-id:361262225 --> @sashahilton00 commented on GitHub (Jan 29, 2018): <a href="https://github.com/plietar"><img src="https://avatars0.githubusercontent.com/u/1489775?v=4" align="left" width="48" height="48" hspace="10"></img></a> **Comment by [plietar](https://github.com/plietar)** _Thursday Mar 23, 2017 at 13:25 GMT_ ---- Pretty much. A solution would be to change `librespot` to break up the files in blocks of say 500KB, and delete them automatically (if cache is disabled) once it has moved on to the next one. This is a large-ish change, so it's unlikely I'll be able to implement it anytime soon unfortunately.
Author
Owner

@sashahilton00 commented on GitHub (Jan 29, 2018):

Comment by michaelherger
Tuesday May 02, 2017 at 04:33 GMT


I've modified librespot to disable the audio file-cache. See pull request #181.

<!-- gh-comment-id:361262248 --> @sashahilton00 commented on GitHub (Jan 29, 2018): <a href="https://github.com/michaelherger"><img src="https://avatars3.githubusercontent.com/u/2789989?v=4" align="left" width="48" height="48" hspace="10"></img></a> **Comment by [michaelherger](https://github.com/michaelherger)** _Tuesday May 02, 2017 at 04:33 GMT_ ---- I've modified librespot to disable the audio file-cache. See pull request #181.
Author
Owner

@ComlOnline commented on GitHub (Jan 31, 2018):

The final PR for this was closed. See here.

<!-- gh-comment-id:362051772 --> @ComlOnline commented on GitHub (Jan 31, 2018): The final PR for this was closed. See [here](https://github.com/plietar/librespot/pull/204).
Author
Owner

@plietar commented on GitHub (Feb 2, 2018):

This is different from https://github.com/plietar/librespot/pull/204. The issue here is that librespot tries to download the entire file (whether or not cache is enabled), which may be impossible for long tracks and low memory devices.

<!-- gh-comment-id:362445859 --> @plietar commented on GitHub (Feb 2, 2018): This is different from https://github.com/plietar/librespot/pull/204. The issue here is that librespot tries to download the entire file (whether or not cache is enabled), which may be impossible for long tracks and low memory devices.
Author
Owner

@michaelherger commented on GitHub (Feb 2, 2018):

Yep, I had to learn this the hard way: though I had the audio-cache disabled I still saw people with large files in TMPDIR. In my case I was able to work around this using the method mentioned by @plietar: have librespot write to some place outside in-memory storage. Setting TMPDIR=/path/to/folder librespot ... does the trick here.

<!-- gh-comment-id:362484417 --> @michaelherger commented on GitHub (Feb 2, 2018): Yep, I had to learn this the hard way: though I had the audio-cache disabled I still saw people with large files in TMPDIR. In my case I was able to work around this using the method mentioned by @plietar: have librespot write to some place outside in-memory storage. Setting `TMPDIR=/path/to/folder librespot ...` does the trick here.
Author
Owner

@sashahilton00 commented on GitHub (Feb 2, 2018):

given that all spotify songs are downloaded in chunks, is there an easy way to discard chunks once they have been played when the cache is disabled?

<!-- gh-comment-id:362611102 --> @sashahilton00 commented on GitHub (Feb 2, 2018): given that all spotify songs are downloaded in chunks, is there an easy way to discard chunks once they have been played when the cache is disabled?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#42
No description provided.