Open qknight opened 2 years ago
The issue seems to be that \r
characters end up inside files copied into the Docker image:
> docker run -it --entrypoint=bash fred2
root@903d7de32e56:/# ls
bin boot conf dev etc home lib lib64 media mnt opt proc root run sbin srv start.py sys tmp usr var
root@903d7de32e56:/# /start.py
bash: /start.py: /usr/local/bin/python^M: bad interpreter: No such file or directory
start.py
is successfully copied, just with Windows line endings.
As a workaround, you could try re-saving docker/start.py
with Unix line endings and rebuilding the image.
Presumably docker is just copying the raw file?
As a workaround, you could try re-saving
docker/start.py
with Unix line endings and rebuilding the image.
If you've got windows line endings on start.py
, its unlikely to be the only file so afflicted.
I'm not very familiar with Windows stuff, but this doesn't sound like a problem we can solve?
Presumably docker is just copying the raw file?
I'm assuming that's what's happening. git clone
converts the line endings to \r\n
, then docker copies them verbatim into the container.
It is possible to tell Git to leave the line-endings as-is when cloning a repo, via some .gitattributes
magic: https://git-scm.com/docs/gitattributes . I can't remember off the top of my head how, and I'm not convinced that's the right solution.
Despite being on Linux, python
seems happy to run files that contain Windows line endings:
root@903d7de32e56:/# python start.py
Config file '/data/homeserver.yaml' does not exist. [...]
so once start.py
is running, things might just work if you're lucky, assuming we never leave the Python interpreter / try to exec anything else (which may or may not be a valid assumption).
fwiw, I have the following git config magic on Windows not even related to Synapse to avoid problems.
~/.gitconfig
[core]
autocrlf = input
eol = lf
core.autocrlf = true
- Text files checked-out from the repository will keep original EOL characters in your working tree.
- Text files in your working tree with
CRLF
characters are normalized toLF
when committed back to the repository.
Also a nice table in https://stackoverflow.com/a/41282375/796832 for how core.autocrlf = true
interacts with git commit
and git checkout
Description
I'm not able to build the docker image and then run it on my windows machine using docker desktop:
The build:
And running the generate
docker run -it --rm --mount type=volume,src=synapse-data,dst=/data -e SYNAPSE_SERVER_NAME=my.matrix.host fred2 generate exec /start.py: no such file or directory
Steps to reproduce
git clone https://github.com/matrix-org/synapse.git cd synapse docker build --no-cache -f docker/Dockerfile -t fred2 . docker run -it --rm --mount type=volume,src=synapse-data,dst=/data -e SYNAPSE_SERVER_NAME=my.matrix.host fred2 generate
Homeserver
does not apply i think
Synapse Version
v1.66.0 / v1.60.0 / v1.56.0
Installation Method
Other (please mention below)
Platform
My docker desktop configuration:
I'm using WSL2 backend in for docker and this is my configuration:
Relevant log output
Anything else that would be useful to know?
I can reproduce this on a different Windows machine with similar setup:
Update: Seems to be a Docker Windows problem because on my linux host it was able to build&execute properly.