Skip to content

Local Environment Troubleshooting

Sina Iman edited this page Mar 30, 2023 · 1 revision

Troubleshooting

Problem Error: Failed to upload file to IPFS: getaddrinfo ENOTFOUND host.docker.internal

# add following line to /etc/hosts
127.0.0.1 localhost host.docker.internal

Problem: The services aren't running or the app doesn't let me login (Network error)

ENSURE all .env.example files are copied to corresponding .env file

# Frontend
# Edit this (defaults may work)
cp ../nodes-web/.env.example ../nodes-web/.env
vim ../nodes-web/.env

# Server
# Edit this (defaults may work)
cp ./.env.example ./.env
vim ./.env

# only if you're deploying contracts to testnets (not local)
cp desci-contracts/.env.example desci-contracts/.env
vim desci-contracts/.env

Problem: Network error / server doesn't start or doesn't work

DB should be migrated / seeded on first run (this should happen automatically) But it can fail due to file system permissions problems. Check the logs for any errors.

If you're running Docker on Windows or WSL, make sure you do

docker exec -it -u 0 desci_nodes_backend /bin/chown -R node node_modules
docker exec -it -u 0 desci_nodes_backend /bin/chown -R node /app/node_modules/.prisma
docker exec -it -u 0 db_boilerplate /bin/chown -R postgres /var/lib/postgresql
# or manually with /bin/sh or /bin/bash
# then set permissions for all the volumes for the user

If you see all the migrations run on the first startup, you should be good.


Problem: Docker complains out of space

# you can DESTROY ALL IMAGES (Destructive) to reclaim space
docker system prune --all --force

Problem: Can't add new package via yarn

# specify the registry
yarn add mypackage --registry https://registry.npmjs.org

Problem: error TS2307: Cannot find module 'MYMODULE' or its corresponding type declarations. (desci-server)

# this may be happening due to stale docker image, DELETE the desci-server docker image and try again

Problem: Running all the docker containers uses up too much RAM

1. Reduce the containers you're running

If you're only working on one component, you may not need to run everything. You can disable services by editing `docker-compose.dev.yml`. Then modify the `.env` files as appropriate to point to cloud resources as necessary.

You can also simply shut down containers you don't need. If you need guidance on this, discuss on [Discord](https://discord.gg/BeJ4dxXdaJ).

2. You can run in [Gitpod](https://gitpod.io) which is a cloud dev environment that works well with docker. We have some initial configs in the `.gitpod.yml` file to help make development smoother on Gitpod.

Problem: Graph Indexing Not Working / Publishing Node not working / Need to reset my contract for local dev

1) Delete the desci-contracts/.openzeppelin/unknown-*.json files
2) Connect to local postgres as defined in desci-nodes/.env (database: postgres, not boilerplate) -- delete all schemas, create new schema `public`
3) re-run ./dockerDev.sh -- this should redeploy the contract.

Note: Ensure desci-contracts/subgraph.local.yaml and/or desci-contracts/subgraph.yaml files reflect the new contract address.

Additional config


NVM version

There is an .nvmrc file specifying the recommended node version in each folder. To automatically switch to this version, assuming NVM is installed and assuming ZSH is your shell. Add the following to .zshrc

# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
  local node_version="$(nvm version)"
  local nvmrc_path="$(nvm_find_nvmrc)"

  if [ -n "$nvmrc_path" ]; then
    local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")

    if [ "$nvmrc_node_version" = "N/A" ]; then
      nvm install
    elif [ "$nvmrc_node_version" != "$node_version" ]; then
      nvm use
    fi
  elif [ "$node_version" != "$(nvm version default)" ]; then
    echo "Reverting to nvm default version"
    nvm use default
  fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc


Clone this wiki locally