I posted this in the OPL maintenance subforum, but not sure if that was a good place. Anyway, I am having issues with running OPL-update.
I get an error that state WEBWORK_ROOT is undefined. After looking thru the wiki, I saw that I should have some export commands in the .bashrc file.
I went ahead and added these three export lines. Including one for WEBWORK_ROOT. Im still getting the same error. Here are those export lines I added to the end of the .bashrc files for both root and my user.
I'm no longer getting the WEBWORK_ROOT error. However, we have new errors.
When I type ./OPL-update, I get an error now that the file does not exist. If I type $ sudo OPL-update, I get file not found error.However, If I type OPL-update (without sudo) I get the following:
Library version is 2.5; using OPLtables!
Mysql database reinitialized.
Reading in textbook data from Textbooks in the library /opt/webwork/libraries/webwork-open-problem-library/OpenProblemLibrary.
Reading in OPL taxonomy from Taxonomy2 in the library /opt/webwork/libraries/webwork-open-problem-library/OpenProblemLibrary.
Cannot open /opt/webwork/webwork2/htdocs/DATA/tagging-taxonomy.json at /opt/webwork/webwork2/bin/OPL-update line 516.
What are the appropriate commands to use to get my OPL-update to work so that I can get the latest set of library problems? We were able to get this to work during the web conference, but has not worked since.
You can look at
Note that you might have to do some preliminary stuff, e.g.
which you found. Also note that file permissions, etc are set up so that the user "wwadmin" can do things. If you had to be root to run OPL-update, then probably you didn't set things up so that the user you logged in as has permission to do things.
As you notice you need the WEBWORK_ROOT variable in your environment. You also need to permission to write to various directories, including htdocs/DATA.
If you use sudo, you are temporarily using the "root" .bashrc which probably doesn't have the WEBWORK_ROOT variable initialized. One way around this is to use
sudo -E ./OPL-update
The -E flag means use your own .bashrc file to initialize variables and aliases but also allows you root privileges for that command which means you have access to directories that you normally would not have access to.
Hope this helps.
A couple of corrections to Mike's post:
When you sudo a command, by default (on most systems) very few environment variables are passed to the command. This is to increase security. This means that sudo doesn't know of any custom environment variables such as WEBWORK_ROOT, regardless of whose .bashrc file they are stored in.
There are two fixes to the problem that you describe: one is to make sure that the user running OPL-update has permission to write to all of the relevant directories. In most WeBWorK installations, this means making sure that your user is in the same group as the web server, and that these directories are owned and writeable by that group.
The second solution is as Mike describes, which is to use sudo -E. One detail is that the -E flag doesn't read the .bashrc file, but simply uses the current environment when running the command (i.e. all of the variables that are set for the current user). This means that if you were to run
sudo -E ./OPL-update
it should work even if WEBWORK_ROOT is not set in your .bashrc file.
One last comment: the .bashrc file is typically only read when a new session is started, so if you add things to .bashrc, you will typically have to log out and log back in before they take effect.