Hey everyone,
with the help of rocs ci scripts, i wrote a little bash script that installs the latest roc build as /roc_nightly/
. That way i don't have to wget, tar rename and so on by hand. maybe thats helpful for others too, so i thought i share it here:
set -euxo pipefail
rm -rf roc_nightly
rm roc_nightly.tar.gz
curl --request GET \
--url https://api.github.com/repos/roc-lang/roc/releases \
--header 'content-type: application/json' \
--output roc_releases.json
arch=linux_x86_64
LATEST_RELEASE_URL=`cat roc_releases.json | jq --arg arch $arch '.[0] | .assets | map(.browser_download_url) | map(select(. | contains("\($arch)-"))) | last'`
if [[ "$LATEST_RELEASE_URL" == "null" ]]
then
echo "I expected to get a url but I got null instead. The provided argument for this bash script may not have had any matches when used as arch in the jq query above."
exit 1
fi
DL=`echo "$LATEST_RELEASE_URL" | sed 's/\"//g'`
wget -c -O roc_nightly.tar.gz $DL
mkdir roc_nightly
tar -zxf roc_nightly.tar.gz -C roc_nightly --strip-components=1
rm roc_nightly.tar.gz
rm roc_releases.json
@Rene Mailaender great stuff! Small question: what should be the $AUTH_HEADER
value?
oh. good question. i think that’s included by mistake. (copy paste inheritance) i never set that variable and the script worked non the less. but i double check that later. thx
Yeah, you can leave the --header '$AUTH_HEADER' \
out, it's only necessary on CI machines
yes you are right. have removed it from the snippet. :)
Becuase of the new naming of the nightly releases I was able to condense the install script into one line:
curl --fail --location 'https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz' | tar --directory $HOME/bin --extract --gzip --strip-components 1 --file - --wildcards 'roc_nightly-*/roc'
If you want to use it you'd need to change the linux_x86_64
to your OS and architecture and the $HOME/bin
to the location you want to install the Roc binary
nice! :smiley:
An even shorter version (which at least chatGPT thinks is equivalent):
curl -fL 'https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz' | tar -xz -C $HOME/bin --strip-components 1 -f - 'roc_nightly-*/roc'
Ah yeah, I wrote it for a docker container so I expanded out all the flags to make it more maintainable.
I'm surprised it removed the --wildcards
option, but after googling it looks like the default behaviour for most tar implementations is to treat filter paths as globs :shrug:
Hannes said:
Becuase of the new naming of the nightly releases I was able to condense the install script into one line:
curl --fail --location 'https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz' | tar --directory $HOME/bin --extract --gzip --strip-components 1 --file - --wildcards 'roc_nightly-*/roc'
If you want to use it you'd need to change the
linux_x86_64
to your OS and architecture and the$HOME/bin
to the location you want to install the Roc binary
For others who want to use this, I had to remove the --wildcards
to get it to work on my mac. Thanks for sharing this!
Ah, probably a GNU tar specific option :sweat_smile:
Richard Feldman said:
nice! :smiley:
An even shorter version (which at least chatGPT thinks is equivalent):
curl -fL 'https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz' | tar -xz -C $HOME/bin --strip-components 1 -f - 'roc_nightly-*/roc'
This version didn't work for me on Ubuntu. :thinking:
tar: Pattern matching characters used in file names
tar: Use --wildcards to enable pattern matching, or --no-wildcards to suppress this warning
tar: roc_nightly-*/roc: Not found in archive
tar: Exiting with failure status due to previous errors
The original one @Hannes shared works.
interesting, so I guess you need --wildcards
on Linux but need to omit it on macOS?
I guess so :thinking:
$ tar --version
tar (GNU tar) 1.34
If you have GNU tar installed on Mac OS it's normally called gtar, but I don't think that's very common :/
gtar
:guitar:
This is super hacky, but if you use TAR_OPTIONS=--wildcards tar ...
, it seems to work with both tar and gtar because only GNU tar supports TAR_OPTIONS
Updated install one-liner that installs Roc and the Roc language server on MacOS and Linux (except Alpine), you just need to export two environment variables:
ROC_OUTPUT_LOCATION
- path to the directory you want to install toROC_OS
- Your OS and architecture, one of these:linux_arm64
linux_x86_64
macos_apple_silicon
macos_x86_64
export ROC_OS=... ROC_OUTPUT_LOCATION=... && mkdir -p $ROC_OUTPUT_LOCATION && curl --fail --location "https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-$ROC_OS-latest.tar.gz" | TAR_OPTIONS=--wildcards tar --directory $ROC_OUTPUT_LOCATION --extract --gzip --strip-components 1 --file - 'roc_nightly-*/roc' 'roc_nightly-*/roc_language_server'
Thanks @Ajai Nelson for the TAR_OPTIONS hack :)
I'm not sure I should be thanked for that lol, it's a little horrifying
If it works, it works! :sweat_smile:
Last updated: Jul 05 2025 at 12:14 UTC