Skip to content

How to run code snippets locally/offline? #1768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
micouy opened this issue Mar 16, 2022 · 4 comments
Closed

How to run code snippets locally/offline? #1768

micouy opened this issue Mar 16, 2022 · 4 comments

Comments

@micouy
Copy link

micouy commented Mar 16, 2022

Sometimes I get a timeout error when running Rust code. I'm currently preparing a Rust course with editable examples and I expect my students to re-run their code a lot. Is there a way to use the local installation of Rust to do it? I'd be willing to add a custom preprocessor and I'm open to hacky solutions.

@ehuss
Copy link
Contributor

ehuss commented Mar 28, 2022

I don't think it is possible for a web page to launch executables on the local system without using an extension or something like that. Also, mdbook is currently hard-coded to only use play.rust-lang.org (#350).

I might recommend checking out something like evcxr for interactive evaluation of Rust. That still requires running jupyter locally, though.

I think no matter what approach you take, you'll either need the user to install something on their system, or hosting your own server that provides a playground-like experience.

@micouy
Copy link
Author

micouy commented Apr 2, 2022

Okay, thanks.

@micouy micouy closed this as completed Apr 2, 2022
@mgeisler
Copy link
Contributor

Is there a way to use the local installation of Rust to do it?

As @ehuss said, you cannot directly use a Rust installation.

However, you can run the Playground locally (or on a server you control): https://github.com/integer32llc/rust-playground#development. Then override the play.rust-lang.org URLs in book.js for your course. You get the book.js file by running mdbook init --theme.

@mgeisler
Copy link
Contributor

@micouy Perhaps leave this feature request open since it isn't really resolved yet? Or do you consider it a duplicate of #350?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants