Nix migration causes Pygame project to become unuseable

Replit projects (pygame) my students were working on yesterday (through Teams for Edu) were experiencing some issues connecting to the output window but they were working.

This morning I am getting messages of errors from students and when I checked, the replits are being “upgraded to Nix” as you open them but once it completes, the are unable to run.

Error:

ygame 2.1.2 (SDL 2.0.16, Python 3.8.12)
Hello from the pygame community. ** edited to remove link
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1894f18 addr=0x7ffde3cdc1d8 pc=0x0]

Example:
https://replit.com/@ICS3UC-03-2022/Lab08-Animation

We are seeing this on Windows 11 through Chroms.

Replit Profile: https://replit.com/@GregReid

I am also having this problem with several classes of students who are working through PyGame tasks.

Win10 on Intel i3 with Chrome and Edge browser

Example:
https://replit.com/@MortonBirkdale/PacmanChomperDemo#main.py

The conversion to the Nix environment happens automatically with no offer to confirm or skip the upgrade. After that the PyGame code is unusable.

My temp fix was to recreate the project in a fresh Pygame environment (re-upload all the starter code) and it seems to work fine. Opened that to the kids and they have have been copying their code over to the new Replit project.

Actually this is a little more problematic then I first realized - as I go back and try to mark previous submitted work, they are all trying to upgrade and crash as well. So I now have several classes worth of assignments which cannot run. To have to recreate them all will be a serious manual work.

Hopefully there will be a fix here to this migration (or an option not to do it).

1 Like

I do have a potential fix, but it takes quite a bit of effort, if you’d like to try that.

1 Like

The current workaround to this issue is to run curl https://pythonify.util.repl.co/recreate_python3_venv.sh | bash in the shell. We’re currently working on a fix.

2 Likes

Tried it and it did not work. There is a PYTHONBIN in the .nix file

~/Lab05-Create-a-Picture-UnaisKhan1$ curl https://pythonify.util.repl.co/recreate_python3_venv.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1734 100 1734 0 0 4254 0 --:–:-- --:–:-- --:–:-- 4260
PYTHONBIN not set. Please make sure it’s set in your replit.nix file and try again.

I also tried this and got a similar error to GregReid1. Opening the replit.nix file I can see that PYTHONBIN seems to be set…

PYTHONBIN = “${pkgs.python38Full}/bin/python3.8”;

A colleague has copies of the several dozen repl tasks in this unit of work and her copies are not (all?) upgrading as mine have.

Can you ensure that your replit.nix file looks like this?

replit.nix contents
{ pkgs }: {
  deps = [
    pkgs.python310Full
    pkgs.replitPackages.prybar-python310
    pkgs.replitPackages.stderred
  ];
  env = {
    PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
      # Needed for pandas / numpy
      pkgs.stdenv.cc.cc.lib
      pkgs.zlib
      # Needed for pygame
      pkgs.glib
      # Needed for matplotlib
      pkgs.xorg.libX11
    ];
    PYTHONHOME = "${pkgs.python310Full}";
    PYTHONBIN = "${pkgs.python310Full}/bin/python3.10";
    LANG = "en_US.UTF-8";
    STDERREDBIN = "${pkgs.replitPackages.stderred}/bin/stderred";
    PRYBAR_PYTHON_BIN = "${pkgs.replitPackages.prybar-python310}/bin/prybar-python310";
  };
}

Under the [env] section of the .replit file, ensure that it looks like this:

.replit > .env
[env]
VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv"
PATH = "${VIRTUAL_ENV}/bin"
PYTHONPATH = "$PYTHONHOME/lib/python3.10:${VIRTUAL_ENV}/lib/python3.10/site-packages"
REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/"
MPLBACKEND = "TkAgg"
POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry"

No those are not quite the same as what I have in the example Replit provided. However I replaced the sections indicated and the curl command provided still fails. Worse now when I attempt to run it it appears to be in a dead loop of errors.

Here are the entires in .nix and .repit ->.env before I replaced them.

{ pkgs }: {
deps = [
pkgs.python38Full
];
env = {
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath ([
# Neded for pandas / numpy
pkgs.stdenv.cc.cc.lib
pkgs.zlib
# Needed for pygame
pkgs.glib
] ++ (with pkgs.xlibs; [ libX11 libXext libXinerama libXcursor libXrandr libXi libXxf86vm ]));

PYTHONBIN = "${pkgs.python38Full}/bin/python3.8";

};
}

[env]
VIRTUAL_ENV = “/home/runner/${REPL_SLUG}/venv”
PATH = “${VIRTUAL_ENV}/bin”
PYTHONPATH=“${VIRTUAL_ENV}/lib/python3.8/site-packages”
REPLIT_POETRY_PYPI_REPOSITORY=“https://package-proxy.replit.com/pypi/

Can you send me the link to one of the Repls so I can take a look?

I have been modifying the same Replit I originally reported the problem in.

Worth noting I went through the Nix update on an older lab which I was preparing to release to my class today and that one appeared to have converted properly. Not sure if there was something different it or if you have already applied a change to newer conversions.

I was able to get the Repl working in these three steps:

  1. Deleted the __pycache__ folder
  2. Set the .replit file to this:
.replit contents
# The command that runs the program. If the interpreter field is set, it will have priority and this run command will do nothing
run = "python3 main.py"

# The primary language of the repl. There can be others, though!
language = "python3"
entrypoint = "main.py"
# A list of globs that specify which files and directories should
# be hidden in the workspace.
hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]

# Specifies which nix channel to use when building the environment.
[nix]
channel = "stable-22_11"

# The command to start the interpreter.
[interpreter]
  [interpreter.command]
  args = [
    "stderred",
    "--",
    "prybar-python310",
    "-q",
    "--ps1",
    "\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
    "-i",
  ]
  env = { LD_LIBRARY_PATH = "$PYTHON_LD_LIBRARY_PATH" }

[env]
VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv"
PATH = "${VIRTUAL_ENV}/bin"
PYTHONPATH = "$PYTHONHOME/lib/python3.10:${VIRTUAL_ENV}/lib/python3.10/site-packages"
REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/"
MPLBACKEND = "TkAgg"
POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry"

# Enable unit tests. This is only supported for a few languages.
[unitTest]
language = "python3"

# Configures the packager.
[packager]
language = "python3"
ignoredPackages = ["unit_tests"]

  [packager.features]
  enabledForHosting = false
  # Enable searching packages from the sidebar.
  packageSearch = true
  # Enable guessing what packages are needed from the code.
  guessImports = true

# These are the files that need to be preserved when this 
# language template is used as the base language template
# for Python repos imported from GitHub
[gitHubImport]
requiredFiles = [".replit", "replit.nix", ".config", "venv"]

[languages]

[languages.python3]
pattern = "**/*.py"

[languages.python3.languageServer]
start = "pylsp"

[deployment]
run = ["sh", "-c", "python3 main.py"]
  1. Ran curl https://pythonify.util.repl.co/recreate_python3_venv.sh | bash in the shell

Our DevEx engineers are currently working on fixing the issue with Python Repls.

2 Likes

Tried all the steps:

Hit run:

Stuck in an error loop:

Screenshot 2023-06-01 at 00.28.59

image
i Did the above step and getting this after run the code

This is a regular python error. Make sure flask is installed and you should be ready to go.

Please send me the link to your Repl and I’ll take a look.

You can prevent your Repl from upgrading to Nix by adding ?skipMigration=1 at the end of the Repl’s URL