Skip to content

UnboundLocalError: local variable 'codecs' referenced before assignment #354

@nikmon2

Description

@nikmon2

Describe the bug

The server fails on start, with or without config

To Reproduce

Fails at run "python3 copyparty-sfx.py", log at bottom

Expected behavior

Not expecting a dump, but this is my first attempt to run copyparty

Server details (if you're NOT using docker/podman)

remove the ones that are not relevant:

  • server OS / version: Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-216-generic x86_64)

  • what copyparty did you grab: sfx

  • how you're running it: terminal

  • run copyparty with --version and grab the last 3 lines (they start with copyparty, CPython, sqlite) and paste them below this line:
    copyparty v1.18.7 "logtail" (2025-07-30)
    CPython v3.8.10 on Linux64 [GCC 9.4.0]
    sqlite 3.31.1*1 | jinja 2.10.1 | pyftpd 1.5.10 | tftp 0.4.0

  • copyparty arguments and/or config-file: no config file

Additional context

niklas@ubbe:~/copyparty$ python3 copyparty-sfx.py

[SFX] this is: copyparty 1.18.7
[SFX] packed at: 2025-07-30, 21:46:14 UTC, 1753911974
[SFX] archive is: /home/niklas/copyparty/copyparty-sfx.py
[SFX] python bin: /usr/bin/python3
[SFX] python ver: CPython 3.8.10 (default, Mar 18 2025, 20:04:55)
[GCC 9.4.0]

[SFX] found early
[SFX] jinja2: 2.10.1
[SFX] pyftpd: bundled
[SFX] sfxdir: /tmp/pe-copyparty.1000.15405.0

copyparty v1.18.7 "logtail" (2025-07-30)
CPython v3.8.10 on Linux64 [GCC 9.4.0]
sqlite 3.31.1*1 | jinja 2.10.1 | pyftpd 1.5.10 | tftp 0.4.0

no arguments provided; will use --qr

2025-07-31
04:22:54.610 root opening sessions-db /home/niklas/.config/copyparty/sessions.db
04:22:54.767 auth volumes and permissions:

"/" /home/niklas/copyparty
| read: everybody
| write: everybody
| move: --none--
| delete: --none--
| dots: --none--
| get: --none--
| upGet: --none--
| html: --none--
| uadmin: --none--

04:22:54.767 auth hint: enable searching and upload-undo with argument -e2dsa
04:22:54.767 auth hint: enable upload deduplication with --dedup (but see readme for consequences)
04:22:54.767 auth anyone can write to the current directory: /home/niklas/copyparty

04:22:54.767 root max clients: 1024
04:22:54.772 tcpsrv available @ http://127.0.0.1:3923/ (1-lo)
04:22:54.772 tcpsrv available @ http://[::1]:3923/ (1-lo)
04:22:54.772 tcpsrv available @ http://192.168.86.138:3923/ (2-enp0s4, external)
04:22:54.772 tcpsrv available @ http://[fdf6:1022:d1d0:440b:2a0:98ff:fe6a:cca6]:3923/ (2-enp0s4, external)
04:22:54.772 tcpsrv available @ http://172.17.0.1:3923/ (3-docker0)

04:22:54.779 optional-dependencies OK: sqlite, pillow, pillow-webp, ffmpeg, ffprobe, NG: vips, mutagen, argon2, pyzmq, pillow-heif, pillow-avif, see --deps (this is fine btw)
04:22:54.779 thumb decoder preference: pil, ff
04:22:54.780 thumb cln ok; rm 0 dirs

[SFX] retcode Traceback (most recent call last):
File "copyparty-sfx.py", line 277, in main
run(tmp, j2, ftp)
File "copyparty-sfx.py", line 217, in run
run_i(ld)
File "copyparty-sfx.py", line 229, in run_i
p()
File "/tmp/pe-copyparty.1000.15405.0/copyparty/main.py", line 1884, in main
SvcHub(al, dal, argv, "".join(printed)).run()
File "/tmp/pe-copyparty.1000.15405.0/copyparty/svchub.py", line 401, in init
self.broker = Broker(self)
File "/tmp/pe-copyparty.1000.15405.0/copyparty/broker_thr.py", line 30, in init
self.httpsrv = HttpSrv(self, None)
File "/tmp/pe-copyparty.1000.15405.0/copyparty/httpsrv.py", line 180, in init
self.j2 = {x: env.get_template(x + ".html") for x in jn}
File "/tmp/pe-copyparty.1000.15405.0/copyparty/httpsrv.py", line 180, in
self.j2 = {x: env.get_template(x + ".html") for x in jn}
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 830, in get_template
return self._load_template(name, self.make_globals(globals))
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 804, in _load_template
template = self.loader.load(self, name, globals)
File "/usr/lib/python3/dist-packages/jinja2/loaders.py", line 113, in load
source, filename, uptodate = self.get_source(environment, name)
File "/usr/lib/python3/dist-packages/jinja2/loaders.py", line 314, in get_source
rv = self.load_func(template)
File "/tmp/pe-copyparty.1000.15405.0/copyparty/httpsrv.py", line 166, in
env.loader = jinja2.FunctionLoader(lambda f: load_jinja2_resource(self.E, f))
File "/tmp/pe-copyparty.1000.15405.0/copyparty/httpsrv.py", line 96, in load_jinja2_resource
with load_resource(E, "web/" + name, "r") as f:
File "/tmp/pe-copyparty.1000.15405.0/copyparty/util.py", line 4022, in load_resource
stream = codecs.getreader(enc)(stream)
UnboundLocalError: local variable 'codecs' referenced before assignment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions