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

failed to write to pager: exec: "PAGER_PATH": executable file not found in $PATH #721

Open
adrienthiery opened this issue Jan 17, 2023 · 7 comments
Labels

Comments

@adrienthiery
Copy link

Thanks for submitting a bug report. Please provide the following information:

A description of the problem

Out of the box, after installing with Homebrew on Mac, I had this error message

❯ cheat zip
failed to write to pager: exec: "PAGER_PATH": executable file not found in $PATH

cheat version info

4.4.0

cheat configuration info
If your bug pertains to how cheatsheets are loaded and/or displayed, please
paste here the following information:

  1. The output of cheat -d
❯ cheat -d
community: /Users/adrien/.config/cheat/cheatsheets/community
personal:  /Users/adrien/.config/cheat/cheatsheets/personal
  1. The contents of your conf.yml file
---
# The editor to use with 'cheat -e <sheet>'. Defaults to $EDITOR or $VISUAL.
editor: EDITOR_PATH

# Should 'cheat' always colorize output?
colorize: false

# Which 'chroma' colorscheme should be applied to the output?
# Options are available here:
#   https://github.com/alecthomas/chroma/tree/master/styles
style: monokai

# Which 'chroma' "formatter" should be applied?
# One of: "terminal", "terminal256", "terminal16m"
formatter: terminal256

# Through which pager should output be piped?
# 'less -FRX' is recommended on Unix systems
# 'more' is recommended on Windows
pager: PAGER_PATH

# Cheatpaths are paths at which cheatsheets are available on your local
# filesystem.
#
# It is useful to sort cheatsheets into different cheatpaths for organizational
# purposes. For example, you might want one cheatpath for community
# cheatsheets, one for personal cheatsheets, one for cheatsheets pertaining to
# your day job, one for code snippets, etc.
#
# Cheatpaths are scoped, such that more "local" cheatpaths take priority over
# more "global" cheatpaths. (The most global cheatpath is listed first in this
# file; the most local is listed last.) For example, if there is a 'tar'
# cheatsheet on both global and local paths, you'll be presented with the local
# one by default. ('cheat -p' can be used to view cheatsheets from alternative
# cheatpaths.)
#
# Cheatpaths can also be tagged as "read only". This instructs cheat not to
# automatically create cheatsheets on a read-only cheatpath. Instead, when you
# would like to edit a read-only cheatsheet using 'cheat -e', cheat will
# perform a copy-on-write of that cheatsheet from a read-only cheatpath to a
# writeable cheatpath.
#
# This is very useful when you would like to maintain, for example, a
# "pristine" repository of community cheatsheets on one cheatpath, and an
# editable personal reponsity of cheatsheets on another cheatpath.
#
# Cheatpaths can be also configured to automatically apply tags to cheatsheets
# on certain paths, which can be useful for querying purposes.
# Example: 'cheat -t work jenkins'.
#
# Community cheatsheets must be installed separately, though you may have
# downloaded them automatically when installing 'cheat'. If not, you may
# download them here:
#
# https://github.com/cheat/cheatsheets
cheatpaths:
  # Cheatpath properties mean the following:
  #   'name': the name of the cheatpath (view with 'cheat -d', filter with 'cheat -p')
  #   'path': the filesystem path of the cheatsheet directory (view with 'cheat -d')
  #   'tags': tags that should be automatically applied to sheets on this path
  #   'readonly': shall user-created ('cheat -e') cheatsheets be saved here?
  - name: community
    path: /Users/adrien/.config/cheat/cheatsheets/community
    tags: [ community ]
    readonly: true

  # If you have personalized cheatsheets, list them last. They will take
  # precedence over the more global cheatsheets.
  - name: personal
    path: /Users/adrien/.config/cheat/cheatsheets/personal
    tags: [ personal ]
    readonly: false

  # While it requires no configuration here, it's also worth noting that
  # cheat will automatically append directories named '.cheat' within the
  # current working directory to the 'cheatpath'. This can be very useful if
  # you'd like to closely associate cheatsheets with, for example, a directory
  # containing source code.
  #
  # Such "directory-scoped" cheatsheets will be treated as the most "local"
  # cheatsheets, and will override less "local" cheatsheets. Similarly,
  # directory-scoped cheatsheets will always be editable ('readonly: false').
@adrienthiery
Copy link
Author

I actually found a workaround, which is to edit :
~/.config/cheat/conf.yml

and set a pager: as described in the comment:

# Through which pager should output be piped?
# 'less -FRX' is recommended on Unix systems
# 'more' is recommended on Windows
- pager: PAGER_PATH
+ pager: less -FRX

But thought it would be interesting to report.

Is it just my machine where PAGER_PATH is not defined by default?
Or should cheat have a default value there?

@chrisallenlane
Copy link
Member

Hi, @adrienthiery

Thanks for the bug report, and I'm sorry for the embarrassingly long delay in getting back to you.

If by chance you remember, do you know if you ran the "installer" after installing via brew? If you did not have a config file present on your machine, you should have been prompted with the following:

A config file was not found. Would you like to create one now? [Y/n]

If you choose n there, I believe you'd encounter the problem that you've described.

For context, PAGER_PATH is a template literal that is replaced by the installer:
https://github.com/cheat/cheat/blob/master/internal/installer/run.go#L29

You're correct that editing the configuration file by hand will solve the problem.

As an aside, if you're wondering why the default isn't less or more or something, that used to be the case, but I've found that neither is available on all supported platforms, so I think we might be stuck with the correct (admittedly cumbersome) solution.

Sorry once again for the delay. Thanks.

@chrisallenlane
Copy link
Member

I'm going to close this for now to remove noise from the issue-tracker, but please feel free to re-open it if you think there's more to discuss. Thanks.

@adrienthiery
Copy link
Author

I do think I used brew to install, but I don't remember a prompt.
But I did have a conf file, so maybe there was a bug during install that omitted the PAGER_PATH replacement?

Anyway, it's been working well ever since :)

@chrisallenlane
Copy link
Member

But I did have a conf file, so maybe there was a bug during install that omitted the PAGER_PATH replacement?

It's entirely possible. I vaguely remember having installer issues a while ago.

Anyway, it's been working well ever since :)

Glad to hear! I'll consider this solved for now, but I'll keep an eye open for similar issues in the future.

Thanks!

@4rc0s
Copy link

4rc0s commented Dec 15, 2023

I just had this happen on macOS (with cheat installed via homebrew some time ago). I did just upgrade to Sonoma, but that may be unrelated. Editing conf.yml manually as described above fixed the issue. Looks like the template literals weren't replaced by the installer or were reinstalled during an update.

@chrisallenlane
Copy link
Member

@4rc0s, thanks for the input. I've re-opened the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants