devbox icon indicating copy to clipboard operation
devbox copied to clipboard

Corepack symlinks are relative and not absolute (they break if you move the devbox to a different directory depth)

Open foucist opened this issue 1 year ago • 1 comments

What happened?

after moving devbox with corepack enabled to a different directory the following error appears after running devbox shell:

Internal Error: EEXIST: file already exists, symlink '../../../../../../../../nix/store/6njmhaghg7x19cra79g8ljvxcxr77sfq-nodejs-14.21.3/lib/node_modules/corepack/dist/pnpm.js' -> '/Users/foucist/nested/test-devbox/.devbox/virtenv/nodejs/corepack-bin/pnpm'
Error: EEXIST: file already exists, symlink '../../../../../../../../nix/store/6njmhaghg7x19cra79g8ljvxcxr77sfq-nodejs-14.21.3/lib/node_modules/corepack/dist/pnpm.js' -> '/Users/foucist/nested/test-devbox/.devbox/virtenv/nodejs/corepack-bin/pnpm'

It should affect any corepack-bin pnpm / pnpx / yarn / yarnpkg regardless of the version of nodejs/etc due to the relative linking to reach /nix folder.

Steps to reproduce

  1. mkdir test-devbox
  2. cat > devbox.json
{
  "$schema":  "https://raw.githubusercontent.com/jetify-com/devbox/0.13.0/.schema/devbox.schema.json",
  "packages": ["nodejs@14"],
  "env": {
    "DEVBOX_COREPACK_ENABLED": "true"
  },
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}
  1. devbox shell
  2. exit
  3. cd ..
  4. mkdir nested
  5. mv test-devbox nested
  6. cd nested/test-devbox
  7. devbox shell

Command

shell

devbox.json

{
  "$schema":  "https://raw.githubusercontent.com/jetify-com/devbox/0.13.0/.schema/devbox.schema.json",
  "packages": ["nodejs@14"],
  "env": {
    "DEVBOX_COREPACK_ENABLED": "true"
  },
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}

Devbox version

0.13.0

Nix version

2.24.7

What system does this bug occur on?

macOS (Intel)

Debug logs

No response

foucist avatar Sep 26 '24 20:09 foucist

Fixing this bug might fix #1984

Looks like it's a corepack issue. The command corepack enable --install-directory .devbox/virtenv/nodejs/corepack-bin installs relative symlinks.

foucist avatar Sep 26 '24 20:09 foucist