docker-node
docker-node copied to clipboard
os.EOL is CRLF on linux docker images
Environment
- Platform: macOS Sonoma (arm64 & x86_64)
- Node.js Version: v18.20.3
- Image Tag: 18, 18-bookworm-slim (affects all docker images as far as I can tell)
- Docker Version:
Colima 24.0.7
❯ docker info Client: Docker Engine - Community Version: 26.1.3 Context: colima Debug Mode: false
Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 1 Server Version: 24.0.7 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Using metacopy: false Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 runc Default Runtime: runc Init Binary: docker-init containerd version: d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f runc version: v1.1.10-0-g18a0cb0 init version: de40ad0 Security Options: apparmor seccomp Profile: builtin cgroupns Kernel Version: 6.5.0-28-generic Operating System: Ubuntu 23.10 OSType: linux Architecture: aarch64 CPUs: 2 Total Memory: 1.851GiB Name: colima ID: 942780f7-70a0-40e1-836a-785646f5b955 Docker Root Dir: /var/lib/docker Debug Mode: false Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false
Docker Desktop 26.1.1
❯ docker info Client: Docker Engine - Community Version: 26.1.3 Context: desktop-linux Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc.) Version: v0.14.0-desktop.1 Path: /Users/cassidy/.docker/cli-plugins/docker-buildx compose: Docker Compose (Docker Inc.) Version: v2.27.0-desktop.2 Path: /Users/cassidy/.docker/cli-plugins/docker-compose debug: Get a shell into any image or container (Docker Inc.) Version: 0.0.29 Path: /Users/cassidy/.docker/cli-plugins/docker-debug dev: Docker Dev Environments (Docker Inc.) Version: v0.1.2 Path: /Users/cassidy/.docker/cli-plugins/docker-dev extension: Manages Docker extensions (Docker Inc.) Version: v0.2.23 Path: /Users/cassidy/.docker/cli-plugins/docker-extension feedback: Provide feedback, right in your terminal! (Docker Inc.) Version: v1.0.4 Path: /Users/cassidy/.docker/cli-plugins/docker-feedback init: Creates Docker-related starter files for your project (Docker Inc.) Version: v1.1.0 Path: /Users/cassidy/.docker/cli-plugins/docker-init sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.) Version: 0.6.0 Path: /Users/cassidy/.docker/cli-plugins/docker-sbom scout: Docker Scout (Docker Inc.) Version: v1.8.0 Path: /Users/cassidy/.docker/cli-plugins/docker-scout
Server: Containers: 1 Running: 1 Paused: 0 Stopped: 0 Images: 28 Server Version: 26.1.1 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Using metacopy: false Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 runc Default Runtime: runc Init Binary: docker-init containerd version: e377cd56a71523140ca6ae87e30244719194a521 runc version: v1.1.12-0-g51d5e94 init version: de40ad0 Security Options: seccomp Profile: unconfined cgroupns Kernel Version: 6.6.26-linuxkit Operating System: Docker Desktop OSType: linux Architecture: aarch64 CPUs: 10 Total Memory: 7.657GiB Name: docker-desktop ID: 2ac46fb7-7ad9-48bb-b7a8-b31225598358 Docker Root Dir: /var/lib/docker Debug Mode: false HTTP Proxy: http.docker.internal:3128 HTTPS Proxy: http.docker.internal:3128 No Proxy: hubproxy.docker.internal Labels: com.docker.desktop.address=unix:///Users/cassidy/Library/Containers/com.docker.docker/Data/docker-cli.sock Experimental: false Insecure Registries: hubproxy.docker.internal:5555 127.0.0.0/8 Live Restore Enabled: false
WARNING: daemon is not using the default seccomp profile
Expected Behavior
os.EOL should return 0a (\n)
or LF, matching the operating system line feed for Debian
Current Behavior
os.EOL returns 0d 0a (\r\n)
or CRLF
Possible Solution
I am unsure. I have not found the root cause.
Steps to Reproduce
On any macOS or linux system running docker:
docker run --rm -it node:18 -p 'require("os").EOL' | hexdump -c
node -p 'require("os").EOL' | hexdump -c
0000000 \r \n \r \n (wrong)
0000004
0000000 \n \n (correct)
0000002
Additional Information
This is causing errors with yarn@3
yarn.lock file. When ran with the --immutable
tag, yarn will attempt to re-write the yarn.lock file with CRLF line endings, causing any build to fail. This was changed in this issue: https://github.com/yarnpkg/yarn/issues/1061