Console Runs "Main", and not the code opened

Problem description: when we run a cods that is not called “main”, it runs the “main” one.

Expected behavior:
When press run, it runs the code that is opened at the moment.

Actual behavior:
It runs the code that is called “main”

Steps to reproduce:
Create a Repl.it
Create two codes:
one called “main”
and another x named code
Code wathever you want in the main one
and code something in x coxe
Run X and it runs the main in console.

Bug appears at this link:

Browser/OS/Device:

The “main.py” file is run by default. It is configured in the .replit file.
You may change the file run when pressing the run button to x.pyby clicking the three dots to the right of the create file/folder icons and clicking “Show hidden files”, and then scrolling down to click `.replit. Then change:

# 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"

to

# 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 x.py"

.

5 Likes

Welcome to the community! This is not a bug, but rather just something that’s not a feature. You can use the advice Milo gave, or use this solution from a similar topic. Either one should work.

3 Likes

No, you need to change entrypoint.

2 Likes

Only if it’s an interpreted language. Otherwise, that just controls what file to open, and run is used.

3 Likes