gleitz / howdoi

instant coding answers via the command line
http://blog.gleitzman.com/post/43330157197/howdoi-instant-coding-answers-via-the-command-line
MIT License
10.57k stars 868 forks source link

ERROR: Sorry, couldn't find any help with that topic (use --explain to learn why) #489

Open wasertech opened 10 months ago

wasertech commented 10 months ago

What happened:

❯ howdoi show my ip for ssh
ERROR: Sorry, couldn't find any help with that topic (use --explain to learn why) 

What you expected to happen:

An answer of some sort. Like ip address show or even ifconfig or something.

Output with --explain

Please provide the output of running the same command with the --explain flag like so

Click here to expand the logs ```text ❯ howdoi show my ip for ssh --explain INFO: Version: 2.0.20 INFO: Fetching answers for query: show my ip for ssh INFO: Using cached links INFO: No StackOverflow links found in cached search engine results - will make live query INFO: Searching google with URL: https://www.google.com/search?q=site:stackoverflow.com%20show%20my%20ip%20for%20ssh&hl=en INFO: Search engine google found no StackOverflow links, returned HTML is: INFO: Before you continue to Google Search

Before you continue to Google

We use cookies and data to

  • Deliver and maintain Google services
  • Track outages and protect against spam, fraud, and abuse
  • Measure audience engagement and site statistics to understand how our services are used and enhance the quality of those services

If you choose to “Accept all,” we will also use cookies and data to

  • Develop and improve new services
  • Deliver and measure the effectiveness of ads
  • Show personalized content, depending on your settings
  • Show personalized ads, depending on your settings

If you choose to “Reject all,” we will not use cookies for these additional purposes.

Non-personalized content is influenced by things like the content you’re currently viewing, activity in your active Search session, and your location. Non-personalized ads are influenced by the content you’re currently viewing and your general location. Personalized content and ads can also include more relevant results, recommendations, and tailored ads based on past activity from this browser, like previous Google searches. We also use cookies and data to tailor the experience to be age-appropriate, if relevant.

Select “More options” to see additional information, including details about managing your privacy settings. You can also visit g.co/privacytools at any time.

ERROR: Sorry, couldn't find any help with that topic ```

Using howdoi from the AUR:

❯ pacman -Q | grep howdoi
howdoi 2.0.20-2
SamueleFacenda commented 9 months ago

Same with the program installed from nix (latest version). The result page for me is the fullscreen google cookie consent request page(it's always asked the first time you use google).

gleitz commented 9 months ago

Are you in the US, or another country? I hear that people can get this error outside the US or from machines that don't have cookies set from Google.

SamueleFacenda commented 9 months ago

I'm in Italy, the european privacy regulation is very strict so probably this is the cause.

gleitz commented 9 months ago

Thanks for letting me know. If you can figure out a way to accept the cookies I would accept a pull request. It seems to impact many people.

wasertech commented 9 months ago

I find using beautifulsoup is very unreliable as your search engine provider can break it at any moment. I had more luck in the past using hanapin + trafilatura + QALM in my WebSearch Domain for RASA but nowadays with LLMs, I just use GitHub Copilot CLI to do that with a few stupid simple aliases and some function in CodePilot.

❯ which howdoi
howdoi () {
        if [[ $# -eq 0 ]]
        then
                echo "Usage: howdoi <question>"
                return 1
        else
                gh copilot explain "How do I $@ ?"
        fi
        return 0
}
❯ howdoi show my ip for ssh

Welcome to GitHub Copilot in the CLI!
version 0.5.3-beta (2023-11-09)

I'm powered by AI, so surprises and mistakes are possible. Make sure to verify any generated code or suggestions, and share feedback so that we can learn and improve.

Explanation:                                                                    

  To display your IP address for SSH, you can run the following command:        

  • curl -s ifconfig.me: This uses curl to issue a web request to ifconfig.me and
  retrieves your public IP address. The -s flag is used to suppress the progress
  meter and only display the IP address.                                        

  Alternatively, you can use other services such as:                            

  • curl -s checkip.amazonaws.com: This uses curl to retrieve your public IP    
  address from the checkip.amazonaws.com service.                               

  Please note that these commands will display your public IP address, which    
  might be different from your local/private IP address within your network.
ingles98 commented 9 months ago

Hey, fellow European here, anyone has found a workaround?

ingles98 commented 9 months ago

Ok, after a bit of messing, I have a workaround.

Apparently google no longer cares about the CONSENT COOKIE, you want to use the SOCS one.

I edited the source code directly (do "which howdoi" and cat the path provided to check where the source is for your case)

On howdoi.py, line 182 _get_result(url) function, add a SOCS cookie from your own browser. I am unsure how ephemeral this cookie is so perhaps a better solution is needed, and one that is embedded upstream I guess.

All things considered, howdoi should not be expected to grab cookies from your browser as that would be potentially malicious behaviour, I will let the wizards work out their magic as to how to provide some functionality for us European cookie 🍪 nerds

tin-ot commented 5 months ago

Hello, As a workaround I fetch answers from duckduckgo instead of google.

export HOWDOI_SEARCH_ENGINE=duckduckgo

( btw in linux to get the current vm's ip : ip -br -4 a )

'wizards work out their magic' haha what does it mean ?