Command ‘brew’ not found

Let me guess: you just installed Homebrew on your Linux system because you were going to use it to install some other software. Instead, when you tried to install the software, you got something like this:

$ brew install <software-name>
Command 'brew' not found

This response means the command can’t find the brew application binary. This happened because the Homebrew installation omits an essential step: adding the path of the brew binary to the Linux $PATH variable.

To fix this, you must add an instruction to your ~/.profile or ~/.bashrc configuration file that adds the path of the brew binary to the Linux $PATH variable.

So, what is the path of the brew binary?

Earlier, when you installed Homebrew, the output showed the location of the brew binary. Optional: Scroll up through your command history to see if it is still visible. For example:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password).
==> This script will install:
/home/linuxbrew/.linuxbrew/bin/brew
/home/linuxbrew/.linuxbrew/share/doc/homebrew
/home/linuxbrew/.linuxbrew/share/man/man1/brew.1
/home/linuxbrew/.linuxbrew/share/zsh/site-functions/_brew
/home/linuxbrew/.linuxbrew/etc/bash_completion.d/brew
/home/linuxbrew/.linuxbrew/Homebrew

Press RETURN to continue or any other key to abort

If you have root privileges, brew installed to /home/linuxbrew/.linuxbrew/bin/brew. Otherwise, if you don’t have root privileges, it installed to ~/.linuxbrew/bin/brew.

In any case, the following commands (which I found slightly buried in the Homebrew documentation) will sort this out. They find which path has the brew binary and adds it to your .profile configuration file. Paste the following commands in your terminal.

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile

After this, restart your terminal. When you do this, .profile adds the path to your system’s $PATH variable.

Now, verify that the brew command works by using it to install some software. Please let me know how this works for you. If not, I’ll try adding some troubleshooting steps.

Now…why was I installing Homebrew? Ah yes, I installed it so I could install the GitHub CLI:

rolfedh@rolfedh-HP-Z2-Mini-G3-Workstation:~$ brew install gh
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 48 formulae.
Updating Homebrew...

==> Downloading https://ghcr.io/v2/linuxbrew/core/gh/manifests/2.0.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/linuxbrew/core/gh/blobs/sha256:ac34664fe701dc
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Pouring gh--2.0.0.x86_64_linux.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /home/linuxbrew/.linuxbrew/etc/bash_completion.d
==> Summary
🍺  /home/linuxbrew/.linuxbrew/Cellar/gh/2.0.0: 97 files, 27.8MB
rolfedh@rolfedh-HP-Z2-Mini-G3-Workstation:~$ 

My favorite Kubernetes books

Note: I did not include any affiliate links in this post.

Nigel Poulton’s Mastering Kubernetes bundle on Leanpub, $12.99.

A couple of years ago, I bought the ebook and audiobook versions of Nigel’s The Kubernetes Book. I became a huge fan of his humor and ability to deliver key information about complex topics.

This weekend, I found an interview with Nigel on the Leanpub Frontmatter podcast. I enjoyed hearing about how his father saved up for his first computer, how he got started in tech, how he started developing courses and writing books, and how he and his family are doing currently.

Inspired by all that, I decided to look for his current books on Leanpub and found the aforementioned Mastering Kubernetes bundle, which contains the 2021 editions of The Kubernetes Book and Quick Start Kubernetes.

You might ask, why pay for a book about Kubernetes, which already has comprehensive free well-written documentation? Aside from liking the guy, I bought Nigel’s books because he does a great job of summarizing and helping me retain the key information. His work saves me countless hours of reading. He doesn’t just present dry facts, he shares meaningful insights and opinions about the platform.

(Nigel, if you’re reading this post, skip the next sentence because I don’t want you to raise your prices.) If reading his books saves me only 15 minutes and increases my mastery of Kubernetes, they are worth far more than the small price I paid for them.

I also like supporting Leanpub. Authors earn 80% royalties on their books and courses. The platform enables authors to set sliding scale prices for their works. And the platform encourages authors to publish early and publish often — to better gauge their readers’ interests and needs and therefore deliver information that has more value.

Vale notes #3: Things start rolling

Last week, I did separate walk-throughs with two writers. My intention was to gain insight into the issues a typical user might encounter, and to use that information to improve the “getting started” repo I had created. I helped them install, configure, and start using Vale on their systems.

Installing Vale by using brew was problematic, so we installed the precompiled Vale binary instead. We also copied the .vale.ini configuration file and /styles directory to their doc project and updated the configuration to work with .adoc files.

However, when we ran Vale against one of their .adoc content files, we got a mysterious error. Searching online didn’t help us solve the issue right away. I made a mental note to try to reproduce the error later. The writer had been preparing a presentation on Vale for his documentation project team, but given these setbacks they decided to delay that presentation.

The second writer completed the installation process on their own. Our meeting was more of a conversation than a walkthrough. It seemed like they were ready for a style that was more Red Hat-specific than the generic ones I provided.

This weekend, I put my insights from those two walkthroughs to work by completely updating the getting started repo, https://github.com/rolfedh/studious-fortnight:

  • Removing the previous /styles folder and .vale.ini file.
  • Adding the .vale styles folder and .vale.ini that Fabrice and Yana developed for the Che eclipse documentation project.
  • Updating and expanding README.md with new information to help you get started with using Vale.
  • Adding a “Troubleshooting common errors” topic to help newcomers identify and correct common issues.
  • Added a “Vale at Red Hat Blog” blog to the repo.

That blog will cover information similar to project and release notes. In contrast, these “vale notes” posts will focus more on my personal insights.

Vale notes #2: Talk to experts and stakeholders

In addition to eating my own dogfood, I started finding and talking to experts and stakeholders.

For experts, I went to folks inside and outside Red Hat. At Red Hat, I talked to Fabrice Flore-Thebault and Yana Hontyk. Last year, they presented on using Vale with their documentation sets: Eclipse Che and CodeReady Workspaces. I talked to them about their workflow, the issues they had fixed, and results.

Outside Red Hat, I pulled together an unconference session at Write the Docs Portland conference with Mike Jang from GitLab and Jodie Putrino at NGINX. They spoke about their differing approaches to rolling it out at their organizations. Lynette Miles at TAG1 Consulting also contributed.

For stakeholders:

  • I talked with my manager, who was supportive.
  • I arranged a meeting for Yana and Fabrice to present their work to a small group of writers, content strategists, and managers who had expressed an interest in rolling out Vale. The group expressed a lot of interest, and we agreed there should be some follow-up actions, like additional pilot programs.

As an aside, Fabrice and Yana’s presentation included the following impressive graph. It shows how they iterated on both the documentation and Vale style rules to achieve nearly zero errors, both real errors and false positives, over the course of almost two years:

To prepare for the follow-up, I have created a repo that contains a preliminary set of Vale config files and styles: https://github.com/rolfedh/studious-fortnight (definitely a work-in-progress).

Vale notes #1: Eating my dog food

I’ve heard complaints about the peer review process at a variety of organizations where I’ve seen it in use. To simplify, they sound like this:

  • Writers: When I fix a set of issues and resubmit the PR, the reviewer(s) come up with a new set of issues.
  • Reviewers: I keep flagging the same set of stupid !%$%*$# issues.
  • Everyone: Ugh. This takes too much time and effort.

In some cases, the peer review process can be demoralizing and spark interpersonal conflicts.

Looking for a solution to this issue, I turned to Vale, a style linter that has been gained traction at a variety of organizations, such as GitLab, NGINX, and elsewhere. At Red Hat, a couple of doc projects have been using it for over a year and there seems to be growing interest in expanding its use.

My first step was to start using Vale to get hand-on experience using it: eat your own dog food, etc. In my enthusiasm, I popped $57 for a Vale Server license.

Installing Vale Server wasn’t hard. Finding and configuring the pair of plugins to make it work with my Atom editor was a little confusing. Setting up the single plugin for VS Code was easy.

I installed all the built-in styles for Vale Server, but then had trouble applying them to my docs. Installation is not enough. One must also create a project in Vale Server and configure it to use the styles.

Overall, the process was a bit tricky enough that I realized rolling it out to a team of writers would require documented procedures, tutorial videos, and live support.

It’s also unclear whether my organization would commit to purchasing Vale Server licenses at first. So, I would need to figure out how to roll out Vale, the CLI tool, instead of Vale Server. To make the distinction clear, I’ll refer to Vale as Vale CLI from now on.

Vale CLI is simpler to install and configure than Vale Server. However, I believe Vale CLI alone doesn’t integrate with editors like Atom and VS Code. With Vale CLI, you get all your feedback by running the vale command against your file or files from the CLI. For example:

$ vale README.md

The output looks something like this:

Typical feedback from Vale CLI

In some ways, it’s less distracting to get with this command line feedback after you write a block of content. Vale Server highlights issues in your text editor when you save your current text. In other words, with Vale Server, the feedback is both more immediate and in some ways distracting. Six one way, half-dozen the other.

Git rid of old branches :-)

Toss ’em out!

Every so often, I clean up old working branches I don’t need any more.

After I’ve written or revised content, and the pull request has been merged from my fork of the repo into the main branch of the organization’s repo, it’s time to get rid of the old working branches.

TLDR/Copy and paste

Here’s a summary of the commands for you to copy and paste.

cd <repo-directory>/
git checkout <main branch>
git fetch upstream <main branch>
git branch --merged
> Make sure the branch is dead
git branch -D <branch-name>
git push origin :<branch-name>

Verbose

Sections:

  • List the merged branches
  • Make sure the working branches are really dead
  • Delete the dead branches
List the merged branches

I start by listing the merged branches in my local repo:

$ cd openshift-docs/       # Change to the project/repo directory
$ git checkout main        # Check out the main or master branch
Already on 'main'
Your branch is up to date with 'upstream/main'.
$ git fetch upstream main  # Fetch information about branches from your upstream repo 
remote: Enumerating objects: 46, done.
remote: Counting objects: 100% (36/36), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 19 (delta 15), reused 12 (delta 10), pack-reused 0
Unpacking objects: 100% (19/19), 3.11 KiB | 176.00 KiB/s, done.
From github.com:openshift/openshift-docs
 * branch                main     -> FETCH_HEAD
   54901a001..b051f3c46  main     -> upstream/main
$ git branch --merged      # List local branches that are merged in the upstream repo
  RHDEVDOCS-2465-replace-docker
  RHDEVDOCS-2514
  RHDEVDOCS-2609
  RHDEVDOCS-2618
  RHDEVDOCS-2740-rn
  bz#1873372
* main
Make sure the working branches are really dead

Early on, when I start a new project, I use the ID of the Jira or GitHub issue to name the working branch and PRs. This makes it simple to know which issue, branch, and PR belong to each other.

When I’ve finished using a working branch, to make sure I don’t need it any more, I search my closed pull requests for the issue ID. I review the pull request to make sure that the PR that was merged into the main branch was also cherry-picked into all relevant release branches. I also look at the issue to make sure its state is “closed.”

When I’ve confirmed that a branch is not only merely dead, but really most sincerely dead, it’s time to…

Delete the dead branches

I return to my terminal and delete the branch by entering:

$ git branch -D <branch-name>

Then I push the deletion to origin by entering:

$ git push origin :<branch-name>

Notes

  • Many repos still use master as the name of their primary branch. In this post, I have changed the name to main and will continue to do so in future posts.
  • Please share your comments, questions, and suggestions for improving this post, below!

Job aid: Git cherry-pick a commit and manually resolve a conflict

This post is short version of Git: Cherry-pick a commit into a branch and resolve a merge conflict. Replace `upstream/enterprise-4.8` with whatever your target branch is.

I copy/paste these commands into my terminal.

git checkout master
git branch -D enterprise-4.8
git checkout --track upstream/enterprise-4.8
git status

Verify that “Your branch is up to date with ‘upstream/enterprise-4.8’.”

git cherry-pick <commit hash>

Go to the pull request that has the merge failure (e.g., like this example). Copy the commit hash. In the terminal, replace <commit hash> with the real one. Enter the command.

Ignore “CONFLICT (content): Merge conflict in <path/filename>

In Atom editor (or whatever), manually resolve the merge conflict.
Save and commit the changes as “Manual CP of RHDEVDOCS-<jira#> #<pr#>”.

git status

Confirm “Your branch is ahead of ‘upstream/enterprise-4.8’ by 1 commit.”

git push -f origin enterprise-4.8

Go to origin/enterprise-4.8 in GitHub and create the pull request with the following description.

https://issues.redhat.com/browse/RHDEVDOCS-2617
Previously merged as https://github.com/openshift/openshift-docs/pull/29491/files
[enterprise-4.8]

Copy the URL of this new PR and paste it to a comment in the Jira issue (e.g., in RHDEVDOCS-2617).

Git: Cherry-pick a commit into a branch and resolve a merge conflict

Here’s the merge conflict message our merge master got when she tried to cherry pick my pull request (PR) to version 4.7 of the published OpenShift docs (lines , below).

openshift-cherrypick-robot commented 4 days ago • 
@theythemself: #29573 failed to apply on top of branch "enterprise-4.7":

