Error when using docker in bootstrap.py : TypeError: expected str, bytes or os.PathLike object, not int

Hello all
Got an error when starting for the first time a server using docker.
It seems it can’t run the script to setup the db I have no idea why

seafile            | [2024-02-01 00:29:35] Now running setup-seafile-mysql.py in auto mode.
seafile-mysql      | 2024-02-01  0:29:35 3 [Warning] Aborted connection 3 to db: 'unconnected' user: 'seafile' host: '172.22.0.4' (Got an error reading communication packets)
seafile            | Traceback (most recent call last):
seafile            |   File "/scripts/start.py", line 95, in <module>
seafile            | waiting for mysql server to be ready: %s (2003, "Can't connect to MySQL server on 'db' ([Errno 111] Connection refused)")
seafile            |     main()
seafile            |   File "/scripts/start.py", line 59, in main
seafile            |     init_seafile_server()
seafile            |   File "/scripts/bootstrap.py", line 166, in init_seafile_server
seafile            |     call('{} auto -n seafile'.format(setup_script), env=env)
seafile            |   File "/scripts/utils.py", line 70, in call
seafile            |     return subprocess.check_call(*a, **kw)
seafile            |   File "/usr/lib/python3.10/subprocess.py", line 364, in check_call
seafile            |     retcode = call(*popenargs, **kwargs)
seafile            |   File "/usr/lib/python3.10/subprocess.py", line 345, in call
seafile            |     with Popen(*popenargs, **kwargs) as p:
seafile            |   File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
seafile            |     self._execute_child(args, executable, preexec_fn, close_fds,
seafile            |   File "/usr/lib/python3.10/subprocess.py", line 1783, in _execute_child
seafile            |     env_list.append(k + b'=' + os.fsencode(v))
seafile            |   File "/usr/lib/python3.10/os.py", line 811, in fsencode
seafile            |     filename = fspath(filename)  # Does type-checking of `filename`.
seafile            | TypeError: expected str, bytes or os.PathLike object, not int
1 Like

I dug into the code and I figure it out, in /scripts/bootstrap.py line 149, the mysql_port environement variable should NOT be cast to an int

it should be like that

    env = {
        'SERVER_NAME': 'seafile',
        'SERVER_IP': get_conf('SEAFILE_SERVER_HOSTNAME', 'seafile.example.com'),
        'MYSQL_USER': 'seafile',
        'MYSQL_USER_PASSWD': str(uuid.uuid4()),
        'MYSQL_USER_HOST': '%.%.%.%',
        'MYSQL_HOST': get_conf('DB_HOST', '127.0.0.1'),
        'MYSQL_PORT': get_conf('DB_PORT', '3306'),
        # Default MariaDB root user has empty password and can only connect from localhost.
        'MYSQL_ROOT_PASSWD': get_conf('DB_ROOT_PASSWD', ''),
    }

Dunno why nobody reported it before ? it’s odd

1 Like

commit from last week ! that might explain why.

1 Like

Thank you! You just saved me a lot of hassle. I’m new to Seafile and wanted to just try it out but couldn’t seem to get past the same error you were having. For now I just went back to 11.0.4 and it seems to work on a first glance. Hopefully someone sees your post and is able to implement the fix soon.

Thanks for your feedback, we have updated the seafileltd/seafile-mc:latest image.
You can install Seafile by docker pull seafileltd/seafile-mc:latest and then execute docker compose up

1 Like