learningequality / ka-lite

KA Lite: lightweight web server for serving core Khan Academy content (videos and exercises) without needing internet connectivity
https://learningequality.org/ka-lite/
Other
456 stars 304 forks source link

Running Ka Lite on RPi {"error": "Can only handle default language changes through POST requests"} #5468

Closed andrewclark55 closed 7 years ago

andrewclark55 commented 7 years ago

Summary

Running any Ka Lite article on RPi under RACHEL gives the following error. {"error": "Can only handle default language changes through POST requests"}

System information

Please specify the KA Lite version you were using and your operating system!

Traceback or relevant snippet from server.log

INSERT TRACEBACK, LOG MESSAGES ETC. HERE

How to reproduce

  1. Steps
  2. To
  3. Reproduce Select ANY Ka Lite article to generate this error

Have attempted to upgrade Ka Lite but that fails with errors on nginx. Admit I know nothing about how Ka Lite is constructed or maintained.

Have also tried replacing the api_views.py file as suggested. That removes the error message but leaves Ka Lite with the following showing in any article:-

" KA Lite logo Foundation for Learning Equality logo KA Lite version 0.16.9 © 2017 Videos © 2015 Khan Academy (Creative Commons) // Exercises © 2015 Khan Academy Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License"

so it is not working at all.

Screenshots

If applicable

Real-life consequences (anything community should be aware, for instance how it affects your deployment)

Can't deploy as non-working module.

If applicable

benjaoming commented 7 years ago

Hi @andrewclark55 - thanks for the report!

Can you clarify:

Have also tried replacing the api_views.py file as suggested.

What instructions are you following? I'm not familiar with the error, so I have to be clued in a bit more..

andrewclark55 commented 7 years ago

Hi Ben Thanks for responding and apologies for not making the issue clearer. My fault as I had originally posted this in response to someone else with the same error on the rachelfriends.org forum and copied it here on advice from their moderator forgetting that the context would be lost. Annoyingly I can't find my original post but here is a related one that I read from jfield on there that appears to explain the error.


jfieldMar 27 Hi Tim,

That "Can only handle default..." error is because RACHEL includes a custom multi-lingual patch for ka-lite. You can install the patch like so:

wget -q https://raw.githubusercontent.com/rachelproject/rachelplus/master/scripts/KALITE-MULTILINGUAL-api_views.py -O /usr/lib/python2.7/dist-packages/kalite/i18n/api_views.py

And then:

kalite restart

Double check the directory /usr/lib/python2.7/dist-packages/kalite/i18n/ exists -- on some installs it can be in /usr/local/lib instead.

This patch was submitted to the kalite team and included in the 0.17 release, but if you're on 0.16.x or earlier, you'll need to install it manually.


I actually manually downloaded the modified api_views.py file and renamed and replaced the one in Ka Lite so it is possible I messed up in some way e.g. with file permissions or something.

but bottom line is Ka Lite doesn't work any more and I didn't previously do anything to change it so that is a puzzle. I'm sure it was working on my RPi a few months ago as it is one of the main modules I show people in our project.

I suppose it is possible that the Ka Lite module just got corrupted on my SD card, in which case the four copies that I have sent out to Malawi may still work, but I really need to find out what caused this.

Regards Andrew

andrewclark55 commented 7 years ago

I found the post. I had actually put it here first in response to a post by Needlestack:- https://github.com/rachelproject/rachelplus/issues/68

I don't know if that throws any more light on the issue...

benjaoming commented 7 years ago

Hi @andrewclark55

re:Malawi, please do write me on benjamin@learningequality.org :)

I suppose it is possible that the Ka Lite module just got corrupted on my SD card

Anything is possible, but the software files of KA Lite are installed in your system's /usr hierarchy so in case something go corrupted, the chances that only KA Lite would fail are microscopic.

but bottom line is Ka Lite doesn't work any more and I didn't previously do anything to change it so that is a puzzle. I'm sure it was working on my RPi a few months ago as it is one of the main modules I show people in our project.

When changing files and requesting support like this, it's really vital that you know exactly what's going on. Otherwise it'll take way too much time. I'm not a fan of the way things are patched in RACHEL, but I sympathize with their reasons.. but it seems now that you've modified something that was already patched in ways I'm not familiar with, moreover receiving error messages that don't come from the original codebase.