Applying: [RHDEVDOCS-2614](https://issues.redhat.com/browse/RHDEVDOCS-2614) Define ClusterLogForwarder compatability Matrix
Using index info to reconstruct a base tree...
M	logging/cluster-logging-external.adoc
Falling back to patching base and 3-way merge...
Auto-merging logging/cluster-logging-external.adoc
CONFLICT (content): Merge conflict in logging/cluster-logging-external.adoc
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 [RHDEVDOCS-2614](https://issues.redhat.com/browse/RHDEVDOCS-2614) Define ClusterLogForwarder compatability Matrix
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Here, I start by deleting the enterprise-4.7 branch (line ) because it had a previous unmerged commit sitting at the top of the pile. (In the future, I think I’ll avoid this by creating a working branch off of the enterprise-4.7 branch.)

[memyself@memyself openshift-docs]$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'upstream/master'.

[memyself@memyself openshift-docs]$ git branch -D enterprise-4.7
Deleted branch enterprise-4.7 (was 803d05ddd).

Next, I create a new enterprise-4.7 branch that tracks Red Hat’s upstream repo (line). I don’t track my forked copy of the repo, origin, because it has that previous unmerged commit sitting at the top of the pile. (Again, there are other better ways to deal with that problem, I’m just sharing the one I used here.)

[memyself@memyself openshift-docs]$ git checkout --track upstream/enterprise-4.7
Branch 'enterprise-4.7' set up to track remote branch 'enterprise-4.7' from 'upstream'.
Switched to a new branch 'enterprise-4.7'

I fetch the latest changes from upstream and use status to verify that my branch is up to date.

[memyself@memyself openshift-docs]$ git fetch upstream
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 4), reused 5 (delta 4), pack-reused 0
Unpacking objects: 100% (6/6), 1.22 KiB | 1.22 MiB/s, done.
From github.com:openshift/openshift-docs
   335951a8d..0f6dbceae  enterprise-4.5 -> upstream/enterprise-4.5

[memyself@memyself openshift-docs]$ git status
On branch enterprise-4.7
Your branch is up to date with 'upstream/enterprise-4.7'.

nothing to commit, working tree clean

I go to the pull request with the failed cherry pick and copy the hash of the commit. I always squash commits so each pull request has only one commit.

I cherry pick that commit into the 4.7 branch. The merge conflict on line 5 is expected.

[memyself@memyself openshift-docs]$ git cherry-pick 3cad05d66d11c2d38a08322222f6c9dcbfc839ab
Auto-merging modules/olm-mirroring-package-manifest-catalog.adoc
Auto-merging modules/cluster-logging-deploy-console.adoc
Auto-merging modules/cluster-logging-deploy-cli.adoc
CONFLICT (content): Merge conflict in modules/cluster-logging-deploy-cli.adoc
error: could not apply 3cad05d66... RHDEVDOCS-2589 OpenShift Logging: Update any installation/upgrade specific information to use our new channels.
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

I check the status.

[memyself@memyself openshift-docs]$ git status
On branch enterprise-4.7
Your branch is up to date with 'upstream/enterprise-4.7'.

You are currently cherry-picking commit 3cad05d66.
  (all conflicts fixed: run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   logging/cluster-logging-exported-fields.adoc
	modified:   logging/cluster-logging-upgrading.adoc
	modified:   modules/cluster-logging-configuring-image-about.adoc
	modified:   modules/cluster-logging-deploy-cli.adoc
	modified:   modules/cluster-logging-deploy-console.adoc
	modified:   modules/cluster-logging-eventrouter-deploy.adoc
	modified:   modules/cluster-logging-log-store-status-comp.adoc
	modified:   modules/cluster-logging-updating-logging.adoc
	modified:   modules/cluster-logging-visualizer-kibana.adoc
	modified:   modules/olm-mirroring-package-manifest-catalog.adoc

In Atom editor (not shown here), I inspect the file that contains the conflict, modules/cluster-logging-deploy-cli.adoc. In it, I select the set of changes I want to keep. Then, I stage and commit the changes.

Back on the command line, I complete the cherry pick process.

[memyself@memyself openshift-docs]$ git cherry-pick --continue

I -f force push the changes to 4.7 to origin, which is my fork of the repo.

[memyself@memyself openshift-docs]$ git push -f origin enterprise-4.7
Enumerating objects: 27, done.
Counting objects: 100% (27/27), done.
Delta compression using up to 8 threads
Compressing objects: 100% (14/14), done.
Writing objects: 100% (14/14), 1.62 KiB | 1.62 MiB/s, done.
Total 14 (delta 13), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (13/13), completed with 13 local objects.
To github.com:rolfedh/openshift-docs.git
 + 803d05ddd...bcc5f087b enterprise-4.7 -> enterprise-4.7 (forced update)

Finally, on GitHub, in rolfedh/openshift-docs, I create the pull request to merge the commit into openshift:enterprise-4.5 from rolfedh:enterprise-4.5.

I’ll need to repeat this process and come up with a more complete set of screenshots.

Here’s a TLDR version of this blog post: Job aid: Git cherry-pick a commit and manually resolve a conflict
I use this short version to copy/paste commands into my terminal.

WordPress bug with highlighting lines in a code block

I discovered a bug. When you use the highlight lines property for code blocks as shown here…

Here, on the right, you see the “Highlight lines” property.

…the highlighting for the higher line numbers gets confused, as shown with lines 27, 39, 60 in the following screenshot.

Here, you see the highlighting on lines 27, 39, and 60 is wrong.

I’ve reached out to WordPress support and will let you know how it goes. I’ll try to file a bug for this.

[UPDATE] A WordPress happiness engineer created the following issue, which does an excellent job of analyzing and describing the problem: https://github.com/Automattic/wp-calypso/issues/50577