idank / explainshell

match command-line arguments to their help text
GNU General Public License v3.0
13.17k stars 787 forks source link

Docker Version Broken - Unsupported OP_QUERY command: count #310

Closed abcarroll closed 1 year ago

abcarroll commented 1 year ago

First & foremost, I am a little confused about the dockerfile, and docker compose file, along with the given documentation. I really don't understand what all I am suppose to do: that is, is the mongodb restore even necessary? And, if so, could it not be included in the dockerfile/docker-compose? ... (If so, I would certainly volunteer to improve this)

However, regardless, I am getting some errors when running the local setup. I followed the instructions precisely, with something along the lines of

git clone .... 
cd explainshell
docker-compose build
docker-compose up
docker cp dump/ explainshell_db_1:/tmp/dump
docker exec explainshell_db_1 mongorestore /tmp/dump

And, the initial page loads fine and even some things are explained. However, some links are completely broken, rendering:

ERROR!
something went wrong... this was logged and will be checked

When hitting the URL:

GET /explain?cmd=echo+%60basename+%22%24file%22%60 HTTP/1.1

The error appears to be:

web_1  | OperationFailure: command SON([('count', u'mapping'), ('fields', None), ('query', {'src': u'echo'})]) failed: Unsupported OP_QUERY command: count. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal

I've attached a text file with the full backtrace. I would offer more than just a complaint here, however both Python & MongoDB are at the bottom of list of things I'm well versed in.

Any help would be appreciated. Thanks!

Backtrace: error.txt

idank commented 1 year ago

Looks like pymongo is pinned to an old version while the mongodb version in docker compose is using the latest image available.

You can try changing pymongo==2.6 to just pymongo in requirements.txt and see if using the latest version of pymongo works. I haven't tested that so if there were breaking changes in the library (I'm going to bet on a yes on this one), that might need to be fixed as well.

Amueller36 commented 1 year ago

I tried out the approach with the pymongo @idank but it didn't help me atleast. Can't look up anything in the local explainshell.

idank commented 1 year ago

Ok I fixed a few things and just went through this workflow and it worked for me (pull before):

DB=explainshell-db-1

# download db dump
curl -L -o /tmp/dump.tar.gz https://github.com/idank/explainshell/releases/download/db-dump/archive.tar.gz
tar xzvf /tmp/dump.tar.gz -C /tmp/

# start containers, restore from dump
docker-compose build
docker-compose up
docker cp /tmp/db.backup/ $DB:/tmp/dump
docker exec $DB mongorestore /tmp/dump

Give this a try and let me know if that works for you.

Amueller36 commented 1 year ago

Last command fails for me image

idank commented 1 year ago

Hmm I'm not sure what's going on there with the Windows looking path. Try to exec into the container and see if it copied the files over, something like docker exec -it $DB bash, ls -la /tmp/dump.