I would suggest that you do sudo apt-get purge 'ka-lite*' in order to remove KA Lite entirely, and make sure somehow that everything (except your data in ~/.kalite) is wiped. Then try installing the 0.16.9 release again (or one of the newer releases).

andrewclark55 commented 7 years ago

Hi Ben OK, just to get back to a position where you might be able to offer some support I have restored the card back from the Win32 image backup that I used to create all our SD RACHEL server copies. All the main modules of RACHEL work fine (excepting Music Theory and Powertyping that fail with "Couldn't load Plugin" but that is normal). KA Lite still doesn't work - same error. I'm happy to follow your guidance on repairing this by purging the module but I have never tried loading KA Lite from scratch so would need some instructions to do that. If we can get a solution in this manner I will then document it as we will then have to follow the same procedure in Malawi for the copies I have sent out. Regards Andrew

benjaoming commented 7 years ago

@andrewclark55

Cool, let's stay in touch on the Malawi thing! :)

I'm not familiar really with the codebase of RACHEL, so it's hard to guess about this for me.

Are you saying 1) It used to work and now it doesn't or 2) It never worked? Also, in case of 1) - are you saying 1.1) It used to work, and I haven't modified anything and now it doesn't? or 1.2) It used to work, but I need help figuring out why it has stopped working?

One thing that strikes me as odd is the error message itself + I suppose KA Lite works out-of-the-box on RACHEL. Try perhaps wiping the cache in your browser or displaying KA Lite with a different browser? Could be your browser is requesting a language that doesn't exist in the installation?

benjaoming commented 7 years ago

I'm happy to follow your guidance on repairing this by purging the module but I have never tried loading KA Lite from scratch so would need some instructions to do that.

Loading KA Lite from scratch is everything our documentation is about :) But I don't know about how to go about purging the RACHEL version entirely. Try the command I put sudo apt-get purge 'ka-lite*', and then try installing ka-lite-raspberry-pi 0.17 version as per docs: http://ka-lite.readthedocs.io/en/0.17.x/installguide/tutorial_rpi.html

andrewclark55 commented 7 years ago

Ben

Just working my way through your instructions but fell at first hurdle!

sudo apt-get purge 'ka-lite*' gives

E: Unable to locate package ka-lite*

Also tried it without the * but no go.

Starting to wonder if this really worked before on this build…

Can we try proceeding as a new install and see what happens?

Regards Andrew

From: Benjamin Bach [mailto:notifications@github.com] Sent: 08 June 2017 00:34 To: learningequality/ka-lite ka-lite@noreply.github.com

Subject: Re: [learningequality/ka-lite] Running Ka Lite on RPi {"error": "Can only handle default language changes through POST requests"} (#5468)

I'm happy to follow your guidance on repairing this by purging the module but I have never tried loading KA Lite from scratch so would need some instructions to do that.

Loading KA Lite from scratch is everything our documentation is about :) But my challenge would be about how to go about purging the RACHEL version entirely. Try the command I put sudo apt-get purge 'ka-lite*', and then try installing ka-lite-raspberry-pi 0.17 version as per docs: http://ka-lite.readthedocs.io/en/0.17.x/installguide/tutorial_rpi.html

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/learningequality/ka-lite/issues/5468#issuecomment-306955494, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AbuVurzpoqgJGI8bEWB9iQPFyo5BIjvQks5sBzNcgaJpZM4Nqy2i.

andrewclark55 commented 7 years ago

OK, so having discovered that ka-lite does not seem to be there I went ahead to try installing it according to the documentation that you pointed me to.

It failed on the second command-line instruction. Here is a copy of the whole thing:-

