I am trying to change the directory in a command with cd but this does not work.
I know of the possibility to change the working directory with withWorkdir but this is not applicable in my usecase because this could be a (user-supplied) line like: cd /temp/prod && bun install --frozen-lockfile --production. Is the following result expected or can this be fixed?
Code:
async function main() {
await connect(
async (client) => {
const container = client
.container()
.from('alpine')
.withExec(['mkdir', '-p', '/app'])
.withExec(['cd', '/app'])
await container.sync();
},
{ LogOutput: process.stdout },
);
}
main();```
Results in:
[...]
ExecError: resolve: process "cd /app" did not complete successfully: exit code: 2
at compute (file://.../node_modules/.pnpm/@dagger.io+dagger@0.14.0/node_modules/@dagger.io/dagger/dist/api/utils.js:148:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async computeQuery (file://.../node_modules/.pnpm/@dagger.io+dagger@0.14.0/node_modules/@dagger.io/dagger/dist/api/utils.js:107:12)
at async Container.sync (file://.../node_modules/.pnpm/@dagger.io+dagger@0.14.0/node_modules/@dagger.io/dagger/dist/api/client.gen.js:723:26)
at async connect.LogOutput (.../test.ts:11:7)
at async connect (file://.../node_modules/.pnpm/@dagger.io+dagger@0.14.0/node_modules/@dagger.io/dagger/dist/connect.js:63:5)
at async main (.../test.ts:4:3) {
cause: undefined,
code: 'D109',
cmd: [ 'cd', '/app' ],
exitCode: 2,
stdout: '',
stderr: '[dumb-init] cd: No such file or directory'
}
Node.js v20.18.0