Anonymous
Not logged in
Talk
Contributions
Log in
Request account
Rest of What I Know
Search
Editing
Blog/2024-02-28/Rust Panamax
From Rest of What I Know
Namespaces
Page
Discussion
More
More
Page actions
Read
Edit
History
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
Today, my wife and I flew to Hawaii for her sister's wedding tomorrow on Feb 29. That's a 5.5 h flight and United doesn't have Internet access on the plane once you leave the mainland US so that means that if you do any programming at all, it all has to be offline. So naturally I prepared for the occasion. == LLM Assistant == My M1 Max Mac has 64 GiB of RAM which is good enough to run [https://huggingface.co/TheBloke/dolphin-2.5-mixtral-8x7b-GGUF a reasonably sized Mixtral 8x7b], the one quantized down to 4 bits per float. That's a pretty good tool and I've had it on my laptop for a while so I was confident it would work. I use Copilot less, so I didn't bother getting an offline version of that. == Rust Crates == [[File:Panamax-RS.png|thumb|alt=A screenshot of the Panamax-RS web interface. It has instructions on how to set up Panamax.|The rather nice-looking page you see looking at the Panamax web server]] Writing Rust, a lot of the work has been done in crates that are shared for all sorts of esoteric purposes. But to get crates you need the Internet. Unless you've decided to mirror all of crates.io on your laptop. Well, fortunately there's a tremendous tool to let you do that: [https://github.com/panamax-rs/panamax Panamax]. It's a pretty straightforward process once you've decided you want this. <syntaxhighlight lang=bash inline>panamax sync crates-mirror</syntaxhighlight> synced everything to a directory called crates-mirror that I put in my <syntaxhighlight inline>~/lib</syntaxhighlight> directory. From that same directory, I could then run <syntaxhighlight inline>panamax server -p 80</syntaxhighlight> to start a HTTP server that acts as a crates.io mirror. If you visit that page, you'll get the web interface with instructions on how to set things up. Personally, I didn't want to switch all my <syntaxhighlight inline>cargo</syntaxhighlight> commands to always use Panamax, this being a temporary affair, so I completed setup differently. I added the following to <syntaxhighlight inline>~/.zshrc</syntaxhighlight> since I wanted to be able to <syntaxhighlight inline>rustup</syntaxhighlight> offline as well, on-demand: <syntaxhighlight lang=zsh> function activate_panamax_rustup() { export RUSTUP_DIST_SERVER=http://localhost export RUSTUP_UPDATE_ROOT=http://localhost/rustup } </syntaxhighlight> So now, when I want to rustup on Panamax, I run that function that's available and then it works as normal. But the main thing you want to be able to do is use crates as if you were still connected to crates.io. For that, I added a [[Comma command|comma command]] that proxies <syntaxhighlight inline>cargo</syntaxhighlight>: <syntaxhighlight lang=bash> #!/usr/bin/env bash cargo \ --config 'source.crates-io.replace-with="panamax-sparse"'\ --config 'source.panamax.registry="http://localhost/git/crates.io-index"'\ --config 'source.panamax-sparse.registry="sparse+http://localhost/index/"'\ "$@" </syntaxhighlight> Nice and simple, I save that as <syntaxhighlight inline>,pargo</syntaxhighlight> it just runs our good friend cargo using the local index that panamax is serving. And after that <syntaxhighlight inline>,pargo build</syntaxhighlight> and friends will work beautifully, fetching from one's local cache. And then you can write code on a plane without needing to worry about fetching crates from the Internet! [[Category:Blog]]
Summary:
Please note that all contributions to Rest of What I Know are considered to be released under the Creative Commons Attribution-ShareAlike (see
Rest of What I Know:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Wiki tools
Wiki tools
Special pages
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs