# timOhjeet

Common installation and maintenance problems

1. When installing TIM, ./tim setup hangs (Windows)

If after the ./tim setup command, the installation is stuck in the

[INFO] Installing Python development dependencies

it is likely that you do not have the rights to make the necessary changes. In this case, Git Bash (or any other shell you use for the installation) should be run with administrator privileges:

  1. Open the Windows search menu by pressing Win+S
  2. Type git bash (or your shell) in the search and right-click 'Run as administrator'
  3. Run ./tim setup --force from the TIM root directory

The installation should now go through normally.

2. Windows: WSL stops responding

WSL stopped responding and then Docker would not start. The following helped:

wsl --update
wsl --shutdown
wsl

In the second case, Docker appeared to be running externally, but

$ ./tim npmi
error cb() never called!
error This is an error with npm itself. Please report this error at:
error https://npm.community/

something in the WSL was preventing Docker from starting.

$ ./tim up
error during connect: This error may indicate that the docker daemon is not running.

The situation was resolved by updating WSL and restarting Docker

$ wsl --update
$ wsl --shutdown
$ docker restart

3. TIM cannot be accessed in the browser

If you cannot connect to TIM from your browser, it is likely that a container has not started .

You can get information about the container running by typing:

./tim dc logs <kontin nimi docker-compose.yml:ssä>

For example:

./tim dc logs --tail=20 tim

and there may be, for example:

2021-12-16 09:28:04,309 ERROR: Your database is not up to date. To upgrade, run: ./r flask db upgrade

in which case you must follow the instructions.

3.1 Possible reasons why a TIM container will not start

  • The structure of the database is not up to date. The database can be updated with the command
./tim run flask db upgrade
```If you do this in production, it may be safer to run

./tim update db ```which will also shut down the other containers for the update and display the "TIM is being updated" message to the base users.

  • The database is broken in some way. Then it can be reformatted:
./tim dc down
docker volume rm tim_data11
<poista kansio timApp/tim_files>
./tim up

4. Browser shows 502 Bad Gateway

  • Alternatives:
    • Tim container not running, see docker ps

    • The TIM server itself is not running; see if it has stopped

    • For example, you can check the existence of the database: ./tim pg backendsThe database is automatically created when TIM is started, if it does not exist.

5. Windows: EPERM error when running ./tim npmi

During this command, Windows may encounter an EPERM error. In the case of , temporarily disable the antivirus program, remove the directory node_modules (if it was created) and try again.

# portitvarattu

6. Windows: ports used by TIM are busy

At least on Vesa's machine, when Windows starts , some ports used by TIM are on the denied list. By default TIM only uses ports 80 (HTTP) and 443 (HTTPS), but these ports can be redirected by changing the caddy.port_mapping configuration in the tim.conf file.

The list can be seen in Windows with the command:

netsh interface ipv4 show excludedportrange protocol=tcp

If the list contains ports used by TIM, you can free them at least temporarily with the command

net stop winnat

However, this must be given before the docker containers are started, i.e. if the containers are already started, then

./tim dc down
./tim up

With the command

netstat -a -b

to see the ports in use (different from what is denied).

On Windows, you can use the graphical CurrPorts tool to view the ports in use.

You can also try unblocking reserved ports (Command Promt with admin privileges):

net stop winnat
netsh int ipv4 set dynamic tcp start=49152 num=16384
netsh int ipv6 set dynamic tcp start=49152 num=16384
net start winnat

If the container startup is interrupted by the error message below

Error response from daemon: Ports are not available: listen tcp 0.0.0.0:80: bind:
An attempt was made to access a socket in a way forbidden by its access permissions.

You must release the port that is already in use

$ netstat -aon | grep :80
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4
  TCP    [::]:80                [::]:0                 LISTENING       4

$ net stop W3SVC
  The World Wide Web Publishing Service service is stopping.
  The World Wide Web Publishing Service service was stopped successfully.
  
$ netstat -aon | grep :80
  <tyhjä>

Let's try again if it works

$ ./tim dc down
$ ./tim up

7. WSL: No connection to the local network

Nature of the problem: if you try to connect to devices on the local network, for example, WSL reports an error:

$ ping 192.168.59.1
ping: connect: Network is unreachable

Similarly, apt update and docker-compose pull will inevitably fail for the same reason.