pi@rachel:~ $ sudo apt-get install python-m2crypto python-pkg-resources nginx python-psutil Reading package lists... Done Building dependency tree Reading state information... Done python-pkg-resources is already the newest version. python-pkg-resources set to manually installed. The following extra packages will be installed: nginx-common nginx-full Suggested packages: fcgiwrap nginx-doc The following NEW packages will be installed: nginx nginx-common nginx-full python-m2crypto python-psutil 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 801 kB of archives. After this operation, 2,449 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main nginx-common all 1.6.2-5+deb8u4 [88.1 kB] Get:2 http://mirrordirector.raspbian.org/raspbian/ jessie/main nginx-full armhf 1.6.2-5+deb8u4 [375 kB] Get:3 http://mirrordirector.raspbian.org/raspbian/ jessie/main nginx all 1.6.2-5+deb8u4 [72.6 kB] Get:4 http://mirrordirector.raspbian.org/raspbian/ jessie/main python-m2crypto armhf 0.21.1-3 [149 kB] Get:5 http://mirrordirector.raspbian.org/raspbian/ jessie/main python-psutil armhf 2.1.1-1 [116 kB] Fetched 801 kB in 1s (717 kB/s) Preconfiguring packages ... Selecting previously unselected package nginx-common. (Reading database ... 127433 files and directories currently installed.) Preparing to unpack .../nginx-common_1.6.2-5+deb8u4_all.deb ... Unpacking nginx-common (1.6.2-5+deb8u4) ... Selecting previously unselected package nginx-full. Preparing to unpack .../nginx-full_1.6.2-5+deb8u4_armhf.deb ... Unpacking nginx-full (1.6.2-5+deb8u4) ... Selecting previously unselected package nginx. Preparing to unpack .../nginx_1.6.2-5+deb8u4_all.deb ... Unpacking nginx (1.6.2-5+deb8u4) ... Selecting previously unselected package python-m2crypto. Preparing to unpack .../python-m2crypto_0.21.1-3_armhf.deb ... Unpacking python-m2crypto (0.21.1-3) ... Selecting previously unselected package python-psutil. Preparing to unpack .../python-psutil_2.1.1-1_armhf.deb ... Unpacking python-psutil (2.1.1-1) ... Processing triggers for systemd (215-17+deb8u5) ... Processing triggers for man-db (2.7.0.2-5) ... Setting up nginx-common (1.6.2-5+deb8u4) ... Setting up nginx-full (1.6.2-5+deb8u4) ... Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details. invoke-rc.d: initscript nginx, action "start" failed. dpkg: error processing package nginx-full (--configure): subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of nginx: nginx depends on nginx-full (>= 1.6.2-5+deb8u4) | nginx-light (>= 1.6.2-5+deb8u4) | nginx-extras (>= 1.6.2-5+deb8u4); however: Package nginx-full is not configured yet. Package nginx-light is not installed. Package nginx-extras is not installed. nginx depends on nginx-full (<< 1.6.2-5+deb8u4.1~) | nginx-light (<< 1.6.2-5+deb8u4.1~) | nginx-extras (<< 1.6.2-5+deb8u4.1~); however: Package nginx-full is not configured yet. Package nginx-light is not installed. Package nginx-extras is not installed.

dpkg: error processing package nginx (--configure): dependency problems - leaving unconfigured Setting up python-m2crypto (0.21.1-3) ... Setting up python-psutil (2.1.1-1) ... Processing triggers for systemd (215-17+deb8u5) ... Errors were encountered while processing: nginx-full nginx E: Sub-process /usr/bin/dpkg returned an error code (1)


sudo wget https://learningequality.org/r/deb-pi-installer-0-17 --no-check-certificate --content-disposition


pi@rachel:~ $ sudo dpkg -i ka-lite-raspberry-pi*.deb Selecting previously unselected package ka-lite-raspberry-pi. dpkg: regarding ka-lite-raspberry-pi_0.17.1-0ubuntu1_all.deb containing ka-lite-raspberry-pi, pre-dependency problem: ka-lite-raspberry-pi pre-depends on nginx-light (>= 1.1.19) | nginx (>= 1.1.19) | nginx-full (>= 1.1.19) nginx-light is not installed. nginx is unpacked, but has never been configured. nginx-full is unpacked, but has never been configured.

dpkg: error processing archive ka-lite-raspberry-pi_0.17.1-0ubuntu1_all.deb (--install): pre-dependency problem - not installing ka-lite-raspberry-pi Errors were encountered while processing: ka-lite-raspberry-pi_0.17.1-0ubuntu1_all.deb

So, being a non-Guru with Linux I’ll have to ask you if you can figure what is wrong here!

Regards Andrew

