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

Minecraft client no longer works on NixOS #179323

Closed
peti opened this issue Jun 27, 2022 · 40 comments · Fixed by #299645 · May be fixed by #326374
Closed

Minecraft client no longer works on NixOS #179323

peti opened this issue Jun 27, 2022 · 40 comments · Fixed by #299645 · May be fixed by #326374
Labels
0.kind: bug Something is broken

Comments

@peti
Copy link
Member

peti commented Jun 27, 2022

I used to play Minecraft on NixOS just fine, but ever since the game switched from Mojang IDs to Microsoft IDs, the Linux client no longer works. If I attempt to log in with Mojang, the software says that I am not online, which means that the server it's trying to talk to has disappeared I guess. If I attempt to log in with the Microsoft ID, it does work initially, but then the game won't start saying it experienced an unexpected crash.

error

@peti peti added the 0.kind: bug Something is broken label Jun 27, 2022
@peti
Copy link
Member Author

peti commented Jun 27, 2022

This is happening on recent versions of nixos-unstable, like f2537a5.

$ nix-info
system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix) 2.9.0, channels(root): "nixos", nixpkgs: /home/simons/src/nixpkgs

@Stunkymonkey
Copy link
Contributor

I am experiencing the same problem. I can aditionally provide some logs:

[21:37:57] [main/INFO]: Building optimized datafixer
[21:38:00] [Render thread/INFO]: [STDERR]: [LWJGL] Failed to load a library. Possible solutions:
	a) Add the directory that contains the shared library to -Djava.library.path or -Dorg.lwjgl.librarypath.
	b) Add the JAR that contains the shared library to the classpath.
[21:38:00] [Render thread/INFO]: [STDERR]: [LWJGL] Enable debug mode with -Dorg.lwjgl.util.Debug=true for better diagnostics.
[21:38:00] [Render thread/INFO]: [STDERR]: [LWJGL] Enable the SharedLibraryLoader debug mode with -Dorg.lwjgl.util.DebugLoader=true for better diagnostics.
[21:38:01] [Render thread/INFO]: [STDERR]: java.lang.NoClassDefFoundError: Could not initialize class com.mojang.blaze3d.systems.RenderSystem
[21:38:01] [Render thread/INFO]: [STDERR]: 	at ac.a(SourceFile:65)
[21:38:01] [Render thread/INFO]: [STDERR]: 	at eev.a(SourceFile:2306)
[21:38:01] [Render thread/INFO]: [STDERR]: 	at eev.a(SourceFile:2301)
[21:38:01] [Render thread/INFO]: [STDERR]: 	at net.minecraft.client.main.Main.main(SourceFile:207)

@Stunkymonkey
Copy link
Contributor

might be related to the launcher, because it was not updated since 2021-01-27

@peeley
Copy link
Contributor

peeley commented Jul 12, 2022

I've experienced the same, and I believe it might be a launcher issue as well. From what I understand, the Minecraft launcher is responsible for pre-fetching Java libraries (which makes sense, given the error message posted by @Stunkymonkey ). Unfortunately, it looks like the version of the launcher within the derivation is the most recent that can be fetched with a reproducible build.

In pkgs/games/minecraft/default.nix, the format for fetching the launcher is "https://launcher.mojang.com/download/linux/x86_64/minecraft-launcher_${version}.tar.gz" with version = 2.1.1441. Here is a link to the Minecraft wiki pages listing all launcher versions, with the most recent as of writing being 2.3.280. For some odd reason, it looks like https://launcher.mojang.com/download/linux/x86_64/minecraft-launcher_2.2.1441.tar.gz is valid but https://launcher.mojang.com/download/linux/x86_64/minecraft-launcher_2.3.280.tar.gz 404's.

The actual Minecraft launcher download page for Linux just uses the URL https://launcher.mojang.com/download/Minecraft.tar.gz to download the most recent version. This unfortunately doesn't have a version tag, so it's not possible to reproduce builds with that download link.

When the client is run, there's a popup about updating the client with a clickable link (see img)
Screenshot_2022-07-11_18-57-38
...which could be useful if it manually downloads the libraries instead. Unfortunately, when I click the link I see the following error in the logs:

sh: line 1: /usr/bin/xdg-open: No such file or directory

So, it looks like a patch might be necessary regardless. I've tried greping through the launcher .tar.gz archives and binaries but I've yet to find where/how xdg-open is being called. Not sure where to go from there.

@maxdeviant
Copy link

In the past it looks like we've referred to Flatpak for how they download the launcher: #107046.

