.gitpod.yml:
tasks:
- init: gp env -e PATH="/usr/local/cargo/bin:$PATH" && eval $(gp env -e) && /workspace/rustlings/install.sh
- command: eval $(gp env -e) && /workspace/.cargo/bin/rustlings watch
image:
file: .gitpod.Dockerfile
vscode:
extensions:
- [email protected]:CvNqMTgDdt3UXt+6BCDTVg==
.gitpod.Dockerfile:
FROM rust
ENV export PATH="/usr/local/cargo/bin:$PATH"
Repo:
https://github.com/ryanpcmcquen/rustlings/tree/add-gitpod-support
My end goal here is just to modify the PATH, and I've tried a lot of things, but nothing seems to be working.
Hello @ryanpcmcquen!
There are some pitfalls in the initial Gitpod setup. There are some things to know. I'm happy to help you out.
rust instead of using our default workspace image? It has rust installed already:Please find at https://github.com/corneliusludmann/rustlings/tree/gitpod-test a working example with our image.
https://gitpod.io/#https://github.com/corneliusludmann/rustlings/tree/gitpod-test
If there is a good reason for building your own image, here are some hints that you need to know:
gp does not work well in init. The init command could be running as prebuild or when the workspace is not fully started. Then, the gp service is not there yet. The best way to change the PATH variable is by adding it to .bashrc, IMO. You can do this in your .gitpod.Dockerfile like this:# See https://github.com/gitpod-io/workspace-images/blob/1ed69ba76d99485b8dab7900dc03d1a8e240398d/full/Dockerfile#L35-L37
RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod
USER gitpod
RUN echo 'export PATH="/usr/local/cargo/bin:$PATH"' >> /home/gitpod/.bashrc
/workspaces folder in your Dockerfile will be overwritten by the Git repo contents and it lost. Everything that you modify outside of the /workspace folder (e.g. the home folder) in your .gitpod.yml is be lost after a workspace restart. That also means that changes of an init command during a prebuild outside of /workspace is lost. As a general rule of thumb:/workspace in your Dockerfile and never change something outside of /workspace in your .gitpod.yml tasks.That could be challenging when tools store data in the home folder. Therefore we change some folders in our workspace image. So: If possible, take our base image instead.
.gitpod.yaml:tasks:
- init: /workspace/rustlings/install.sh
- command: /workspace/.cargo/bin/rustlings watch
leads to two separate terminals in parallel. If the second command relies on the first one you need to write it like this:
tasks:
- init: /workspace/rustlings/install.sh
command: /workspace/.cargo/bin/rustlings watch
(Be aware of the second - that is missing.)
--
I hope this helps you.
Wow, @corneliusludmann, thank you so much for the fix and the very thorough explanation, I've bookmarked this page because that is very helpful data.
I'm only having one issue, it appears the watch command isn't noticing filesystem changes:

@corneliusludmann, it appears I was linked to an old container, after destroying that, everything is working perfectly!