Skip to content

Relative paths aren't evaluated properly in symlinked files #563

@rovo89

Description

@rovo89

I'm trying to include the devcontainer command in my Docker image. I extend a Next.js a standalone build by setting outputFileTracingIncludes to the results of nodeFileTrace() for the additional binaries I want to bundle.

Anyway, the issue is easily reproducable by installing @devcontainers/cli locally and then:

$ node_modules/.bin/nft print node_modules/.bin/devcontainer 
FILELIST:
node_modules/.bin/devcontainer
node_modules/@devcontainers/cli/devcontainer.js


WARNINGS:
Error: Failed to resolve dependency "./dist/spec-node/devContainersSpecCLI":
Cannot find module '/home/dev/vibe-web/node_modules/.bin/dist/spec-node/devContainersSpecCLI' loaded from /home/dev/vibe-web/node_modules/.bin/devcontainer

As usual, node_modules/.bin/devcontainer is just a symlink to ../@devcontainers/cli/devcontainer.js, which is really just:

#!/usr/bin/env node
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

require('./dist/spec-node/devContainersSpecCLI');

Seemingly, this relative path should be evaluated based on the actual file location / symlink target (../@devcontainers/cli/). Here's the test that it would work (despite some strange warnings that I assume to be caused by some settings in the nft CLI):

$ node_modules/.bin/nft print node_modules/.bin/../@devcontainers/cli/devcontainer.js
Skipping asset emission of /home/dev/vibe-web/*/* for /home/dev/vibe-web/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js as it is outside the package base /home/dev/vibe-web/node_modules/@devcontainers/cli
Skipping asset emission of /home/dev/vibe-web/*/* for /home/dev/vibe-web/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js as it is outside the package base /home/dev/vibe-web/node_modules/@devcontainers/cli
Skipping asset emission of /home/dev/vibe-web/*/* for /home/dev/vibe-web/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js as it is outside the package base /home/dev/vibe-web/node_modules/@devcontainers/cli
Skipping asset emission of /tmp for /home/dev/vibe-web/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js as it is outside the package base /home/dev/vibe-web/node_modules/@devcontainers/cli
FILELIST:
node_modules/@devcontainers/cli/devcontainer.js
node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js
node_modules/@devcontainers/cli/package.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is neededreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions