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

Cannot fetch input 'path:./glibc-patch' because it uses a relative path #2481

Open
dwayne opened this issue Jan 16, 2025 · 9 comments
Open
Labels
bug Something isn't working triage Issue needs triage

Comments

@dwayne
Copy link

dwayne commented Jan 16, 2025

What happened?

Trying to open a Devbox shell with Python version 3.13.1 (but the version doesn't seem to matter) I get the following error:

Info: Ensuring packages are installed.
✓ Computed the Devbox environment.
Error: nix: command error: nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/home/dwaynecrooks/devbox-glibc-patch-issue/.devbox/gen/flake: cannot fetch input 'path:./glibc-patch' because it uses a relative path: exit code 1

Other relevant details

The file at .devbox/gen/flake/flake.nix seems to be the issue:

{
   description = "A devbox shell";

   inputs = {
     nixpkgs.url = "github:NixOS/nixpkgs/75a52265bda7fd25e06e3a67dee3f0354e73243c";
     glibc-patch.url = "path:./glibc-patch";
   };

   outputs = {
     self,
     nixpkgs,
     glibc-patch,
   }:
      let
        pkgs = nixpkgs.legacyPackages.x86_64-linux;
      in
      {
        devShells.x86_64-linux.default = pkgs.mkShell {
          buildInputs = [
            
            (builtins.trace "evaluating glibc-patch.packages.x86_64-linux.python313" glibc-patch.packages.x86_64-linux.python313)
          ];
        };
      };
 }

Specifically, glibc-patch.url = "path:./glibc-patch";.

The template used is: https://github.com/jetify-com/devbox/blob/0.13.7/internal/shellgen/tmpl/flake.nix.tmpl
The glibc-patch.url value comes from: https://github.com/jetify-com/devbox/blob/0.13.7/internal/shellgen/flake_input.go#L16

When I use the following devbox.json instead everything works fine.

{
  "packages": {
    "python": {
      "version": "3.13.1",
      "patch": "never"
    }
  }
}

Steps to reproduce

  1. Add Python 3.13.1 (or any other version) to your project.
  2. Run devbox shell.

Command

shell

devbox.json

{
  "packages": [
    "[email protected]"
  ]
}

Devbox version

0.13.7

Nix version

nix (Nix) 2.25.4

What system does this bug occur on?

Linux (x86-64)

Debug logs

time=2025-01-16T07:56:50.851-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:125 msg="searching for config file (including parent directories)" path=.
time=2025-01-16T07:56:50.851-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:146 msg="trying config file" path=devbox.json
time=2025-01-16T07:56:50.852-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:133 msg="config file found" path=/home/dwaynecrooks/devbox-glibc-patch-issue/devbox.json dur=175.65µs
time=2025-01-16T07:56:50.852-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2025-01-16T07:56:50.852-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:125 msg="searching for config file (including parent directories)" path=.
time=2025-01-16T07:56:50.852-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:146 msg="trying config file" path=devbox.json
time=2025-01-16T07:56:50.852-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:133 msg="config file found" path=/home/dwaynecrooks/devbox-glibc-patch-issue/devbox.json dur=32.369µs
time=2025-01-16T07:56:50.852-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2025-01-16T07:56:50.877-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/nix.go:342 msg="nix --version --debug output" out="nix (Nix) 2.25.4\nSystem type: x86_64-linux\nAdditional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux\nFeatures: gc, signed-caches\nSystem configuration file: /etc/nix/nix.conf\nUser configuration files: /home/dwaynecrooks/.config/nix/nix.conf:/etc/xdg/xdg-pop/nix/nix.conf:/etc/xdg/nix/nix.conf\nStore directory: /nix/store\nState directory: /nix/var/nix\nData directory: /nix/store/6n9s2qsamfkza3d50z5ka670f7cm7gra-nix-2.25.4/share\n"
time=2025-01-16T07:56:50.885-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:60 msg="nix command starting" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' eval --impure --raw --expr builtins.currentSystem" cmd.path=/home/dwaynecrooks/.nix-profile/bin/nix
time=2025-01-16T07:56:50.912-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:67 msg="nix command exited" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' eval --impure --raw --expr builtins.currentSystem" cmd.path=/home/dwaynecrooks/.nix-profile/bin/nix cmd.pid=9095 cmd.code=0 cmd.dur=26.421338ms
time=2025-01-16T07:56:50.912-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:125 msg="searching for config file (including parent directories)" path=.
time=2025-01-16T07:56:50.912-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:146 msg="trying config file" path=devbox.json
time=2025-01-16T07:56:50.912-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:133 msg="config file found" path=/home/dwaynecrooks/devbox-glibc-patch-issue/devbox.json dur=62.138µs
time=2025-01-16T07:56:50.912-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2025-01-16T07:56:50.912-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2025-01-16T07:56:50.912-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2025-01-16T07:56:50.912-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
Info: Ensuring packages are installed.
time=2025-01-16T07:56:50.912-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/plugin/plugin.go:85 msg="creating files for package" [email protected]
time=2025-01-16T07:56:50.912-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/plugin/plugin.go:128 msg="Creating file %q from contentPath: %q" /home/dwaynecrooks/devbox-glibc-patch-issue/.devbox/virtenv/python/bin/venvShellHook.sh=python/venvShellHook.sh
time=2025-01-16T07:56:51.229-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2025-01-16T07:56:51.229-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:60 msg="nix command starting" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' path-info --offline --json /nix/store/acxvfb890g9jawlxsj7zs8marxxvzrrs-python3-3.13.1" cmd.path=/home/dwaynecrooks/.nix-profile/bin/nix
time=2025-01-16T07:56:51.254-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:67 msg="nix command exited" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' path-info --offline --json /nix/store/acxvfb890g9jawlxsj7zs8marxxvzrrs-python3-3.13.1" cmd.path=/home/dwaynecrooks/.nix-profile/bin/nix cmd.pid=9101 cmd.code=0 cmd.dur=25.176688ms
time=2025-01-16T07:56:51.254-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2025-01-16T07:56:51.254-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/plugin/plugin.go:85 msg="creating files for package" pkg=python313
time=2025-01-16T07:56:51.254-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/plugin/plugin.go:128 msg="Creating file %q from contentPath: %q" /home/dwaynecrooks/devbox-glibc-patch-issue/.devbox/virtenv/python/bin/venvShellHook.sh=python/venvShellHook.sh
time=2025-01-16T07:56:51.254-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
time=2025-01-16T07:56:51.255-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/shellgen/flake_plan.go:155 msg="creating new patch flake" flake.inputs.devbox=github:jetify-com/devbox/0.13.7 flake.inputs.nixpkgs-glibc=flake:nixpkgs/75a52265bda7fd25e06e3a67dee3f0354e73243c flake.inputs.nixpkgs-de1864=github:NixOS/nixpkgs/de1864217bfa9b5845f465e771e0ecb48b30e02d flake.outputs=[python313]
time=2025-01-16T07:56:51.255-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/nix.go:85 msg="running print-dev-env cmd" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/home/dwaynecrooks/devbox-glibc-patch-issue/.devbox/gen/flake"
time=2025-01-16T07:56:51.255-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:60 msg="nix command starting" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/home/dwaynecrooks/devbox-glibc-patch-issue/.devbox/gen/flake" cmd.path=/home/dwaynecrooks/.nix-profile/bin/nix
⣾ Computing the Devbox environment...
time=2025-01-16T07:56:51.284-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:67 msg="nix command exited" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/home/dwaynecrooks/devbox-glibc-patch-issue/.devbox/gen/flake" cmd.path=/home/dwaynecrooks/.nix-profil✓ Computed the Devbox environment.
Error: nix: command error: nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/home/dwaynecrooks/devbox-glibc-patch-issue/.devbox/gen/flake: cannot fetch input 'path:./glibc-patch' because it uses a relative path: exit code 1

time=2025-01-16T07:56:51.284-04:00 level=ERROR source=go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:68 msg="command error" stderr="error:\n       … while updating the lock file of flake 'path:/home/dwaynecrooks/devbox-glibc-patch-issue/.devbox/gen/flake?lastModified=1737028229&narHash=sha256-/C%2BUIPZJJi49lT5UmQY7U/X4kdorZZG9F1iOtEBCvt8%3D'\n\n       … while updating the flake input 'glibc-patch'\n\n       … while fetching the input 'path:./glibc-patch'\n\n       error: cannot fetch input 'path:./glibc-patch' because it uses a relative path\n" execid=9c039e6bbbaf44499b8fa8091feafc55 stack=<nil>
time=2025-01-16T07:56:51.284-04:00 level=ERROR source=go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:70 msg="command error" execid=9c039e6bbbaf44499b8fa8091feafc55 stack=<nil>
time=2025-01-16T07:56:51.284-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:125 msg="searching for config file (including parent directories)" path=.
time=2025-01-16T07:56:51.284-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:146 msg="trying config file" path=devbox.json
time=2025-01-16T07:56:51.284-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devconfig/config.go:133 msg="config file found" path=/home/dwaynecrooks/devbox-glibc-patch-issue/devbox.json dur=54.531µs
time=2025-01-16T07:56:51.284-04:00 level=DEBUG source=go.jetpack.io/devbox/internal/devpkg/package.go:198 msg="package needs patching" pkg=python mode=auto
@dwayne dwayne added bug Something isn't working triage Issue needs triage labels Jan 16, 2025
@dwayne
Copy link
Author

dwayne commented Jan 16, 2025

So I tried using an absolute path to see if it would work and it did.

I replaced

glibc-patch.url = "path:./glibc-patch";

with

glibc-patch.url = "path:/home/dwaynecrooks/devbox-glibc-patch-issue/.devbox/gen/flake/glibc-patch";

and ran

nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/home/dwaynecrooks/devbox-glibc-patch-issue/.devbox/gen/flake

and it worked with no problems.

Relative paths in flake inputs seems to be the problem but my research on it hasn't yielded much good advise. If that was being used for 2 years and no one seems to have had a problem with it then it has to be a recent change to nix flakes to be causing the problem.

@dwayne
Copy link
Author

dwayne commented Jan 16, 2025

For e.g. this documentation doesn't say that using relative paths would lead to problems in flake inputs.

See this comment instead.

@abeltavares
Copy link

abeltavares commented Jan 16, 2025

I’m having the same issue, and the fix @dwayne suggested was also what worked for me.
But this isn’t a great solution since it’s manual, requires to edit the file, which isn’t practical.
Also this worked fine last week, so something must have changed recently.

@dwayne
Copy link
Author

dwayne commented Jan 16, 2025

Actually, reading further down in the documentation under the path bulletpoint in Types it does mention that relative paths should only be used on the command line and when the referenced flake is not in a git repository.


path: arbitrary local directories. The required attribute path specifies the path of the flake. The URL form is

path:<path>(\?<params>)?

where path is an absolute path to a directory in the file system containing a file named flake.nix.

If the flake at path is not inside a git repository, the path: prefix is implied and can be omitted.

path generally must be an absolute path. However, on the command line, it can be a relative path (e.g. . or ./foo)
which is interpreted as relative to the current directory. In this case, it must start with . to avoid ambiguity with
registry lookups (e.g. nixpkgs is a registry lookup; ./nixpkgs is a relative path).

For example, these are valid path flake references:

  • path:/home/user/sub/dir
  • /home/user/sub/dir (if dir/flake.nix is not in a git repository)
  • ./sub/dir (when used on the command line and dir/flake.nix is not in a git repository)

@abeltavares
Copy link

#2421
This issue seems to be related to the same problem since Devbox fails to handle relative paths correctly when generating Flakes.

@maxiem-ota-insight
Copy link

Almost certainly related: NixOS/nix#12248

@ZTGallagher
Copy link

ZTGallagher commented Jan 20, 2025

Even after the proposed (albeit temporary) fix, devbox shell still fails, and the glibc-patch.url is replaced with the relative path after I run it. This is making devbox completely unusable, unfortunately. (Free software, I get it, no complaints, but it's a bummer).

@bdjellabaldebaran
Copy link

On my side, upgrading nix with nix upgrade-nix (to nix-2.24.11) fixed the issue:

$ devbox shell
Info: Ensuring packages are installed.
✓ Computed the Devbox environment.
Error: nix: command error: nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/tmp/.devbox/gen/flake: cannot fetch input 'path:./glibc-patch' because it uses a relative path: exit code 1

$ nix upgrade-nix
[...]

$ devbox shell               
Info: Ensuring packages are installed.
✓ Computed the Devbox environment.
Starting a devbox shell...

Poetry could not find a pyproject.toml file in /tmp or its parents
Virtual environment directory doesn't exist. Creating new one...
(devbox) $

@ZTGallagher
Copy link

ZTGallagher commented Jan 22, 2025

I can try a downgrade, but for me the same is still happening on 2.25.4

vagrant in 🌐 ubuntu in app on  main [✘!?] via 🐍 v3.13.1
❯ devbox version
0.13.7

vagrant in 🌐 ubuntu in app on  main [✘!?] via 🐍 v3.13.1
❯ nix --version
nix (Nix) 2.25.4

vagrant in 🌐 ubuntu in app on  main [✘!?] via 🐍 v3.13.1
❯ bat devbox.json
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: devbox.json
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ {
   2 ~"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.7/.schema/devbox.schema.json",
   3 ~"packages": [
   4 ~"python@latest",
   5   │     ],
   6 ~"shell": {
   7 ~"init_hook": [
   8 ~"echo 'Welcome to devbox!' > /dev/null"
   9 ~ │       ],
  10 ~"scripts": {
  11 ~"test": [
  12 ~"echo \"Error: no test specified\" && exit 1"
  13 ~ │         ]
  14 ~ │       }
  15   │     }
  16   │   }
  17 ~ │
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

vagrant in 🌐 ubuntu in app on  main [✘!?] via 🐍 v3.13.1
❯ devbox shell
Info: Ensuring packages are installed.
✓ Computed the Devbox environment.
Error: nix: command error: nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/home/vagrant/code/app/.devbox/gen/flake: cannot fetch input 'path:./glibc-patch' because it uses a relative path: exit code 1

Error: There was an internal error. Run with DEVBOX_DEBUG=1 for a detailed error message, and consider reporting it at https://github.com/jetify-com/devbox/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issue needs triage
Development

No branches or pull requests

5 participants