Skip to content

Commit

Permalink
Merge pull request #16040 from XuehaiPan/rcfile-shellenv
Browse files Browse the repository at this point in the history
docs: prefer placing `shellenv` command in rcfile rather than shell profile on Linux
  • Loading branch information
MikeMcQuaid committed Oct 6, 2023
2 parents 7a2425f + e12a56f commit 8f7e06a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Library/Homebrew/cmd/shellenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#:
#: The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
#: To help guarantee idempotence, this command produces no output when Homebrew's `bin` and `sbin` directories are first and second
#: respectively in your `PATH`. Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`,
#: `~/.bash_profile`, or `~/.zprofile`) with: `eval "$(brew shellenv)"`
#: respectively in your `PATH`. Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.bash_profile` or
#: `~/.zprofile` on macOS and `~/.bashrc` or `~/.zshrc` on Linux) with: `eval "$(brew shellenv)"`
#:
#: The shell can be specified explicitly with a supported shell name parameter. Unknown shells will output POSIX exports.

Expand Down
5 changes: 2 additions & 3 deletions docs/Homebrew-on-Linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ Technically, you can install Homebrew wherever you want. However, you shouldn't

The prefix `/home/linuxbrew/.linuxbrew` was chosen so that users without admin access can ask an admin to create a `linuxbrew` role account and still benefit from precompiled binaries. If you do not yourself have admin privileges, consider asking your admin staff to create a `linuxbrew` role account for you with home directory set to `/home/linuxbrew`.

Follow the *Next steps* instructions to add Homebrew to your `PATH` and to your bash shell profile script, either `~/.profile` on Debian/Ubuntu or `~/.bash_profile` on CentOS/Fedora/Red Hat.
Follow the *Next steps* instructions to add Homebrew to your `PATH` and to your bash shell rcfile, either `~/.bashrc` for `bash` or `~/.zshrc` for `zsh`.

```sh
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
echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bashrc
```

You're done! Try installing a package:
Expand Down
6 changes: 4 additions & 2 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ Print export statements. When run in a shell, this installation of Homebrew will

The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
To help guarantee idempotence, this command produces no output when Homebrew's `bin` and `sbin` directories are first and second
respectively in your `PATH`. Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`,
`~/.bash_profile`, or `~/.zprofile`) with: `eval "$(brew shellenv)"`
respectively in your `PATH`. Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.bash_profile` or
`~/.zprofile` on macOS and `~/.bashrc` or `~/.zshrc` on Linux) with: `eval "$(brew shellenv)"`

The shell can be specified explicitly with a supported shell name parameter. Unknown shells will output POSIX exports.

Expand Down Expand Up @@ -1926,6 +1926,8 @@ Provides more output from Homebrew and `launchctl`(1) or `systemctl`(1) if run w
Run *`subcommand`* on all services.
* `--json`:
Output as JSON.
* `--no-wait`:
Don't wait for `stop` to finish stopping the service.

### `test-bot` [*`options`*] [*`formula`*]

Expand Down
6 changes: 5 additions & 1 deletion manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ Search for \fItext\fR in the given database\.
Print export statements\. When run in a shell, this installation of Homebrew will be added to your \fBPATH\fR, \fBMANPATH\fR, and \fBINFOPATH\fR\.
.
.P
The variables \fBHOMEBREW_PREFIX\fR, \fBHOMEBREW_CELLAR\fR and \fBHOMEBREW_REPOSITORY\fR are also exported to avoid querying them multiple times\. To help guarantee idempotence, this command produces no output when Homebrew\'s \fBbin\fR and \fBsbin\fR directories are first and second respectively in your \fBPATH\fR\. Consider adding evaluation of this command\'s output to your dotfiles (e\.g\. \fB~/\.profile\fR, \fB~/\.bash_profile\fR, or \fB~/\.zprofile\fR) with: \fBeval "$(brew shellenv)"\fR
The variables \fBHOMEBREW_PREFIX\fR, \fBHOMEBREW_CELLAR\fR and \fBHOMEBREW_REPOSITORY\fR are also exported to avoid querying them multiple times\. To help guarantee idempotence, this command produces no output when Homebrew\'s \fBbin\fR and \fBsbin\fR directories are first and second respectively in your \fBPATH\fR\. Consider adding evaluation of this command\'s output to your dotfiles (e\.g\. \fB~/\.bash_profile\fR or \fB~/\.zprofile\fR on macOS and \fB~/\.bashrc\fR or \fB~/\.zshrc\fR on Linux) with: \fBeval "$(brew shellenv)"\fR
.
.P
The shell can be specified explicitly with a supported shell name parameter\. Unknown shells will output POSIX exports\.
Expand Down Expand Up @@ -2741,6 +2741,10 @@ Run \fIsubcommand\fR on all services\.
\fB\-\-json\fR
Output as JSON\.
.
.TP
\fB\-\-no\-wait\fR
Don\'t wait for \fBstop\fR to finish stopping the service\.
.
.SS "\fBtest\-bot\fR [\fIoptions\fR] [\fIformula\fR]"
Tests the full lifecycle of a Homebrew change to a tap (Git repository)\. For example, for a GitHub Actions pull request that changes a formula \fBbrew test\-bot\fR will ensure the system is cleaned and set up to test the formula, install the formula, run various tests and checks on it, bottle (package) the binaries and test formulae that depend on it to ensure they aren\'t broken by these changes\.
.
Expand Down

0 comments on commit 8f7e06a

Please sign in to comment.