Failed to save 'main.py'. No space left on device, write ⚠️

Failed to save ‘main.py’: Unable to write file ‘vscode-remote://idx-projectname-1723990303475.cluster-y34ecccqenfhcuavp7vbnxv7zk.cloudworkstations.dev/home/user/project-name/src/main.py’ (Unknown (FileSystemError): Error: ENOSPC: no space left on device, write)

My main.py file has 556 lines.
2 other yaml files, 150 lines and 220 lines.

Do you have any dependencies installed with pip, poetry, or some manager? If there are any, could you show the packages you’ve added in the dev.nix file?

My full imports:

import os
import yaml
import string 
from flask import Flask, request, jsonify, send_from_directory
from pathlib import Path  
from huggingface_hub import InferenceClient 
from anthropic import AnthropicClient
from crewai import Agent, Task, Crew, Process
from crewai.memory.short_term.short_term_memory import ShortTermMemory
from crewai_tools import DirectoryReadTool, FileReadTool 
from src.tools.custom_tool import ESLintTool, ElectronBuilderTool
import logging
1 Like

Can you also show the dev.nix file located at .idx/dev.nix? It looks like you might be loading in some heavy duty dependencies that are going over the workspace limit.

{ pkgs, ... }: {
  # Which nixpkgs channel to use.
  channel = "stable-23.11"; # or "unstable"
  packages = [ pkgs.python3 pkgs.python3Packages.pip ];
  idx = {
    extensions = [ "ms-python.python" "rangav.vscode-thunder-client" "ms-python.debugpy" "ritwickdey.LiveServer" ];
    # Enable previews and customize configuration
    previews = {
      enable = true;
      previews = {
        web = {
          command = [ "python3" "-m" "http.server" "$PORT" "--bind" "0.0.0.0" ];
          manager = "web";
        };
      };
    };
    workspace = {
      # Runs when a workspace is first created with this `dev.nix` file
      onCreate = {
        install =
          "python -m venv .venv && curl -sSL https://install.python-poetry.org | python -";
        default.openFiles = [ "src/main.py" "src/config/agents.yaml" "src/config/tasks.yaml" ];
      };
      # Runs when a workspace is (re)started
      onStart = {
        run-server = "./devserver.sh";
        set-env-vars = ''
          export HUGGINGFACE_MODEL="meta-llama/Meta-Llama-3.1-8B-Instruct"
          export HF_TOKEN="hf_buxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxwd"
          export OPENAI_API_KEY="sk-proj-_yOxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1ETH-6CrCVeDClJm8CfI_3HL53jKNYfy_UtycA"
          export OPENAI_MODEL_NAME="gpt-4o"
          export ANTHROPIC_MODEL="claude-3-5-sonnet-20240620"
          export ANTHROPIC_API_KEY="sk-ant-api03-gRR4RsRf-1XWxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxJamaM0Q-6QAiZQAA"
          export GITHUB_TOKEN="ghp_yrDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx37nrcc"
          export ESLINT_CONFIG_PATH="/home/user/project-name/src/config/eslint.config.mjs"
          export ELECTRON_BUILDER_CONFIG_PATH="/home/user/project-name/src/electron-builder.json"
          export JEST_CONFIG_PATH="/home/user/project-name/src/config/jest.config.js"
        '';
      };
    };
  };
}

(I'll remove the LiveServer anyway)
1 Like

From what I see, the workspace home disk has around 10GB storage. It looks like you have env vars for a number of LLMs. The Llama model alone seems like it’s 5+GB. Assuming those are all getting downloaded locally, that might be where all your storage is going.

You could run du -a /home/user | sort -nr | head to find the largest dirs/files.

1 Like

Thanks for this!
I have both python3 and 3.11, which I should remove, right?

8931464 /home/user
4671648 /home/user/project-name
4086640 /home/user/project-name/.venv
4086308 /home/user/project-name/.venv/lib
4086304 /home/user/project-name/.venv/lib/python3.11
4086300 /home/user/project-name/.venv/lib/python3.11/site-packages
4023612 /home/user/.cache
2867940 /home/user/.cache/pip
2867888 /home/user/.cache/pip/http-v2
2652128 /home/user/project-name/.venv/lib/python3.11/site-packages/nvidia

Llama-3.1-8B: I use the inference API (serverless). Nothing downloaded.
And I use sonnet as I use openai gpt4, with the API and my keys.

Hmm, might you provide the dh -h output?

Not familiar with this nice command, not sure how to handle the result here.

Filesystem                   Size  Used Avail Use% Mounted on
tmpfs                        3.9G   12K  3.9G   1% /
tmpfs                         64M     0   64M   0% /dev
shm                           64M     0   64M   0% /dev/shm
overlay                      9.8G  9.6M  9.3G   1% /nix
tmpfs                        3.9G     0  3.9G   0% /nix/store/qdcbgcj27x2kpxj2sf9yfvva7qsgg64g-glibc-2.38-77/etc
overlay                      9.8G  9.6M  9.3G   1% /etc/bashrc
tmpfs                        3.9G     0  3.9G   0% /nix/store/jp9zgjmkkb633yxscczqxxp51lsvh5mi-glibc-2.38-77/etc
overlay                       46G   14G   32G  30% /mnt
/dev/sda1                     46G   14G   32G  30% /etc/hosts
/dev/sdb                      20G   20G     0 100% /ephemeral
/dev/disk/by-id/google-home  9.8G  9.3G  560K 100% /home
overlay                      9.8G   36K  9.3G   1% /mnt/ephemeral
tmpfs                        3.9G     0  3.9G   0% /run
tmpfs                        3.9G  160K  3.9G   1% /tmp
tmpfs                        3.9G     0  3.9G   0% /var

/dev/disk/by-id/google-home 9.8G 9.3G 560K 100% /home

Something is really using 9.3GB space at /home, try to run du -a /home| sort -nr | head again. Notice /home instead of /home/user

Only difference is this directory no longer appears with your command:

2652128 /home/user/project-name/.venv/lib/python3.11/site-packages/nvidia

What’s nvidia doing here? Can I simply manually remove the nvidia related folders and files?

It looks like roughly half your space is going to /home/user/project-name/.venv/lib/python3.11/site-packages (4086300 KB ~= 4 GB), and half to /home/user/.cache (4023612 KB ~= 4 GB).

site-packages is where your installed Python packages go. I don’t think we can say whether it’s safe to remove nvidia. Even if you did not install it yourself, you might have some other dependency that did. You could try something like pip show nvidia and see if that shows what it’s required by, assuming it was installed via pip.

The .cache folder is generally considered safe to remove, programs will recreate the contents if needed.

At this point, I’m just going to save my files, delete this project and create a new clean one.

Thanks all for the help.