The problem may be that the Windows %temp% folder is compressed. See this reply for more information:

https://github.com/microsoft/WSL/issues/5437#issuecomment-786149638

Fix: Check that the %temp% folder is not compressed. If it is, unzip the folder and restart the computer.

If this is not possible (e.g. permissions are not sufficient), create a .wslconfig file in the %userprofile% folder and set its contents to

[wsl2]
swap=0

and restart the computer.

8. WSL 2: apt update gets stuck

Nature of the problem: when running apt update, it freezes for a long time to contact the server, after which it fails.

In addition, the ping/host commands do not work for domains. For example, there will be an error of the pattern

$ host google.com
;; connection timed out; no servers could be reached

This problem is caused by the fact that WSL does not always know how to correctly identify the address of the DNS server. See the card for more details:

https://github.com/microsoft/WSL/issues/4285

Workaround: follow the instructions below:

https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021

9. Docker won't start

For example, an error occurs:

Docker failed to initialize

when trying to start Docker manually. Manually because it hasn't started itself.

Personally, I got that fixed when

  1. ~/AppData/Roaming/Docker in the directory
    • backing up the settings.json file and then destroying it
    • destroying the file locked-directories
  2. shutting down all Docker instances (maybe even rebooting)
# linux_npm

10. Linux: bdw-skripti / NodeJS:n paketinhallinta (npm) ei toimi

Jos TIMia käynnistäessä/asentaessa bdw-skripti kaatuu virheeseen

TypeError: Class extends value undefined is not a constructor or null

niin joko sinulla on liian tuore versio npm:stä käytössä (et ole downgradettanut), tai npm-asennuksesi on rikki.

Rolling release -tyyppisissä Linux-jakeluissa (mm. Arch, Manjaro, Gentoo) npm saattaa mennä rikki kun paketinhallinta asentaa päivityksenä uuden version Node.js:stä/npm:stä.


Seuraavien askeleiden pitäisi ratkaista ongelma (komennot Arch-pohjaisille jakeluille, sovella tarpeen mukaan):

  1. Jos olet käyttänyt nvm-työkalua Node-versioiden hallintaan, poista se ja sen tekemät muokkaukset virallisten ohjeiden mukaan.

  2. Poista Node ja npm paketinhallinnan kautta:

    sudo pacman -R node-gyp nodejs-nopt semver npm nodejs
  3. Poista npm:n tiedostot:

    sudo rm -rf ~/.npm
    sudo rm -rf /usr/lib/node_modules/npm
  4. Asenna NodeJS ja npm uudelleen

    sudo pacman -Syy nodejs npm
  5. Tarkista että npm toimii

    npm -v

    Tämän pitäisi tulostaa npm:n versionumero, jos saat virheilmoituksen käy edellä olevat askeleet kohta kohdalta uudelleen läpi.

  6. Downgradeta npm

    npm install --global npm@6
  7. Tarkista että npm toimii

    npm -v

    Versionumeron pitäisi nyt olla 6.14.18 tai vastaava, ei kuitenkaan uudempi kuin 6.xx.xx.


Jos bdw vielä kaatuu virheeseen, kuten

An unhandled exception occurred: EACCES, Permission denied: ... /tim/timApp/static/scripts/build ...

niin poista tuo build hakemisto:

sudo rm -rf [TIM-JUURI]/timApp/static/scripts/build

jossa tuo [TIM-JUURI] on polku TIM-asennuksen juurihakemistoon, esim. /opt/tim.

Kokeile sitten ajaa bdw-skripti uudelleen.

Jos poistaminen ei meinaa onnistua, säädä build-kansion oikeudet

sudo chown -R $(whoami) [TIM-JUURI]/timApp/static/scripts/build

ja yritä sitten poistamista uudelleen.

11. Git: git-komentoa ei voi suorittaa

Jos git valittaa

fatal: detected dubious ownership in repository [TIM-POLKU]

niin aja virheilmoituksen mainitsema komento

git config --global --add safe.directory [TIM-POLKU]

jossa [TIM-POLKU] on se kansiopolku, johon asensit TIMin, oletuksena

C:\tim (Windowsilla)

/opt/tim (Linux)

These are the current permissions for this document; please modify if needed. You can always modify these permissions from the manage page.