Shell/LS freezes when you read /nix/store

Problem description:
If you go into a Repl (afaik any template will work) and type ls -lath /nix/store in the Shell, it freezes.
EDIT: not only ls freezes, but any operation that reads from /nix/store freezes. Launching pcmanfm and opening the folder causes it to freeze, opening file:///nix/store in Fierfox causes it to freeze, and also vifm.

Expected behavior:
The expected behavior is that the contents of the folder are listed.

Actual behavior:
The ls command freezes and does not show any output.

Steps to reproduce:

  1. Go into the shell
  2. Write ls /nix/store
  3. Press enter

Bug appears at this link:
Any Repl with a Shell will work.

Chrome 108.0.5359.98 (Official Build) (x86_64) , macOS, Replit version 05510a0.

it takes up too much RAM. Why would you need to read /nix/store directly anyhow?


Just realized this was kinda like an XY problem, sorry.

I installed xterm and it works fine, but if I run a command that is not installed, it just says command not found.

I wanted to launch xterm with the same shell that Replit uses in the shell tab, so I did echo $0 and it shows that the shell is stored in /nix/store/8kgsjv57icc18qhpmj588g9x1w34hi4j-bash-interactive-5.1-p12/bin/bash. But I assume that the path changes every now and then, so I wanted to see the contents of the folder to try to auto-detect and find the Nix shell.

So the actual question is: how can I run an xterm session with a Nix shell?

1 Like

Short answer: “don’t”

Longer answer: reading all the files in that directory consumes way too many resources. it’s better to interact with the nix packages using nix’ tools to efficiently inspect the installed packages.

(a similar problem can be exhibited locally by creating a directory with, literally, millions of files. some commandline tools will freeze and/or crash, which makes things like running rm -rf * impossible: you’ll need to craft a special program that does things more cleverly)

1 Like

So how can I run the Nix shell in a graphic terminal like xterm?

Just get your program to run echo $0 if that’s how you found it

That only shows the Nix shell if you run it in the Nix shell in the Replit editor.

So I can only find it if I’m in it…

The nix magic is added in with the argument -rcfile /nix/store/fayv2rwr7z7lrw65s7ilwhcvn8jih9iz-replit-bashrc/bashrc, not with a specific shell.
Notice how that bashrc itself includes hardcoded paths, so there mustn’t be a problem with the paths for nix packages changing.

1 Like

You sure they won’t change? The path seems pretty random to me.

if they do change then the shell tab would eventually stop working because the paths in the bashrc file would get outdated

Ok so I was right, the file paths change. And so does the RC file, it updates automatically. So is there a way to always find the correct Nix shell RC files?