I was looking at Flatpak again and in flathub/com.mojang.Minecraft#126 they switch to a different version train (?) of the launcher.

I'm not totally sure what launcher this is, but it coincides with the launcher-bootstrap entry in the launcher metadata:

curl -s 'https://launchermeta.mojang.com/v1/products/launcher/6f083b80d5e6fabbc4236f81d0d8f8a350c665a9/linux.json' | jq
{
  "jre-x64": [],
  "jre-x86": [],
  "launcher-bootstrap": [
    {
      "availability": {
        "group": 2631,
        "progress": 100
      },
      "manifest": {
        "sha1": "b233e56e61f74c8aa69e377fb348dc4643da8b36",
        "size": 460,
        "url": "https://launchermeta.mojang.com/v1/packages/b233e56e61f74c8aa69e377fb348dc4643da8b36/manifest.json"
      },
      "version": {
        "name": "1.0.1221",
        "released": "2022-03-23T23:03:04+00:00"
      }
    }
  ],

I'm able to actually download an archive by updating default.nix with the following:

version = "1.0.1221";

src = fetchurl {
  url = "https://launcher.mojang.com/download/linux/x86_64/minecraft-launcher_${version}.tar.gz";
  sha256 = "cd9f0b44fc9cec42829cb2e71145ee599f3d34c7715b55963514d0a8d36214ab";
};

However, once I do so I'm running into issues with patchelf, specifically:

patchelf: getting info about '/nix/store/xy45mmi9kkvhaqfgip9x0dsffbqz2mvk-minecraft-launcher-1.0.1221/opt/minecraft-launcher/libcef.so': No such file or directory

@maxdeviant
Copy link

maxdeviant commented Jul 12, 2022

I was looking at Flatpak again and in flathub/com.mojang.Minecraft#126 they switch to a different version train (?) of the launcher.

I'm not totally sure what launcher this is, but it coincides with the launcher-bootstrap entry in the launcher metadata:

I think this might just be the launcher bootstrapper (which would download the launcher), so probably not what we want, since it won't be reproducible.

@maxdeviant
Copy link

Still no luck trying to figure out the .tar.gz download for 2.2.12148.

I ended up booting up Ubuntu in a VM and running the Minecraft launcher bootstrapper while sniffing the traffic with Wireshark to see what it's pulling.

I'm still sorting through the packets, but I did find this URL that looked interesting:

https://launcher.mojang.com/v1/objects/f533ed14b767037315fde231ffa217f232a72615/minecraft-launcher

If you download it you get an LZMA compressed file:

λ file minecraft-launcher
minecraft-launcher: LZMA compressed data, streamed

@maxdeviant
Copy link

When the client is run, there's a popup about updating the client with a clickable link (see img)

I downloaded version 2.2.1441 of the Minecraft launcher on my Ubuntu VM and clicked the link in the popup.

It takes you to https://aka.ms/MinecraftLauncher which then redirects to https://www.minecraft.net/en-us/download to download Minecraft.

@maxdeviant
Copy link

One thing I did notice during this process is that the contents of the archive file downloaded from https://launcher.mojang.com/download/linux/x86_64/minecraft-launcher_2.2.1441.tar.gz:

$ tree minecraft-launcher
minecraft-launcher
├── cef_100_percent.pak
├── cef_200_percent.pak
├── cef_extensions.pak
├── cef.pak
├── chrome-sandbox
├── icudtl.dat
├── libcef.so
├── libgconf-2.so.4
├── liblauncher.so
├── locales
│   ├── am.pak
│   ├── ar.pak
│   ├── bg.pak
│   ├── bn.pak
│   ├── ca.pak
│   ├── cs.pak
│   ├── da.pak
│   ├── de.pak
│   ├── el.pak
│   ├── en-GB.pak
│   ├── en-US.pak
│   ├── es-419.pak
│   ├── es.pak
│   ├── et.pak
│   ├── fa.pak
│   ├── fil.pak
│   ├── fi.pak
│   ├── fr.pak
│   ├── gu.pak
│   ├── he.pak
│   ├── hi.pak
│   ├── hr.pak
│   ├── hu.pak
│   ├── id.pak
│   ├── it.pak
│   ├── ja.pak
│   ├── kn.pak
│   ├── ko.pak
│   ├── lt.pak
│   ├── lv.pak
│   ├── ml.pak
│   ├── mr.pak
│   ├── ms.pak
│   ├── nb.pak
│   ├── nl.pak
│   ├── pl.pak
│   ├── pt-BR.pak
│   ├── pt-PT.pak
│   ├── ro.pak
│   ├── ru.pak
│   ├── sk.pak
│   ├── sl.pak
│   ├── sr.pak
│   ├── sv.pak
│   ├── sw.pak
│   ├── ta.pak
│   ├── te.pak
│   ├── th.pak
│   ├── tr.pak
│   ├── uk.pak
│   ├── vi.pak
│   ├── zh-CN.pak
│   └── zh-TW.pak
├── minecraft-launcher
├── natives_blob.bin
├── snapshot_blob.bin
└── v8_context_snapshot.bin
 
1 directory, 66 files

Are very similar to the contents of the manifest for launcher-core-v2's manifest.json: https://gist.github.com/maxdeviant/962b8b0af9ab8b456237523bbb9cb40d

I suspect downloading each of these files from the manifest and putting them into a directory would be the equivalent of downloading and extracting a tar archive for the launcher version (albeit more annoying to do).

@maxdeviant
Copy link

I'm still trying to piece together what the different launcher versions are, but here's the relevant entries from https://launchermeta.mojang.com/v1/products/launcher/6f083b80d5e6fabbc4236f81d0d8f8a350c665a9/linux.json:

  "launcher-core-ado": [
    {
      "availability": {
        "group": 6499,
        "progress": 100
      },
      "manifest": {
        "sha1": "775504f590a53c88f8636d796e0ebfaf42caf9db",
        "size": 30807,
        "url": "https://piston-meta.mojang.com/v1/packages/775504f590a53c88f8636d796e0ebfaf42caf9db/manifest.json"
      },
      "version": {
        "name": "2.3.280",
        "released": "2022-06-30T20:49:19+00:00"
      }
    }
  ],
  "launcher-core-v2": [
    {
      "availability": {
        "group": 4022,
        "progress": 100
      },
      "manifest": {
        "sha1": "688bc2598db8ce144841701ad2b0b11a1bf8035f",
        "size": 29102,
        "url": "https://launchermeta.mojang.com/v1/packages/688bc2598db8ce144841701ad2b0b11a1bf8035f/manifest.json"
      },
      "version": {
        "name": "2.2.12148",
        "released": "2022-03-24T03:13:44+00:00"
      }
    }
  ],

The version listed under launcher-core-ado, 2.3.280, is aligned with the most recent launcher version listed on the Minecraft wiki:

image

@maxdeviant
Copy link

For anyone else who's stuck on this and just wants to play Minecraft (as opposed to fixing the broken minecraft package), I switched to PolyMC and it works with no issues.

@sshilovsky
Copy link
Contributor

I only have this problem when launching 1.19. Earlier versions work fine.

nixos-22.05

peeley added a commit to peeley/dotfiles that referenced this issue Jul 22, 2022
Unfortunately Minecraft is currently broken in nixpkgs :'(
NixOS/nixpkgs#179323
@schuelermine
Copy link
Contributor

I have this problem too

@plredmond
Copy link

plredmond commented Aug 11, 2022

I wrote a script to download the launcher and assemble the tar.gz. It successfully starts the new launcher, it doesn't pop up a "game crashed" error, but it fails to launch an the opengl window w/mojang logo.

Commits are here: 3a11db5...plredmond:nixpkgs:92e8b4bcdee4896470c319bbda472d441df265a9

To reproduce, you run download.py inside a local checkout of nixpkgs and then install minecraft from the local checkout of nixpkgs. That said, this doesn't succeed in launching the game, it just gets past the LWJGL/Game Crashed! bug.

@ncfavier
Copy link
Member

Maybe we should at least ask Mojang if the new versions are available at another URL and if not, if they could restore that feature?

@schokotets
Copy link

I was able to get the new minecraft client to run.

These are the steps I took:

  1. Launched the bootstrapper from
  2. zipped up the files in ~/.minecraft/launcher
  3. used them as a replacement for the .tar.gz archive in the default.nix file.
  4. run nix-build with my modified default.nix [1]

Here, I tried to run the bin/minecraft-launcher wrapper script, yet the started application tried to update the game, because of the following: "Current executable is not in game directory, update and run game directory version".

My workaround was to copy the files in $out/opt/minecraft-launcher to the ~/.minecraft/launcher directory and wrap the executable there, as follows:

  1. rm ~/.minecraft/treatment_tags.json (this is needed every time I run the game — else it tries to update the client again)
  2. rm -rf ~/.minecraft/launcher
  3. cp -r $out/opt/minecraft-launcher/ ~/.minecraft/launcher
  4. use makeWrapper to wrap ~/.minecraft/launcher/minecraft-launcher in e.g. minecraft-launcher-wrapper
  5. launch minecraft-launcher-wrapper
  6. log in to mojang/microsoft account
  7. edit the game profile to change the java version to /nix/store/5grvkxkdn1wa8qzrli5nv3bbl54nk10s-openjdk-17.0.3+7/bin/java (from jdk17_headless
  8. launch the game

I'm aware that this is a somewhat hacky solution, yet as I'm unexperienced in nix packaging, I hope someone else can take the info and update the package accordingly. Would be much appreciated :)

1:

let pkgs = import <nixpkgs> {};
in pkgs.callPackage (
{ lib, stdenv
, at-spi2-core
, at-spi2-atk
, libsecret
, libdrm
, mesa
, fetchurl
, nixosTests
, copyDesktopItems
, makeDesktopItem
, makeWrapper
, wrapGAppsHook
, gobject-introspection
, jre # old or modded versions of the game may require Java 8 (https://aur.archlinux.org/packages/minecraft-launcher/#pinned-674960)
, xorg
, zlib
, nss
, nspr
, fontconfig
, pango
, cairo
, expat
, alsa-lib
, cups
, dbus
, atk
, gtk3-x11
, gtk2-x11
, gdk-pixbuf
, glib
, curl
, freetype
, libpulseaudio
, libuuid
, systemd
, flite ? null
, libXxf86vm ? null
}:
let
  desktopItem = makeDesktopItem {
    name = "minecraft-launcher";
    exec = "minecraft-launcher";
    icon = "minecraft-launcher";
    comment = "Official launcher for Minecraft, a sandbox-building game";
    desktopName = "Minecraft Launcher";
    categories = [ "Game" ];
  };

  envLibPath = lib.makeLibraryPath [
    curl
    libpulseaudio
    systemd
    alsa-lib # needed for narrator
    flite # needed for narrator
    libXxf86vm # needed only for versions <1.13
  ];

  libPath = lib.makeLibraryPath ([
    alsa-lib
    at-spi2-core
    at-spi2-atk
    atk
    cairo
    cups
    curl
    dbus
    expat
    fontconfig
    freetype
    gdk-pixbuf
    glib
    libsecret
    libdrm
    mesa
    pango
    gtk3-x11
    gtk2-x11
    nspr
    nss
    stdenv.cc.cc
    zlib
    libuuid
  ] ++
  (with xorg; [
    libX11
    libxcb
    libXcomposite
    libXcursor
    libXdamage
    libXext
    libXfixes
    libXi
    libXrandr
    libXrender
    libXtst
    libXScrnSaver
  ]));
in
stdenv.mkDerivation rec {
  pname = "minecraft-launcher";

  version = "2.2.1441-2";

  src = fetchurl {
    url = "http://localhost:8000/minecraft-launcher.tar.gz";
    sha256 = "27e1d10333b4ff5aabef04fe0c61d53368db5e699f3d80621b9c4b55c5d4d465";
  };

  icon = fetchurl {
    url = "https://launcher.mojang.com/download/minecraft-launcher.svg";
    sha256 = "0w8z21ml79kblv20wh5lz037g130pxkgs8ll9s3bi94zn2pbrhim";
  };

  nativeBuildInputs = [ makeWrapper wrapGAppsHook copyDesktopItems ];
  buildInputs = [ gobject-introspection ];

  sourceRoot = ".";

  dontWrapGApps = true;
  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out/opt
    mv minecraft-launcher $out/opt

    install -D $icon $out/share/icons/hicolor/symbolic/apps/minecraft-launcher.svg

    runHook postInstall
  '';

  preFixup = ''
    patchelf \
      --set-interpreter ${stdenv.cc.bintools.dynamicLinker} \
      --set-rpath '$ORIGIN/'":${libPath}" \
      $out/opt/minecraft-launcher/chrome-sandbox
    patchelf \
      --set-interpreter ${stdenv.cc.bintools.dynamicLinker} \
      --set-rpath '$ORIGIN/'":${libPath}" \
      $out/opt/minecraft-launcher/minecraft-launcher
    patchelf \
      --set-rpath '$ORIGIN/'":${libPath}" \
      $out/opt/minecraft-launcher/libcef.so
    patchelf \
      --set-rpath '$ORIGIN/'":${libPath}" \
      $out/opt/minecraft-launcher/liblauncher.so
  '';

  postFixup = ''
    # Do not create `GPUCache` in current directory
    makeWrapper $out/opt/minecraft-launcher/minecraft-launcher $out/bin/minecraft-launcher \
      --prefix LD_LIBRARY_PATH : ${envLibPath} \
      --prefix PATH : ${lib.makeBinPath [ jre ]} \
      --set JAVA_HOME ${lib.getBin jre} \
      --chdir /tmp \
      "''${gappsWrapperArgs[@]}"
  '';

  desktopItems = [ desktopItem ];

  meta = with lib; {
    description = "Official launcher for Minecraft, a sandbox-building game";
    homepage = "https://minecraft.net";
    maintainers = with maintainers; [ cpages ryantm infinisil ];
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    license = licenses.unfree;
    platforms = [ "x86_64-linux" ];
  };

  passthru = {
    tests = { inherit (nixosTests) minecraft; };
    updateScript = ./update.sh;
  };
}) {}

@peeley
Copy link
Contributor

peeley commented Nov 2, 2022

For anyone else who's stuck on this and just wants to play Minecraft (as opposed to fixing the broken minecraft package), I switched to PolyMC and it works with no issues.

To anyone else who has followed the above advice, beware the following (got this when updating):

error: PolyMC has been removed from nixpkgs due to a hostile takeover by a rogue maintainer. The rest of the maintainers have made a fork which is packaged as 'prismlauncher'

see more on #196480 (comment).

@SergioQuijanoRey

This comment was marked as duplicate.

@GetPsyched
Copy link
Member

Has there been any updates on this issue? I got here after facing the same issue on nixos-unstable.

@SergioQuijanoRey
Copy link

I don't think so, but I am actually using PrismLauncher with any problems

@GetPsyched
Copy link
Member

RIP, I hoped I could stick to the official launcher.

@SergioQuijanoRey
Copy link

I think you should be able to download the official .jar and run it using openjdk. It's not ideal but it may work if you really want to stick to the official launcher

@GetPsyched
Copy link
Member

Nah, I'd rather have simple setup than sticking to the official. Thanks anyways.

@rowan-sl
Copy link

Nah, I'd rather have simple setup than sticking to the official. Thanks anyways.

This is a good choice, that i could not make, unfortunateally (for accounts of age <18, you cannot use 3rd party launchers)

For anyone who does want to go down this path, here are the steps (because oh my god did this suck to figure out).

Dependencies:

  • libsecret: required, not on NixOS by default (this and flite might not work if installed using nix-shell!)
  • flite: might not be required (dependency of narrator)
  • jdk17: required, can use nix-shell
  • steam-run: required, can use nix-shell
  • rustc (build process only!)

Installing the Launcher

Download the official launcher (use the other linux button)

  • extract the downloaded .zip
  • now, enter a FHS env bash shell using steam-run bash (this emulates the normal linux directories that the launcher expects to be there, like /bin/). at this point all dependencies (except rustc) must be installed!
  • once there, run the minecraft-launcher executable, making sure to first set the env var LD_LIBRARY_PATH (see below) (may have to chmod)

Now, to launch the launcher you can run the following command (with steam-run bash/steam-run)

LD_LIBRARY_PATH=/home/<your-username>/.nix-profile/lib:/nix/var/nix/profiles/system/sw/lib ~/.minecraft/launcher/minecraft-launcher

You are now done! (but not if you use fabric (mod loader), or an nvidia optimus laptop...)

Configuring NVIDIA dGPU for optimus laptops (if you dont know what that means, you probably do not have one)

This is where rustc is needed.

First, copy the following rust code to a file named java.rs and compile it with rustc -C opt-level=3 java.rs (this will create some build artifacts that can be removed)

use std::{env, process::Command, os::unix::process::CommandExt};

fn main() {
    Command::new("java")
        .env("__NV_PRIME_RENDER_OFFLOAD", "1")
        .env("__NV_PRIME_RENDER_OFFLOAD_PROVIDER", "NVIDIA-G0")
        .env("__GLX_VENDOR_LIBRARY_NAME", "nvidia")
        .env("__VK_LAYER_NV_optimus", "NVIDIA_only")
        .args(env::args().skip(1))
        .exec();
}

Then, place the produced executable java somewhere 🤷 and edit your minecraft profile in the launcher to use a custom java executable, that being the java program that you just created. (this also works with modded version)

But why rust? isn't bash good?

WRONG.

Attempting to use a bash script to replicate the function of the rust program will not work. If you do try this, or like me tried it thinking it was the correct way, minecraft will launch, and it will use the dedicated GPU, however fabric, and any mods for it will not be loaded AT ALL. no error messages, no logs, nothing.

Notes:

This is not a great way of doing things (having to run multiple commands in the shell every time you want to start the launcher is the big reason, though i might try and improve this in the future), and if anyone wants to upstream a better version of this that would be great

Also, if the current minecraft-launcher package is this broken, it seems like a good idea to add some sort of warning to it so that people know not to use it?

@schuelermine
Copy link
Contributor

Attempting to use a bash script to replicate the function of the rust program will not work. If you do try this, or like me tried it thinking it was the correct way, minecraft will launch, and it will use the dedicated GPU, however fabric, and any mods for it will not be loaded AT ALL. no error messages, no logs, nothing.

This seems odd, any idea why? What about launching via something like switcherooctl?

@rowan-sl
Copy link

Attempting to use a bash script to replicate the function of the rust program will not work. If you do try this, or like me tried it thinking it was the correct way, minecraft will launch, and it will use the dedicated GPU, however fabric, and any mods for it will not be loaded AT ALL. no error messages, no logs, nothing.

This seems odd, any idea why? What about launching via something like switcherooctl?

absolutely no idea. the issue with something like switcherooctl is that you would need a bash script or other program to launch it anyway, since the minecraft launch command must be only an executable, no shell arguments or anything (which i assume would cause the same issue, although i have not checked this).

notes:

  • I'm assuming that something that bash does / running an interpreted script must somehow affect how minecraft runs (no clue why). this still does not explain how the failure mode of this is to launch vanilla minecraft instead of just crashing like a normal program
  • it appears that using .exec() is not necessary (in the env var setting script), .spawn() also works fine

@GetPsyched
Copy link
Member

Thanks for the detailed walk-through, @rowan-sl.

Also, if the current minecraft-launcher package is this broken, it seems like a good idea to add some sort of warning to it so that people know not to use it?

Can you test if this package works on other platforms? If it does, then it's probably just broken on Linux; Depending on this, either badPlatforms or broken attribute can be set.

@rowan-sl
Copy link

Thanks for the detailed walk-through, @rowan-sl.

You're welcome!

Can you test if this package works on other platforms? If it does, then it's probably just broken on Linux; Depending on this, either badPlatforms or broken attribute can be set.

I'm not set up to test on anything other than my current system unfortunateally (which if it matters is NixOS 23.11 unstable, nvidia optimus laptop with an AMD Ryzen 7 cpu and NVIDIA 1650 Ti Mobile) (also this might actually be a NixOS spacific problem?)

I think the package probably should be marked out of date (or equivilant) untill the version of the launcher in the package can be updated to the latest version, since in its current state it just crashes when launching the game. (also to me it looks like the only blocking issue here is the requirement of nixpkgs to have reliable builds, and not any technical issue (can someone clarify?))

The information/problems listed here will mostly be usefull after the version is updated, or for people doing it manually, and i think is the lesser problem here, since it only applies to using nvidia optimus with modded minecraft spacifically (either of the two on their own, or vanilla works just fine)

If anyone would like to do more detailed testing and needs more details from me, or if anyone is trying to do the fix and it is failing, please ask me!

@GetPsyched
Copy link
Member

I think the package probably should be marked out of date (or equivilant) untill the version of the launcher in the package can be updated to the latest version, since in its current state it just crashes when launching the game.

I'll try an updated version of this on my local system, if it works I'll send a PR to update the same. (I doubt the fix would be as easy as this as is evident from earlier comments in this issue). Besides, there are 2 things you can mark in a package for this scenario: broken or badPlatforms.

(also to me it looks like the only blocking issue here is the requirement of nixpkgs to have reliable builds, and not any technical issue (can someone clarify?))

Untrue, to the best of my knowledge; the requirement also includes basic functionality of the build working correctly (as is evident from this PR template checkbox requirement.

@rowan-sl
Copy link

(also to me it looks like the only blocking issue here is the requirement of nixpkgs to have reliable builds, and not any technical issue (can someone clarify?))

Untrue, to the best of my knowledge; the requirement also includes basic functionality of the build working correctly (as is evident from this PR template checkbox requirement.

Sorry, I had meant that the reason no one had fixed the problem of the launcher crashing [because of an outdated launcher] was that mojang does not offer a way to download specific versions of the more recent launcher builds. (unless this was not what you meant, in which case ignore what i just said)

Either way, thank you for looking into this more on the nixpkgs side of things

@freekvh
Copy link

freekvh commented Jun 25, 2023

I'm new to Nix(OS), but I was wondering, has anybody tried simply writing a configuration snippet that loads an Ubuntu or Arch container in the background and simply runs Minecraft Launcher from there?

@freekvh
Copy link

freekvh commented Jun 25, 2023

For anyone else who's stuck on this and just wants to play Minecraft (as opposed to fixing the broken minecraft package), I switched to PolyMC and it works with no issues.

I got this: error: PolyMC has been removed from nixpkgs due to a hostile takeover by a rogue maintainer. The rest of the maintainers have made a fork which is packaged as 'prismlauncher'

prismlauncher works perfectly for me though! Thanx for the suggestion!

@MilkyWayboi
Copy link

MilkyWayboi commented Jun 27, 2023

Alr so i turned on logs for Java Edition

and Here are The Results:

Vanilla: ```12:02:08.002
[STDERR]: at enn.a(SourceFile:2424)
12:02:08.002
[STDERR]: at enn.a(SourceFile:2419)
12:02:08.002
[STDERR]: at net.minecraft.client.main.Main.main(SourceFile:220)
12:02:08.002
[STDERR]: Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: Failed to locate library: liblwjgl.so [in thread "Render thread"]
12:02:08.003
[STDERR]: at org.lwjgl.system.Library.loadSystem(Library.java:164)
12:02:08.003
[STDERR]: at org.lwjgl.system.Library.loadSystem(Library.java:63)
12:02:08.003
[STDERR]: at org.lwjgl.system.Library.(Library.java:51)
12:02:08.003
[STDERR]: at org.lwjgl.system.MemoryUtil.(MemoryUtil.java:100)
12:02:08.003
[STDERR]: at ehh.(SourceFile:8)
12:02:08.003
[STDERR]: at eie.(SourceFile:48)
12:02:08.003
[STDERR]: at eil.(SourceFile:19)
12:02:08.003
[STDERR]: at eil.(SourceFile:23)
12:02:08.003
[STDERR]: at eil.(SourceFile:11)
12:02:08.003
[STDERR]: at com.mojang.blaze3d.systems.RenderSystem.(SourceFile:50)
12:02:08.003
[STDERR]: at net.minecraft.client.main.Main.main(SourceFile:208)
12:02:08.063

12:02:08.063
Process crashed with exit code 1```

Fabric: 12:31:02.409 Preparing to launch minecraft client for fabric-loader-0.14.21-1.20.1 12:31:05.204 Checking installations. 12:31:05.208 Minecraft client fabric-loader-0.14.21-1.20.1 is ready to start. 12:31:05.208 Starting! 12:31:05.209 Using default game log configuration client-1.12.xml (outputs XML) 12:31:06.663 Class path entries reference missing files: /home/ion/.minecraft/libraries/io/netty/netty-transport-native-epoll/4.1.82.Final, linux-aarch_64/netty-transport-native-epoll-4.1.82.Final, linux-aarch_64.jar, /home/ion/.minecraft/libraries/io/netty/netty-transport-native-epoll/4.1.82.Final, linux-x86_64/netty-transport-native-epoll-4.1.82.Final, linux-x86_64.jar, natives-linux/lwjgl-glfw-3.3.1, natives-linux.jar, natives-linux/lwjgl-jemalloc-3.3.1, natives-linux.jar, natives-linux/lwjgl-openal-3.3.1, natives-linux.jar, natives-linux/lwjgl-opengl-3.3.1, natives-linux.jar, natives-linux/lwjgl-stb-3.3.1, natives-linux.jar, natives-linux/lwjgl-tinyfd-3.3.1, natives-linux.jar, natives-linux/lwjgl-3.3.1, natives-linux.jar - the game may not load properly! 12:31:06.665 Loading Minecraft 1.20.1 with Fabric Loader 0.14.21 12:31:06.808 Loading 3 mods: - fabricloader 0.14.21 - java 19 - minecraft 1.20.1 12:31:06.839 SpongePowered MIXIN Subsystem Version=0.8.5 Source=file:/home/ion/.minecraft/libraries/net/fabricmc/sponge-mixin/0.12.5+mixin.0.8.5/sponge-mixin-0.12.5+mixin.0.8.5.jar Service=Knot/Fabric Env=CLIENT 12:31:10.501 188 Datafixer optimizations took 109 milliseconds

not sure if this helps but i thought it was a good idea yo put this in

@MilkyWayboi
Copy link

MilkyWayboi commented Jun 27, 2023

Alr i found a solution for myself, use prismlauncher

See if this helps

@GetPsyched
Copy link
Member

Hey, @cpages @ryantm @infinisil. Could you please look into this thread and potentially add a broken tag to this package until it's fixed? (if it applies)

@TLATER
Copy link
Contributor

TLATER commented Sep 20, 2023

Someone pinged me asking for help with this, and I got curious about the actual root cause. Seems nobody has figured it out yet, so I went sleuthing.

tl;dr: Minecraft versions 1.19 and up are broken with the official launcher because it now tries to download natively compiled, non-Java libraries to execute. This complicates things. As a workaround, use PrismLauncher (and use it anyway since it's open source, ad-free, community maintained, and has useful features to boot).

As far as I can tell, the issue is a change in lwjgl, or how it is used. From what I can tell, prior to version 1.19 of the game, the Minecraft launcher would start it with lwjgl 3.2.2. It lists these lwjgl-related libraries in the classpath:

  • lwjgl-3.2.2.jar
  • lwjgl-jemalloc-3.2.2.jar
  • lwjgl-openal-3.2.2.jar
  • lwjgl-opengl-3.2.2.jar
  • lwjgl-glfw-3.2.2.jar
  • lwjgl-stb-3.2.2.jar
  • lwjgl-tinyfd-3.2.2.jar

None of them contain an lwjgl.so, only checksums that refer to such a library. 1.18 and earlier will launch just fine, irrespective of whether the launcher was updated or not.

Since Minecraft version 1.19, it instead has all these libraries:

  • lwjgl-glfw-3.3.1.jar
  • lwjgl-glfw-3.3.1:natives-linux.jar
  • lwjgl-jemalloc-3.3.1.jar
  • lwjgl-jemalloc-3.3.1:natives-linux.jar
  • lwjgl-openal-3.3.1.jar
  • lwjgl-openal-3.3.1:natives-linux.jar
  • lwjgl-opengl-3.3.1.jar
  • lwjgl-opengl-3.3.1:natives-linux.jar
  • lwjgl-stb-3.3.1.jar
  • lwjgl-stb-3.3.1:natives-linux.jar
  • lwjgl-tinyfd-3.3.1.jar
  • lwjgl-tinyfd-3.3.1:natives-linux.jar
  • lwjgl-3.3.1.jar
  • lwjgl-3.3.1:natives-linux.jar

The natives-linux part may already look concerning to anyone familiar with the pains of using precompiled native things on NixOS, and indeed, there is an lwjgl.so hidden in lwjgl-3.3.1:natives-linux.jar.

From some sleuthing, it looks like lwjgl has always had the option of using native components. It just looks like Microsoft recently flipped over to actually using them. Previously it was instead using the pure java implementation, which naturally had no issues with NixOS.

The good news is that PrismLaucher also uses lwjgl-3.3.1, and it also uses the native components as far as I can tell, but works in spite of this, so there's no issue with loading the shared library. This means it can probably be fixed without having to do something horrible like patching things at runtime.

The difference is that, since PrismLauncher is compiled natively instead of being a repackaged binary package, it does not modify LD_LIBRARY_PATH. My guess is that LD_LIBRARY_PATH messes with whatever magic lwjgl/java uses to load its native components from a specific path, and as a result the shared library cannot be found when using the nix package.

Hence, the nix package is broken (for Minecraft versions 1.19 and up). I think it should be marked as such, I'll send up a PR.

I'm unsure why the previously detailed workarounds work. My guess is that somewhere hidden in them there is an env clear that applies only to the launched java instance that gets rid of the packages' LD_LIBRARY_PATH.

@TLATER
Copy link
Contributor

TLATER commented Sep 20, 2023

I think it should be marked as such, I'll send up a PR.

Hm, scratch that, I'm not sure. The package still partially works, it's just broken for any Minecraft version younger than 1.19. Is this sufficiently broken to mark it broken?

@sudoforge
Copy link
Contributor

@TLATER thanks for your work in debugging this. I was recently setting up machines for young people to play Minecraft, and encountered the joys of the official launcher crashing.

Is this sufficiently broken to mark it broken?

I'd say so. This has been ongoing for ~18 months, give or take (in addition to however long it was occurring prior to this issue being opened). It was a fairly frustrating experience, and I found this issue only after I had decided to use prismlauncher. I'm happy enough with the decision, but it still seems like we need to either figure out how to fix this, or remove the minecraft-launcher package.

@tomberek
Copy link
Contributor

Also just helped people with this... ran into the same problem regarding new versions failing in a way hard for people to debug themselves. I'm leaning toward marking the minecraft client as broken. (if people explicitly need old versions, they likely need a launcher anyway, or can figure out how to un-broken it). Or at least a warning.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/minecraft-wont-start/55683/9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet