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

Undefined variable 'dotnet-sdk_9' #1246

Open
1 task done
michel-jump opened this issue Dec 23, 2024 · 4 comments
Open
1 task done

Undefined variable 'dotnet-sdk_9' #1246

michel-jump opened this issue Dec 23, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@michel-jump
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

This happens when I use nixpacks buid in a .NET 9 project.

nixpacks build ./

╔═════════════════════ Nixpacks v1.30.0 ═════════════════════╗
║ setup      │ dotnet-sdk_9                                  ║
║────────────────────────────────────────────────────────────║
║ install    │ dotnet restore                                ║
║────────────────────────────────────────────────────────────║
║ build      │ dotnet publish --no-restore -c Release -o out ║
║────────────────────────────────────────────────────────────║
║ start      │ ./out/Application                             ║
╚════════════════════════════════════════════════════════════╝

[+] Building 15.3s (8/13)                                                                                                                                                                              docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                                   0.0s
 => => transferring dockerfile: 844B                                                                                                                                                                                   0.0s
 => [internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1733184274                                                                                                                                         0.4s
 => [internal] load .dockerignore                                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                                        0.0s
 => [1/9] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1733184274@sha256:91b1c0ad82b8a7ad531acdb8acf466f0cdbfd9738cf1b31286ca09f9dbb12e21                                                                                   0.0s
 => [internal] load build context                                                                                                                                                                                      0.3s
 => => transferring context: 2.56MB                                                                                                                                                                                    0.3s
 => CACHED [2/9] WORKDIR /app/                                                                                                                                                                                         0.0s
 => CACHED [3/9] COPY .nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix .nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix                                                                    0.0s
 => ERROR [4/9] RUN nix-env -if .nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix && nix-collect-garbage -d                                                                                              14.5s
------                                                                                                                                                                                                                      
 > [4/9] RUN nix-env -if .nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix && nix-collect-garbage -d:                                                                                                          
0.178 unpacking 'https://github.com/NixOS/nixpkgs/archive/5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.tar.gz' into the Git cache...                                                                                            
13.83 installing '5148520bfab61f99fd25fb9ff7bfbb50dad3c9db-env'                                                                                                                                                             
13.90 error:                                                                                                                                                                                                                
13.90        … while calling the 'derivationStrict' builtin                                                                                                                                                                 
13.90          at <nix/derivation-internal.nix>:34:12:
13.90            33|
13.90            34|   strict = derivationStrict drvAttrs;
13.90              |            ^
13.90            35|
13.90 
13.90        … while evaluating derivation '5148520bfab61f99fd25fb9ff7bfbb50dad3c9db-env'
13.90          whose name attribute is located at /nix/store/lgcjj6s23v2203zyihsd0j26wh1saj0c-source/pkgs/stdenv/generic/make-derivation.nix:300:7
13.90 
13.90        … while evaluating attribute 'passAsFile' of derivation '5148520bfab61f99fd25fb9ff7bfbb50dad3c9db-env'
13.90          at /nix/store/lgcjj6s23v2203zyihsd0j26wh1saj0c-source/pkgs/build-support/trivial-builders/default.nix:88:7:
13.90            87|       inherit buildCommand name;
13.90            88|       passAsFile = [ "buildCommand" ]
13.90              |       ^
13.90            89|         ++ (derivationArgs.passAsFile or []);
13.90 
13.90        (stack trace truncated; use '--show-trace' to show the full, detailed trace)
13.90 
13.90        error: undefined variable 'dotnet-sdk_9'
13.90        at /app/.nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix:19:9:
13.90            18|         '')
13.90            19|         dotnet-sdk_9
13.90              |         ^
13.90            20|       ];
------
Dockerfile:8
--------------------
   6 |     
   7 |     COPY .nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix .nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix
   8 | >>> RUN nix-env -if .nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix && nix-collect-garbage -d
   9 |     
  10 |     
--------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c nix-env -if .nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix && nix-collect-garbage -d" did not complete successfully: exit code: 1

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/m1n4wn2a8hvnswg3gn29yaz0d
Error: Docker build failed

To reproduce

  • Setup an .NET 9 project.
  • Run nixpacks build ./ in the right directory

Expected behavior

I expect nixpacks to build the application.

Environment

OS: macOS 15.2 (M3 Pro)
Nixpacks version: 1.30.0 (installed via Homebrew)

@michel-jump michel-jump added the bug Something isn't working label Dec 23, 2024
@SwizzleZticks
Copy link

I have this issue as well, any fixes yet?

@DavidRod1865
Copy link

I have this issue as well, any fixes yet?

The temp solution I found was to downgrade to 7.0. For it to be fixed, the nixpacks needs to be updated to have 9.0 has the base version.

Hopefully after downgrading to 7.0, it works for you too.

To downgrade your .NET project from version 9.0 to 7.0, follow these steps:

  1. Update TargetFramework in Your Project File
    • Open your .csproj file.
    • Look for the element and change it from .NET 9.0 to .NET 7.0.

  2. Update SDK Version
    • Open your global.json file (if it exists).
    • Ensure the "version" points to a .NET 7.0-compatible SDK.

  3. Reinstall .NET 7.0 SDK
    • If .NET 7.0 is not already installed, download and install it from the official .NET downloads page.

  4. Update NuGet Packages
    • Run the following commands to update packages:

dotnet restore
dotnet outdated --update-versions

  1. Rebuild and Test Your Project

dotnet clean
dotnet build

@ayush-lal
Copy link

Instead of downgrading and relying on Nixpacks, why not just use docker?

@SwizzleZticks
Copy link

Instead of downgrading and relying on Nixpacks, why not just use docker?

That is actually what I actually ended up doing, and now it works.

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

No branches or pull requests

4 participants