davidkus / triviacrack-client

Command line client and bot for Trivia Crack.
MIT License
1 stars 0 forks source link

kernel_require.rb:55:in `require': cannot load such file -- triviacrack (LoadError) #1

Closed samcro1967 closed 5 years ago

samcro1967 commented 5 years ago

I am not having any luck getting it to run. I built it using "$ docker build -t triviacrack .". I deployed it using "docker run -d -e EMAIL=user@email.com -e PASSWORD=Password123 trviaicrack".

The container starts and stays running. The logs are empty. I can connect to it with using the image ID with "docker exec -it 62889645b7cc bash" Executing "bin/trivia-crack bot -e user@email.com -p Password123" then errors out. Errors below. Not sure if I am doing something wrong or did not set it up correctly.

root@62889645b7cc:/code# bin/trivia-crack bot -e user@email.com -p Password123 /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- triviacrack (LoadError) from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:inrequire' from /code/lib/triviacrack/client/bot.rb:1:in <top (required)>' from /code/lib/triviacrack/client.rb:3:inrequire_relative' from /code/lib/triviacrack/client.rb:3:in <top (required)>' from bin/trivia-crack:5:inrequire_relative' from bin/trivia-crack:5:in `

' root@62889645b7cc:/code#

davidkus commented 5 years ago

Hey,

Sorry I took so long to get back to you, I don't really keep track of this project anymore. I've looked into this issue and was able to reproduce it. I believe we're running into this issue: https://stackoverflow.com/questions/36047575/unable-to-require-gem-from-git-with-rvm

To get around this, I've published my triviacrack gem to rubygems.org, and update the dependencies for this repo to point to that instead of the git repo. If you pull the latest changes, it should work.

samcro1967 commented 5 years ago

Yes, that seems to have fixed it. Appreciated.

One other question. How do you pass in parameters other than email and password? Their format seems to be a bit different than email and password and just using -e does not seem to be working. Would just like the BOT to complete any active games, not start any new, and exit when done. I thought the below would do it.

docker run -d --name triviacrack -e no-start-new-games -e no-forever e EMAIL=email -e PASSWORD=password triviacrack

davidkus commented 5 years ago

Hey,

From the Dockerfile:

CMD bundle exec bin/trivia-crack bot -e $EMAIL -p $PASSWORD -n -f

So when running it via docker, you can only provide a password and email. And it will, by default, start new games and loop forever. You could modify the Dockerfile locally if you'd like to change this (just remove the -n -f and then rebuild the image with docker build -t triviacrack ..

Unfortunately, there's no way to get it to exit when done, as the -f option only sets it to restart if exceptions are thrown. Without the -f, it will still loop forever (and not exit).

davidkus commented 5 years ago

Just to add, if you do want it to exit when done, you could modify lib/triviacrack/client/bot.rb to remove the loop on line 34. Without that loop it will exit once it has completed all games.

samcro1967 commented 5 years ago

Removing the -n and -f from the dockerfile prevented it from starting new games.

Adding a hashtag before the loop statement on line 34 and before the corresponding closing end on line 52 does not cause it to exit once all games are played. I also tried commenting out everything in between and then no games are played which is what I kind of expected to happen.

Another weird thing is the container always restarts itself if I manually stop it. I used "docker create --name triviacrack --restart=no" to create the container. I also have watchtower stop and disabled. I think this is a Docker thing, but have not figured out yet where additional auto restart config is.