![]() |
#1 |
Connoisseur
![]() Posts: 59
Karma: 10
Join Date: Nov 2013
Device: Samsung Galaxy Tab 2 10.1 P5110
|
How to set CALIBRE_TEMP_DIR on Linux?
Hi all,
I want to change the temporary directory used by calibre. According to the manual: https://manual.calibre-ebook.com/customize.html this is controlled by the environment variable CALIBRE_TEMP_DIR. I did: $export CALIBRE_TEMP_DIR=/new/path/ but Calibre insists of using the old path (/tmp). How can I set CALIBRE_TEMP_DIR on Linux? Any ideas? |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,561
Karma: 204127028
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
That's only going to work for the current terminal you have open. You can't run the export command and then click on a calibre shortcut. You'd have to launch calibre from that same terminal by typing: "calibre" and hitting enter (no quotes).
Try just setting it and running calibre at the same time from a termnal: CALIBRE_TEMP_DIR=/new/path calibre If it works, you can just create a bash script to launch calibre. Or if you want something more permanent, add 'export CALIBRE_TEMP_DIR=/new/path' to the .profile file in your home directory. Then you can launch calibre however you want (after you log back in). |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Connoisseur
![]() Posts: 59
Karma: 10
Join Date: Nov 2013
Device: Samsung Galaxy Tab 2 10.1 P5110
|
Thanks for the quick response!
Try just setting it and running calibre at the same time from a termnal: CALIBRE_TEMP_DIR=/new/path calibre This has worked as you said! I haven't tried the other solution with the .profile file yet but I suppose it will work too. |
![]() |
![]() |
![]() |
#4 |
Deviser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
|
@excaliber:
Since you use ZMI, please read the section in the Original Post entitled "Special Operating System Notes". The bottom half pertains to the path for temporary files. ZMI will not work unless you do what it says about temporary files and the related Python environment variables that must be consistent with the Calibre temp file environment variable. DaltonST |
![]() |
![]() |
![]() |
#5 |
Connoisseur
![]() Posts: 59
Karma: 10
Join Date: Nov 2013
Device: Samsung Galaxy Tab 2 10.1 P5110
|
Since you use ZMI, please read the section in the Original Post entitled "Special Operating System Notes". The bottom half pertains to the path for temporary files. ZMI will not work unless you do what it says about temporary files and the related Python environment variables that must be consistent with the Calibre temp file environment variable.
I have read the "Special Operating System Notes" for ZMI. What does that mean? Am I stuck with some standard paths? Is this python, Calibre or ZMI related? I have a around 50 GB for the root partition and around 1 TB for the home partition. I think some plugins in Calibre crash because they need some GB and and there is no space. I have started Calibre now in a terminal with a count pages job and it's writing to the new temp path in my home partition. |
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Deviser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
|
It means that you have to set extra environment variables specific to Python, and they must be consistent with your Calibre environment variables. ZMI is a Calibre plug-in, so it uses Python. Temporary files in Python are put in the directory based on the environment variables for Python temporary files.
Quote:
DaltonST |
|
![]() |
![]() |
![]() |
#7 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,561
Karma: 204127028
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
|
|
![]() |
![]() |
![]() |
#8 | |
Deviser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
|
Quote:
DaltonST |
|
![]() |
![]() |
![]() |
#9 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,561
Karma: 204127028
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I'm still not following at all (but then I don't have to, either). Subprocess or no, calibredb won't know a thing about any generic Python temporary environment variables. Nor will calibre or calibre-debug. Calibre's Python (including plugins) is launched with specific instructions to ignore any outside Python environment variables. For good reason.
Never mind: My confusion lies with the fact that you keep implying that the environment variables need to be set for the PLUGIN to work. When in fact, the environment variables need to be set so your PROGRAM (and its Python subprocesses) interacts with a calibre plugin correctly. Last edited by DiapDealer; 06-28-2016 at 10:40 AM. |
![]() |
![]() |
![]() |
#10 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Of course, the calibre plugin in question could always get the temporary directory directly from calibre ('from calibre.ptempfile import base_dir') and then do whatever it wants with that. e.g. by setting that as the value of $TMP in the environment of the subprocesses. Or whatever it is the plugin is doing.
(Maybe I am missing something? It seems to be indicated that the subprocess runs calibredb. And the statement "the default temporary directory would likely be the directory where calibredb.exe exists" is just completely and utterly wrong, or else no one would ever be able to run calibre, ever. And for good measure, a third "ever".) ... For some reason, DaltonST's plugins always seem to have manual steps that should be unnecessary with a bit of automation? ![]() Last edited by eschwartz; 06-28-2016 at 11:43 AM. |
![]() |
![]() |
![]() |
#11 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,561
Karma: 204127028
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Just a WAG on my part, but I'm assuming info is being shared (via the temp directory) between his PROGRAM (which launches calibredb as a python subprocess) and his PLUGIN. So the program needs an env var set in order for his program to create files in the same place the plugin is going to look for them (or vice versa). But I agree, there has to be a better way of getting the job done than manually making sure the scratch directories of two different Python processes jive.
|
![]() |
![]() |
![]() |
#12 | |
Deviser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
|
Quote:
Assume that the user uses a RAMDISK via CALIBRE_TEMP_DIR. If ZMI used the same temporary folder as CALIBRE_TEMP_DIR, the RAMDISK could potentially overflow while ZMI is processing, for example, 15,000 .pdf files containing images and text, but all at one time (as inadvisable as that is). So, the base case is to make TMPDIR = CALIBRE_TEMP_DIR, but to handle the above scenario, they will have to make TMPDIR point to a hard drive, not to a RAMDISK. Calibre will work off of the RAMDISK, but just ZMI (a Calibre GUI plug-in) will work off of the hard drive. TMPDIR is the "goto" first choice for Python when looking for where to create a temporary file. The user could pick and choose among several other environment variables and directories, of course. That is up to them. It is just as trivial to set TMPDIR = CALIBRE_TEMP_DIR as it is trivial to set CALIBRE_TEMP_DIR = ...\some_path\... The cost is trivial, and the flexibility given the user to manage their computer resources the way they wish is extremely high. DaltonST |
|
![]() |
![]() |
![]() |
#13 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
And you could choose to import several thousand books into calibre all at once, too -- and flood the temporary directory in the same way. What is your point?
A user who uses a ramdisk for their $TMP has to be careful with or without your plugin. It makes sense to have one preference, as opposed to unnecessarily complicating the setup instructions. Or, you could just say ![]() There you go. Flexibility without any cost whatsoever. |
![]() |
![]() |
![]() |
#14 |
Deviser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
|
Generic Python defaults to the current working directory of the program executing it as a last choice to create a temporary file. In Windows, for Calibre, that is "C:\Program Files\Calibre2\". Windows would throw a security/permissions error. Windows users are 85% of Calibre users. Simply reading the Original Post section about the ins-and-outs of environment variables and doing what they want to do eliminates that issue entirely.
|
![]() |
![]() |
![]() |
#15 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Um, the default is %TEMP% which is created by your user account.
And Windows users are unlikely to have manually installed a ramdisk driver and redirected %TEMP% to it... but if they did, they would know how to deal with it. So there is no need to worry on behalf of Windows users that thousands of files will clobber their RAM. And you still haven't explained what is wrong with relying on calibre's temp dir (which must be writable for calibre to work in general, plugin or no plugin). ... But if you really, really want to impress your users by writing and enforcing complicated instructions, go right ahead. I have no beef in this, I am just commenting on what I regard as shaky logic. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Windows vs Linux Metadata Summary Lacking in Linux | TGPB | Library Management | 5 | 04-10-2014 10:56 AM |
[Linux] Calibre on Linux isn't detecting any of my Android devices | Amogh Harish | Devices | 9 | 10-31-2012 05:45 AM |
Linux calibre-server: How to set username/password? | qupfer | Calibre | 0 | 12-08-2011 04:54 PM |
Set time on Kindle keyboard with usbnetworking and linux terminal | bibiboo | Kindle Developer's Corner | 6 | 11-21-2011 02:11 AM |
Consortium is to set standards for Linux-based smartphones | Colin Dunstan | Lounge | 0 | 11-14-2005 10:31 AM |