node-pty
node-pty copied to clipboard
"Error: chdir() failed: Not a directory" when in Docker on M1 using DOCKER_DEFAULT_PLATFORM=linux/amd64
Environment details
- OS: Debian in Docker + macOS
- OS version: Debian Bullseye 20220527, macOS: Monterey 12.1
- node-pty version: 0.11.0-beta19
- node version: 14
Issue description
When trying to run in Docker on an Apple M1 using the environment variable DOCKER_DEFAULT_PLATFORM=linux/amd64 I get the error: Error: chdir() failed: Not a directory
A hopefully minimal example:
Dockerfile
FROM debian:bullseye-20220527
RUN \
apt-get update && \
apt-get install -y \
build-essential \
curl && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
rm /etc/apt/sources.list.d/nodesource.list && \
rm -rf /var/lib/apt/lists/*
RUN \
npm install [email protected]
COPY n.js /
n.js (the example from the README):
var os = require('os');
var pty = require('node-pty');
var shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
var ptyProcess = pty.spawn(shell, [], {
name: 'xterm-color',
cols: 80,
rows: 30,
cwd: process.env.HOME,
env: process.env
});
ptyProcess.on('data', function(data) {
process.stdout.write(data);
});
ptyProcess.write('ls\r');
ptyProcess.resize(100, 40);
ptyProcess.write('ls\r');
Then I build the Dockerfile using
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker build . -t n
and then running it using
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -it n node n.js
Gives the error:
/node_modules/node-pty/lib/unixTerminal.js:103
var term = pty.fork(file, args, parsedEnv, cwd, _this._cols, _this._rows, uid, gid, (encoding === 'utf8'), closeFDs, onexit, helperPath);
^
Error: chdir() failed: Not a directory
at new UnixTerminal (/node_modules/node-pty/lib/unixTerminal.js:103:24)
at Object.spawn (/node_modules/node-pty/lib/index.js:29:12)
at Object.<anonymous> (/n.js:6:22)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
at internal/main/run_main_module.js:17:47
If I don't use DOCKER_DEFAULT_PLATFORM=linux/amd64 then it seems to work fine