WeBWorK Main Forum

WeBWorK Hardcopy generation

WeBWorK Hardcopy generation

by Wesley Burr -
Number of replies: 18
I have a (mostly) functioning installation of WeBWorK that I'm using in our large first-year statistics course, but there's a few niggling things not working with it, and I'm hoping you folks can assist me with fixing them.

First is hardcopy generation. For a given assignment, if I click "Generate Hardcopy", nothing seems to happen: it simply gives the message (after ~ 4 seconds) "WeBWorK was unable to generate a paper copy of this homework set. Please inform your instructor."

I went through the Troubleshooting Hardcopy wiki, enabled PreserveTempFiles, and checked to make sure that: a) pdflatex is working (it is), and b) that the configuration for WeBWorK points to the correct binaries (it does). But nothing shows up in the /html/tmp/ directory at all: it's like it isn't even getting that far.

Suggestions for what to try are quite welcome. I feel like I'm debugging blind, so I'm at a loss as to how to proceed, with no temporary files and no output, but a clear failure to execute.

In reply to Wesley Burr

Re: WeBWorK Hardcopy generation

by Danny Glin -
Is that the extent of the error message you get?

A couple of things to check:
  • Look at the apache error log to see if there is a more verbose error there.
  • Check the permissions on the directories. If apache can't write to the temp directory, then you would get behaviour like this.
In reply to Danny Glin

Re: WeBWorK Hardcopy generation

by Wesley Burr -
drwxr-sr-x 2 apache wwdata 4096 Jul 4 17:23 achievements
drwxr-sr-x 2 apache wwdata 6 Jul 4 17:23 images
drwxr-sr-x 2 apache wwdata 6 Sep 10 13:15 tmp

