Create `rustup play` for a self-hosted playground?


#1

Found myself disconnected this weekend. Really liked being about to generate local docs with rustup doc, which made me think… why not rustup play for a local playground instance? Any support for the idea?


#2

The playground has the ability to import the top 100 crates. How do you think it should behave if someone is offline and tries to import a crate?

Personally I think it would give you access to everything in the local crate cache (~/.cargo/registry/cache/github.com-*/), but that’d probably be a non-trivial change to the playpen…


#3

It’s actually not that hard to run the playground locally: Grab the project, build the docker containers, then run it: https://github.com/rust-lang/rust-playpen


#4

The official playground is integer32llc/rust-playground. I have been able to get it running locally.

It requires yarn and docker already installed.

git clone https://github.com/integer32llc/rust-playground

Build and run the frontend

cd rust-playground/ui/frontend
yarn
yarn run watch

Build and run the backend

cd rust-playground/ui
RUST_LOG=ui=debug PLAYGROUND_UI_ROOT=$PWD/frontend/build/ cargo run

Build the compiler containers and tools

Fair warning: this uses something like 16G of /var/lib/docker.

cd rust-playground/compiler
./build.sh

Once everything is running, visit http://localhost:5000/.


#5

(D’oh, I thought it was merged back into playpen, I should have read the top of the readme)


#6

There’s also been a bit of background rumbling on having a single Docker image that would have the 5 other images. This would make the command docker run --useful-arguments-and-settings the-name-of-the-playground-image.

However most people can probably accomplish 90% of the same functionality by doing the same trick that the Playground does: Have a Cargo.toml file with all of the crates you want to use. You could even copy the same one the playground uses.

Then you just need to cargo update; cargo build when you are connected to the network. When you aren’t connected, you just do cargo build. This has the benefit that you can use your preferred editor and development environment, docs would be provided for all your crates with cargo doc --open, etc.