Cannot build Scala project using jdk 21

epic-64
HOBBY

4 months ago

In order to use some newer GC options I decided to target java 21 with my scala web app.

I set the variable NIXPACKS_JDK_VERSION to 21 in the railway UI for Variables.

Now my app does no longer build, with the attached error log.

Without the variable, it works, but defaults to jdk 17.

```

[stage-0 4/6] RUN nix-env -if .nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix && nix-collect-garbage -d

"nix-env -if .nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix && nix-collect-garbage -d" did not complete successfully: exit code: 1

View in context

unpacking 'https://github.com/NixOS/nixpkgs/archive/5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.tar.gz' into the Git cache...

installing '5148520bfab61f99fd25fb9ff7bfbb50dad3c9db-env'

error:

… while calling the 'derivationStrict' builtin

at <nix/derivation-internal.nix>:34:12:

33|

34| strict = derivationStrict drvAttrs;

| ^

35|

… while evaluating derivation '5148520bfab61f99fd25fb9ff7bfbb50dad3c9db-env'

whose name attribute is located at /nix/store/lgcjj6s23v2203zyihsd0j26wh1saj0c-source/pkgs/stdenv/generic/make-derivation.nix:300:7

… while evaluating attribute 'passAsFile' of derivation '5148520bfab61f99fd25fb9ff7bfbb50dad3c9db-env'

at /nix/store/lgcjj6s23v2203zyihsd0j26wh1saj0c-source/pkgs/build-support/trivial-builders/default.nix:88:7:

87| inherit buildCommand name;

88| passAsFile = [ "buildCommand" ]

| ^

89| ++ (derivationArgs.passAsFile or []);

(stack trace truncated; use '--show-trace' to show the full, detailed trace)

error: undefined variable 'jdk21'

at /app/.nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix:19:31:

18| '')

19| (sbt.override { jre = jdk21; })

| ^

20| ];
```

3 Replies

4 months ago

Hello,

I tried reverting the Nixpacks version to the same version that was used to build your live deployment, but that didn't work.

That means the build failure wasn't due to a change in the Nixpacks version but something that you have recently pushed.

Unfortunately, since this is an issue at the application level we wouldn't be able to assist here.

Best,
Brody


Status changed to Awaiting User Response railway[bot] 4 months ago


epic-64
HOBBY

4 months ago

Hi Brody,

thanks for looking into it. There is a misunderstanding, I was not referring to the NIXPACKS_VERSION.

I pushed some new changes just now.

I deployed that new version successfully withNIXPACKS_JDK_VERSION set to 17.
Afterwards, I tried deploying again, with NIXPACKS_JDK_VERSION set to 21.

But then the build fails with this message.
```

error: undefined variable 'jdk21'

at /app/.nixpacks/nixpkgs-5148520bfab61f99fd25fb9ff7bfbb50dad3c9db.nix:19:31:

18| '')

19| (sbt.override { jre = jdk21; })
```

In the build logs of the successful deployment, you can find this line instead:
```
║ setup │ (sbt.override { jre = jdk17; }) ║

```

I would like to use Java 21 so I have access to additional flags for the garbage collector.

The only difference between the two runs was the NIXPACKS_JDK_VERSION.

According to https://nixpacks.com/docs/providers/scala, 21 is a supported value, but it looks like my nixpacks image cannot handle it


Status changed to Awaiting Railway Response railway[bot] 4 months ago


epic-64
HOBBY

3 months ago

Scala builds still fail with undefined variable 'jdk21' when setting NIXPACKS_JDK_VERSION to 21