Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty lockfiles will trigger lockfile to init/populate #637

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

joshspicer
Copy link
Member

@joshspicer joshspicer commented Sep 12, 2023

This change provides a way to generate a lockfile without passing the --experimental-lockfile flag.

If a user want to "opt-in" to lockfiles, they may create an empty file in the expected location. The next build of the dev container will write the lockfile information.

This is useful for Codespace users who aren't able to directly influence the flags passed to the dev container CLI. For these users, the instructions to "opt-in" to lockfiles could be to touch .devcontainer-lock.json and rebuild their codespace.

Note that if the --experimental-frozen-lockfile flag is passed, an empty lockfile WILL be considered different and the CLI will throw an error.

Today, providing an empty lockfile throws a JSON parsing error:

[1 ms] @devcontainers/cli 0.51.2. Node.js v16.20.0. linux 5.15.0-1041-azure x64.
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at readLockfile (/workspaces/cli/dist/spec-node/devContainersSpecCLI.js:53202:17)
    at async generateFeaturesConfig (/workspaces/cli/dist/spec-node/devContainersSpecCLI.js:54093:20)
    at async getExtendImageBuildInfo (/workspaces/cli/dist/spec-node/devContainersSpecCLI.js:55410:26)
    at async extendImage (/workspaces/cli/dist/spec-node/devContainersSpecCLI.js:55333:30)
    at async buildNamedImageAndExtend (/workspaces/cli/dist/spec-node/devContainersSpecCLI.js:56402:10)
    at async openDockerfileDevContainer (/workspaces/cli/dist/spec-node/devContainersSpecCLI.js:56336:19)
    at async resolveWithLocalFolder (/workspaces/cli/dist/spec-node/devContainersSpecCLI.js:57198:14)
    at async launch2 (/workspaces/cli/dist/spec-node/devContainersSpecCLI.js:57252:18)
    at async doProvision (/workspaces/cli/dist/spec-node/devContainersSpecCLI.js:60128:20)
{"outcome":"error","message":"Unexpected end of JSON input","description":"An error occurred setting up the container."}

@joshspicer joshspicer requested a review from a team as a code owner September 12, 2023 23:08
@joshspicer joshspicer changed the title Empty (no characters) lockfiles will trigger lockfile to init/populate Empty lockfiles will trigger lockfile to init/populate Sep 12, 2023
Copy link
Contributor

@chrmarti chrmarti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, thanks!

@joshspicer joshspicer merged commit 71bb59f into main Sep 13, 2023
37 checks passed
@joshspicer joshspicer deleted the joshspicer/empty-lockfile-init branch September 13, 2023 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants