Using the input function will cause Mojo to crash.

Using the input function in the main function causes mojo to crash. Please tell me why it crashes and how to work around it.
fn main():'''
name = input("Enter your name: ”)
print(“Hello”, name)
fn main():'''
name = input("Enter your name: ”)
print(“Hello”, name)
This is the mojoproject.toml
[project].
authors = [“Staycia”].
channels = [“conda-forge”, “https://conda.modular.com/max”]
description = “Add a short description here”
name = “c2024Exam”
platforms = [“osx-arm64”].
version = “0.1.0”

[tasks]

[dependencies]]
max = “>=24.5.0,<25”
[project].
authors = [“Staycia”].
channels = [“conda-forge”, “https://conda.modular.com/max”]
description = “Add a short description here”
name = “c2024Exam”
platforms = [“osx-arm64”].
version = “0.1.0”

[tasks]

[dependencies]]
max = “>=24.5.0,<25”
3 Replies
Zbornak
Zbornak4w ago
I have had this problem for a while now. There was an issue loggged in September where someone mentioned that if you just run the code it won't work, but if you build first it fixes the issue, but for me neither works, I get the same segfault every time (incidentally also on silicon osx!). I have mentioned it a few times here but no-one seems responsive (I mean, i/o is kind of important in computing, right??) so I just import python and use it's input function. Hopefully someone working on the stdlib can have a look at it at some point
Zbornak
Zbornak4w ago
GitHub
[BUG] Program with input() crashes when run directly by mojo CLI · ...
Bug description I'm encountering a crash with a simple Mojo v24.5 program that uses the input() method when I run the program directly with the mojo CLI. However, when I compile the same progra...
toasty
toasty4w ago
Does it also crash if you try it in nightly? I know they pushed some changes to the input function shortly after 24.5 was released.
Want results from more Discord servers?
Add your server