Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brew fails to open web pages on Linux, please whitelist DISPLAY variable #5692

Closed
5 tasks done
mtmiller opened this issue Feb 8, 2019 · 5 comments
Closed
5 tasks done
Assignees
Labels
linux outdated PR was locked due to age

Comments

@mtmiller
Copy link
Contributor

mtmiller commented Feb 8, 2019

Please note that we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

  • are reporting a bug others will be able to reproduce and not asking a question. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh
  • ran a brew command and reproduced the problem with multiple formulae? If it's a problem with a single, official formula (not cask) please file this issue at Homebrew/homebrew-core: https://github.com/Homebrew/homebrew-core/issues/new/choose. If it's a brew cask problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • ran brew update and can still reproduce the problem?
  • ran brew doctor, fixed all issues and can still reproduce the problem?
  • ran brew config and brew doctor and included their output with your issue?

What you were trying to do (and why)

Any brew command that passes a URL to open a tab in the web browser fails on Linux. For example, brew home or brew info --github.

What happened (include command output)

The correct web browser command runs, but fails with an error that the display cannot be opened and the tab is not opened.

Command output

mike@host:~$ brew home

(google-chrome:32228): Gtk-WARNING **: 20:57:36.156: cannot open display:
mike@host:~$ brew info --github gcc

(google-chrome:32447): Gtk-WARNING **: 20:57:40.127: cannot open display:

What you expected to happen

The web browser should open a new tab with the given URL.

The reason is clearly that the DISPLAY environment variable is removed in the sanitized environment that brew runs itself in. If I locally modify brew to include DISPLAY in the list of whitelisted environment variables, then the web page is opened as expected.

Step-by-step reproduction instructions (by running brew commands)

  1. Install Linuxbrew on a GNU/Linux system, accept the default installation options.
  2. Run any command that tries to open a web page
brew home
brew home gcc
brew info --github gcc
brew search --debian gcc

Output of brew config and brew doctor

mike@host:~$ brew config
HOMEBREW_VERSION: 2.0.1
ORIGIN: https://github.com/Homebrew/brew
HEAD: e32c1515432a938093d5ef1d8c4b4408991873df
Last commit: 29 hours ago
Core tap ORIGIN: https://github.com/Linuxbrew/homebrew-core
Core tap HEAD: 4b962b502dadb8a93e554bb16dbaa19c526bf3a7
Core tap last commit: 6 hours ago
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CACHE: /home/mike/.cache/Homebrew
HOMEBREW_LOGS: /home/mike/.cache/Homebrew/Logs
HOMEBREW_VISUAL: vim
CPU: octa-core 64-bit haswell
Homebrew Ruby: 2.5.3 => /usr/bin/ruby2.5
Clang: 7.0 build 701
Git: 2.20.1 => /home/linuxbrew/.linuxbrew/bin/git
Curl: 7.63.0 => /usr/bin/curl
Kernel: Linux 4.19.0-1-amd64 x86_64 GNU/Linux
bOS: Debian GNU/Linux buster/sid (buster)
Host glibc: 2.28
/usr/bin/gcc: 8.2.0
glibc: N/A
gcc: 5.5.0_4
xorg: N/A
mike@host:~$ brew doctor
Your system is ready to brew.
@MikeMcQuaid
Copy link
Member

Suggestion for the fix: rather than whitelisting DISPLAY instead this should be one of the variables copied to i.e. HOMEBREW_DISPLAY and then assigned back to DISPLAY in the relevant commands e.g. home, info, search.

@scpeters
Copy link
Member

scpeters commented Feb 8, 2019

It would be implemented a bit like the reverse of bd5b41e

@sjackman
Copy link
Member

sjackman commented Feb 9, 2019

@mtmiller Thanks for the bug report, Mike. Are you interested in taking a shot at fixing this yourself and submitting a PR? Here's the relevant line of code:

brew/bin/brew

Line 81 in 804951a

for VAR in HOME SHELL PATH TERM TERMINFO COLUMNS LOGNAME USER CI SSH_AUTH_SOCK SUDO_ASKPASS \

@mtmiller
Copy link
Contributor Author

mtmiller commented Feb 9, 2019

@sjackman Thanks, yeah I am happy to take a look at this. I liked the suggestion to copy DISPLAY to HOMEBREW_DISPLAY and restore it when needed, so I will try that. I'll be snowed in this weekend, so I expect I'll have some time to look at this.

@sjackman
Copy link
Member

Great. Thanks, Mike! Feel free to ask here if you have any questions, or open a PR if you have a work-in-progress but have questions about your implementation.

@lock lock bot added the outdated PR was locked due to age label Mar 15, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
linux outdated PR was locked due to age
Projects
None yet
Development

No branches or pull requests

4 participants