1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-18 14:38:01 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
jbranchaud
030a3f9791 Add Search For Homebrew Packages To Install as a Unix TIL 2024-02-16 23:38:21 -06:00
jbranchaud
d02d6e006b Add Select A Specific Rails Version To Install as a Rails TIL 2024-02-16 19:56:38 -06:00
3 changed files with 64 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
_1366 TILs and counting..._
_1368 TILs and counting..._
---
@@ -903,6 +903,7 @@ _1366 TILs and counting..._
- [Schedule Sidekiq Jobs Out Into The Future](rails/schedule-sidekiq-jobs-out-into-the-future.md)
- [Secure Passwords With Rails And Bcrypt](rails/secure-passwords-with-rails-and-bcrypt.md)
- [Select A Select By Selector](rails/select-a-select-by-selector.md)
- [Select A Specific Rails Version To Install](rails/select-a-specific-rails-version-to-install.md)
- [Select Value For SQL Counts](rails/select-value-for-sql-counts.md)
- [Serialize With fast_jsonapi In A Rails App](rails/serialize-with-fast-jsonapi-in-a-rails-app.md)
- [Set A Timestamp Field To The Current Time](rails/set-a-timestamp-field-to-the-current-time.md)
@@ -1371,6 +1372,7 @@ _1366 TILs and counting..._
- [Safely Edit The Sudoers File With Vim](unix/safely-edit-the-sudoers-file-with-vim.md)
- [Saying Yes](unix/saying-yes.md)
- [Search Files Specific To A Language](unix/search-files-specific-to-a-language.md)
- [Search For Homebrew Packages To Install](unix/search-for-homebrew-packages-to-install.md)
- [Search History](unix/search-history.md)
- [Search Man Page Descriptions](unix/search-man-page-descriptions.md)
- [Securely Remove Files](unix/securely-remove-files.md)

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
)
```

View File

@@ -0,0 +1,33 @@
# Search For Homebrew Packages To Install
Let's say we want to install the latest version of PostgreSQL with `brew`, but
we aren't sure either what formulas are available nor what the exact name would
be.
We can run a search with the `brew search` subcommand to get an idea of what is
available.
If I run this for even the shorthand of `postgres`, I get a useful set of
results showing me what versions I already have installed and what else is
available.
```bash
$ brew search postgres
==> Formulae
check_postgres postgresql@11 ✔ postgresql@13 postgresql@15 postgrest postgis
postgresql@10 postgresql@12 postgresql@14 postgresql@16 qt-postgresql
==> Casks
navicat-for-postgresql postgres-unofficial sqlpro-for-postgres
postbird postgrespreferencepane
If you meant "postgres" specifically:
postgresql breaks existing databases on upgrade without human intervention.
See a more specific version to install with:
brew formulae | grep postgresql@
```
I can then go on to run `brew install postgresql@16` to get the latest.
See `brew search --help` for more details.