I’m trying to create a Rust app in Glitch, and I’m having trouble installing new packages through cargo.
I’ve found at least two projects that are using Rust already:
- hello-rust is using Iron as a backend, which it’s pulling into Cargo.toml. In a thread about language support from last year, the author mentions installing other Rust packages, like actix.
- rust-web-server is using vanilla Rust, no third-party packages
The first example showed that installing packages worked at some point!
But if I remix either of these projects and start trying to installing my own dependencies (or in the cast of hello-rust, just run it in my own namespace), I get an error from Cargo:
$ cargo build
error: failed to load source for a dependency on `oauth-client`
Unable to update registry `https://github.com/rust-lang/crates.io-index`
failed to open: /opt/rust/cargo/registry/index/github.com-1ecc6299db9ec823/.cargo-index-lock
Permission denied (os error 13)
Inspecting it in the console, I see that the directory is owned by root:
$ ls -l /opt/rust/cargo
drwxr-xr-x 2 root root 4096 Jun 28 03:39 bin
-rw-r--r-- 1 root root 40 Jun 28 03:40 env
Am I missing something I should be doing to install packages with Rust? Have the permissions on this directory changed in the last year or something?
(This might also just be a bad idea, if Glitch has to recompile dependencies on cold start. Just curious if I’m missing something, because I couldn’t find explanations for this error elsewhere!)
os error 13 translates to this: you cant edit those files, nor can the system.
oh! welcome to the glitch support community!
Hi, I wrote the hello-rust template, and can confirm it did work at some point, but no longer does now that I check it.
At a guess, it would seem Glitch no longer allows access to the location cargo was using to store files, or else Glitch’s version of cargo has been updated and has breaking changes to the way it stores files that aren’t compatible with Glitch.
It’s difficult to say where the issue lies, without insight from the Glitch team.
@Glitch_Response is this something that users can fix/work on?
I’ve passed this onto the team to see if it’s a regression that can be fixed!
Thanks! Let me know if this is something the community can help with.
no one’s asking for a workaround, but here’s one anyway: install a whole separate copy of rust in a location where we do have permissions.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
bad idea, if Glitch has to recompile dependencies on cold start
but it would have to do that for Node.js too, so maybe that’s not too bad
that is exactly what the global workaround does! ( for nodejs anyway )
Good to know I’m not missing anything obvious!
Thanks for all the suggestions – I ended up writing my first Glitch app in Python instead of Rust, and I’ll probably stick to that better-trodden path until something changes.
If we’re willing to use Glitch’s installed version of Rust, does it work to simply change the CARGO_HOME? E.g.:
$ export CARGO_HOME=/app/.cargo
I’m just getting started, so this works so far… I just want to avoid hitting bumps later!
…and I’m already hitting bumps because it’s an old compiler version and the package I want to install is too fresh (
@glitch_support Any updates on this?
This work but, has to be done every time, the project is started which besides using a ton of resources for no reason is very annoying.
Glitch is focusing their efforts on Node.js. See this article to re-read that same statement in different words: https://glitch.happyfox.com/kb/article/24-what-languages-and-frameworks-are-supported/
They should then remove all the other compilers and possibly announce that they will be a NodeJS host. The issue right now is there are many references that state glitch supports other languages. While that may have been true at the time it listed, once some time has passed the “other” (rust for example) compilers will eventually stop working and lead to many unhappy users taking their frustration on other forum users only trying to help. Besides, if they merge their resources to only NodeJS it will be much cheaper to run their services overall due to less support time on unsupported languages and smaller containers overall. If you need even more of a reason imagine if someone pays for a year worth of glitch plus only to find out go/java/python/rust etc. is unsupported and as a result they cannot host their site here…
Hi, @wh0 and @MealsPOS, while it is true that Glitch mentions Node.JS in most places as the supported framework, it is not the only framework supported on Glitch. Here is a list of supported languages and framework. There are many other supported languages and frameworks like PHP, Java, Vue.JS, Ruby, Ruby on Rails, C, Python etc. and the Glitch support team will help you out if you face any problem with them. They helped me with my Ruby on Rails app, too.
I just got a response from Glitch Support
Thanks for contacting us!
If you would like tips and workarounds for using rust/cargo with Glitch, check out community forum. There, you might find some folks who have had success working with it. Here are some existing forum threads about Rust. Feel free to ask your questions in there, or create a new thread if you like!
Rust is not going to be supported outside of community workarounds, which at the moment only causes undue strain to the server.