Permissions look fine. Nothing in error_log from WeBWorK in the last hour (when I've been testing the hardcopy). access_log shows the attempts to render (since hardcopy is in the URL, the fgrep picks it up).

In reply to Wesley Burr

Re: WeBWorK Hardcopy generation

by Michael Gage -
If I remember correctly the hardcopy output is assembled in the
webwork2/DATA directory. The files are then deleted unless you disable that feature. Sounds like you have disabled that feature so you should find some tex files in DATA. You can then test those files from the command line to see what is going wrong.

If it's a permission problem remember that you and the apache server might have different permissions. Sometimes switching to be the "user" that represents the apache server can help.
In reply to Michael Gage

Re: WeBWorK Hardcopy generation

by Wesley Burr -
Interestingly, there is nothing in /DATA/ at all for this course, except an empty /mailmerge. This is quite confusing.
In reply to Wesley Burr

Re: WeBWorK Hardcopy generation

by Arnold Pizer -
Hi,

The debugging instructions
http://webwork.maa.org/wiki/Installation_Manual_for_2.13_on_Ubuntu_16.04#Test_that_Things_are_Working_Properly
state

Edit the file Constants.pm in the directory /opt/webwork/webwork2/lib/WeBWorK. Change the line $WeBWorK::PG::ImageGenerator::PreserveTempFiles = 0; to ...::PreserveTempFiles = 1;. Then restart Apache and view the first couple problems or some new ones. Then look in the directory /opt/webwork/webwork2/tmp/. cd to one of the ImageGenerator.../tmp/ directories and look at the error and log files there. When you fix the problem remember to edit ...::PreserveTempFiles = 1; back to 0 and restart Apache or you will be saving a lot of unnecessary files.

Note that if you set up a wwtmp directory then the files will be saved under that directory in a work.???? directory under courseName/Hardcopy/

Arnie
In reply to Michael Gage

Re: WeBWorK Hardcopy generation

by Michael Gage -
Arnie is right -- the assembly takes place in webwork2/tmp not webwork2/DATA.  Sorry about that. 
In reply to Michael Gage

Re: WeBWorK Hardcopy generation

by Danny Glin -
Note that this is /opt/webwork/webwork2/tmp, and not a course-specific tmp directory. Make sure that this directory is writeable by apache.
In reply to Danny Glin

Re: WeBWorK Hardcopy generation

by Arnold Pizer -
Hi,

Almost certainly you will find the preserved log files in the above location. But just to be precise for others who may be reading this in the future, the files will be in a subdirectory of the directory specified by $courseDirs{html_temp}. This is set in the defaults.conf file in/opt/webwork/webwork2/conf. That location may be changed in the file localOverrides.conf residing in the same location. It is very unlikely but possible for this to be changed for an individual course in the course.conf file which resides in a courses main directory (usually /opt/webwork/courses/course_name/).

Arnie
In reply to Wesley Burr

Re: WeBWorK Hardcopy generation

by Wesley Burr -
As various posters (thanks for the help, btw) have suggested, I have verified the following:

1. In Constants.pm: $WeBWorK::PG::ImageGenerator::PreserveTempFiles = 1;
2. Restarted Apache.
3. Checked /opt/webwork/webwork2/tmp - the directory is owned by root (wwdata group), but is world read/write/executable:

drwxrwsr-x 2 root wwdata 19 Sep 11 13:00 tmp

Just to make sure, I re-set the permissions:

# chgrp wwdata tmp
# chmod g+w tmp

but, as expected, it's still

drwxrwsr-x 2 root wwdata 19 Sep 11 13:00 tmp

4. There's no content in /tmp at the moment. I attempted to render a hardcopy again, fresh, after purging the logs, and no Apache error occurred that was logged, nothing showed up in /webwork2/tmp or /webwork2/DATA, and the same message as my first message appeared:

WeBWorK was unable to generate a paper copy of this homework set. Please inform your instructor.

Further thoughts?


In reply to Wesley Burr

Re: WeBWorK Hardcopy generation

by Arnold Pizer -
Hi,

I would first try running pdflatex to make sure it is OK. Then su to whatever user apache is running as (e.g. www-data on Ubuntu) and then run pdflatex again to make sure apache can run it.

Arnie
In reply to Arnold Pizer

Re: WeBWorK Hardcopy generation

by Michael Gage -
Try
chmod 777 tmp

just to eliminate the permissions problem. The webserver needs to be able to write into the directory tmp. If the webserver is in the group wwdata it _should_ be able to do so but .....


In reply to Wesley Burr

Re: WeBWorK Hardcopy generation

by Arnold Pizer -
Hi,

I thought I posted this but I guess not. Two more things to try are
(1) Change the Hardcopy Format to "TeX Source"
(2) Look at
http://webwork.maa.org/wiki/Installation_Manual_for_2.13_on_Ubuntu_16.04#Checking_Module_Dependencies
and run (both as you as as Apache)
pdflatex /opt/webwork/webwork2/bin/check_latex.tex
In reply to Arnold Pizer

Re: WeBWorK Hardcopy generation

by Wesley Burr -
Thanks for this post, Arnold. It gave me the first identifiable errors I've seen (instead of radio silence). I'm poking at my texlive install now to try to ensure it's working properly, as it is failing to compile that check_latex.tex file. It runs, both as root and apache's ID, but it's missing certain CTAN packages (like path.sty) which I've found other threads on.

Now that I know what to look for ... !

I'll update when I actually know more, and if I get this working, I'll add the troubleshooting steps to the Wiki so anyone who hits this in future knows what's going on.
In reply to Wesley Burr

Re: WeBWorK Hardcopy generation

by Arnold Pizer -
Hi Wesley,

I'm glad you are making progress. When you report back please tell the community what OS you are using (and what packages are required by that OS) and also how you installed WeBWorK. E.g the install script "should" install all needed packages and following the instructions for Ubuntu 16.04 do in fact (at least when I tested) give all required packages.

Good luck and thanks in advance,

Arnie
In reply to Arnold Pizer

Re: WeBWorK Hardcopy generation

by D. Brian Walton -
One of out IT departments setup a server (v2.12) I'm testing and I'm having similar issues in that the hard-copy doesn't generate.

In problem sets where I have left the header as "defaultHeader", I get the following error for many of my problem sets:
Undefined subroutine &main::avg_problem_grader called at (eval 5345) line 358.
I'm not sure what about the header file makes this a problem.

If I then modify the set to use the standard setHeader.pg for hardcopy, then I instead get an error about missing the "path.sty" package. The server is running on a VM using some Linux version.

I'll have to contact those who maintain the server about checking the LaTeX distribution, but I'm curious about the issue with the default header file as well.

- Brian

In reply to D. Brian Walton

Re: WeBWorK Hardcopy generation

by Danny Glin -
This sounds like two independent problems.

The path.sty problem should be solvable by installing the right LaTeX package, though I don't remember off hand what you need to install.

The avg_problem_grader issue seems odd. Do you get this error when you view any of the problems in the set? When you say the standard setHeader.pg, is this different from the default header file? It's also worth checking to see that you are running the same versions of pg and WeBWorK.
In reply to Arnold Pizer

Re: WeBWorK Hardcopy generation

by Wesley Burr -
Hi, all,

I had a wonderful long message typed up, but then the authentication broke, and it dumped my message. So, here's the short and skinny:

* it was texlive causing the issues
* CentOS includes a version of texlive that's snap-shotted, not particularly good, and doesn't support the full TUG list of packages
* this was causing pdflatex to fail because it couldn't find the path package

Solution:

* manually install texlive-2017
* change all user paths to point to these binaries instead of the yum installed ones (because if you uninstall the yum one, it also deletes R from the system, which I need)
* go into WW configuration (site.conf), and point directly to the three binaries needed (pdflatex, latex and dvipng)
* test

And it works! Not flawlessly, but it's just minor stuff at this point.

I will try to update the wiki on these issues to bring Arnie's suggestion of testing the check_latex.tex file before anything else. I did install WW with the usual script, and it seemed to complete fine, but I must have missed something failing in there. If I get a chance, I'll try a fresh install onto a fresh CentOS VM and see what happens if texlive-2017 (with path) isn't installed. It'd be good to be able to warn people in advance.

Thanks again for all of the help, this issue is sorted.
In reply to Wesley Burr

Re: WeBWorK Hardcopy generation

by Danny Glin -
One more thing to check occurred to me: make sure site.conf has the right path to the pdflatex binary on your system. WeBWorK is expecting it to be at /usr/bin/pdflatex. If it is somewhere else, you will have to change the entry in site.conf.