From: Benjamin Bach [mailto:notifications@github.com] Sent: 08 June 2017 00:34 To: learningequality/ka-lite ka-lite@noreply.github.com

Subject: Re: [learningequality/ka-lite] Running Ka Lite on RPi {"error": "Can only handle default language changes through POST requests"} (#5468)

I'm happy to follow your guidance on repairing this by purging the module but I have never tried loading KA Lite from scratch so would need some instructions to do that.

Loading KA Lite from scratch is everything our documentation is about :) But my challenge would be about how to go about purging the RACHEL version entirely. Try the command I put sudo apt-get purge 'ka-lite*', and then try installing ka-lite-raspberry-pi 0.17 version as per docs: http://ka-lite.readthedocs.io/en/0.17.x/installguide/tutorial_rpi.html

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/learningequality/ka-lite/issues/5468#issuecomment-306955494, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AbuVurzpoqgJGI8bEWB9iQPFyo5BIjvQks5sBzNcgaJpZM4Nqy2i.

benjaoming commented 7 years ago

@andrewclark55

Alright, a general thing: If a step fails, don't proceed to the next step. You have to solve the problems systematically in the order that the steps indicate. You can't install the ka-lite-raspberry-pi before installing its dependencies (unless you use the PPA installation method). When Nginx fails to install, so will ka-lite-raspberry-pi.

E: Unable to locate package ka-lite*

Run this command instead (without the apostrophe): sudo apt-get purge ka-lite*

Now, when the RACHEL KA Lite has been successfully purged, at least there's a good chance there won't be files left on your system blocking a fresh installation.

Regarding the failed Nginx installation, there's this error:

Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details. invoke-rc.d: initscript nginx, action "start" failed. dpkg: error processing package nginx-full (--configure): subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of nginx:

During the installation, Nginx fails to start. There's a problem in your Nginx configuration and it's left marked as not properly installed.

I suggest you try to do apt-get purge nginx* as well. After that, do sudo rm -rf /etc/nginx to make sure it doesn't have configuration files left (those that would cause it to fail to start!). If you have problems purging Nginx (or any other package) because it's not properly installed, then search the web, there's also answers for this.

But we're in a bit of deep water here. I can't proceed with this support request, please ask the RACHEL community forums: http://community.rachelfriends.org/

andrewclark55 commented 7 years ago

Ben

OK. Thanks for the heads up. I’ll try and find time tomorrow to follow your suggestions.

And respond re the Other Thing…

Regards Andrew

From: Benjamin Bach [mailto:notifications@github.com] Sent: 08 June 2017 22:37 To: learningequality/ka-lite ka-lite@noreply.github.com

Subject: Re: [learningequality/ka-lite] Running Ka Lite on RPi {"error": "Can only handle default language changes through POST requests"} (#5468)

@andrewclark55https://github.com/andrewclark55

Alright, a general thing: If a step fails, don't proceed to the next step. You have to solve the problems systematically in the order that the steps indicate. You can't install the ka-lite-raspberry-pi before installing its dependencies (unless you use the PPA installation method). When Nginx fails to install, so will ka-lite-raspberry-pi.

E: Unable to locate package ka-lite*

Run this command instead (without the apostrophe): sudo apt-get purge ka-lite*

Now, when the RACHEL KA Lite has been successfully purged, at least there's a good chance there won't be files left on your system blocking a fresh installation.

Regarding the failed Nginx installation, there's this error:

Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details. invoke-rc.d: initscript nginx, action "start" failed. dpkg: error processing package nginx-full (--configure): subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of nginx:

During the installation, Nginx fails to start. There's a problem in your Nginx configuration and it's left marked as not properly installed.

I suggest you try to do apt-get purge nginx* as well. After that, do sudo rm -rf /etc/nginx to make sure it doesn't have configuration files left (those that would cause it to fail to start!). If you have problems purging Nginx (or any other package) because it's not properly installed, then search the web, there's also answers for this.

But we're in a bit of deep water here. I can't proceed with this support request, please ask the RACHEL community forums: http://community.rachelfriends.org/

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/learningequality/ka-lite/issues/5468#issuecomment-307234511, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AbuVunPEbwSNYa0aLSyjQK-4ASLMyRU4ks5sCGlxgaJpZM4Nqy2i.