1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 23:28:02 +00:00

Add Select A Specific Rails Version To Install as a Rails TIL

This commit is contained in:
jbranchaud
2024-02-16 19:56:38 -06:00
parent 8100432fad
commit d02d6e006b
2 changed files with 30 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
# Select A Specific Rails Version To Install
We can install a specific Rails version with `gem` using the version flag.
```bash
$ gem install rails --version 7.1.3
```
That's only if we already know which specific version we are intending to
install.
A better version of this would show us a list of available version and let us
select the one we want.
We can do this by fetching all remote Rails versions with `gem`, splitting that
output up into a single version per line, and then piping that to an `fzf`
prompt. The version we navigate to and select will be fed into the `gem
install` command.
```bash
gem install rails --version $(
gem list rails --exact --remote --all \
| sed -n 's/.*(\([^)]*\)).*/\1/p' \
| tr ',' '\n' \
| sed 's/^ //' \
| fzf
)
```