How to change .replit run so it runs a file from another repl?

So basically I want the .replit run to execute a file from another repl. How could I do that?

So basically I want something like this:

run = "python https://replit.com/@SnakeyKing/repl#main.py"
2 Likes

Not really sure, but that would be a really cool idea! for rickrolls

2 Likes

At the moment, this is not possible.

You can expose a shell file from a webserver and execute that, but you can’t run a file in another Repl.

6 Likes

So basically like make a html/css/js project thing and have a random python file that you can access from the web?

hmm let me try that

So I made a repl and you can access main.py like this:

https://pytest.doxr.repl.co/main.py

and I got this on a different repl

python3 https://pytest.doxr.repl.co/main.py
/home/runner/randomproj/venv/bin/python3: can’t open file ‘/home/runner/randomproj/https://pytest.doxr.repl.co/main.py’: [Errno 2] No such file or directory

I tried it with bash too (did it in shell) and it didn’t work

I probably did it wrong because both think that the link is a directory so idk

It could be a feature request

1 Like

I’m gonna change this topic into a feature request


Wait… Can’t we just do:

run = "/home/runner/another-repl/main.py"

or

run = "../home/runner/another-repl/main.py"

???

No, unfortunately, I discovered that each Repl has it’s own file system, and even though the home directory is always in /home/runner, they are never in the same Repl. In other words, each Repl’s directories are entirely different. If they weren’t, we wouldn’t need a replit.nix config, since /nix/store would be synced as well (which it clearly isn’t, since we need to install Nix packages for every Repl)

5 Likes

@doxr Yes, you did do it wrong.

Here’s how you do it:

  1. Create a Python Repl.
  2. In main.py, write:
from requests import get
from os import system

r = get("https://pytest.doxr.repl.co/main.py")

r.raise_for_status()

r = r.text

system("touch file.py")

with open("file.py") as file:
  file.write(r)

system("python3 file.py")

(Note: It is advisable to keep pytest.doxr.repl.co always on for this.)

5 Likes

I did the exact same thing, but instead of buying always-on I just shoved my scripts into a GitHub repository, and accessed it through a URL like https://raw.githubusercontent.com/[user]/[repo]/[branch_i_think]/path_to_file

5 Likes

This is not unfortunate. I have at least two corrupted Repls (and one of those two doesn’t even run). I am glad that they do not share a filesystem with my other Repls, because if they did all my Repls would be bricked.

6 Likes