ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Set luatex cache directory path
@ 2021-04-05 22:19 Thangalin
  2021-04-06  7:31 ` Aditya Mahajan
  0 siblings, 1 reply; 9+ messages in thread
From: Thangalin @ 2021-04-05 22:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 620 bytes --]

Peter Münster once asked:

> What should I do please, to prevent ConTeXt from creating
$HOME/luatex-cache?

I'd like to do the same:

$ cd $HOME
$ ls luatex-cache
ls: cannot access 'luatex-cache': No such file or directory
$ context test.tex
$ ls luatex-cache/
context
$ rm -rf luatex-cache
$ export TEXMFCACHE=/tmp
$ context test.tex
mtxrun          | unknown script 'mtx-context.lua' or 'mtx-mtx-context.lua'
$ export TEXMFCACHE=
$ context --version
...
mtx-context     | current version: 2021.03.31 18:04

What environment variable must change to set the luatex-cache directory?

Thank you!

[-- Attachment #1.2: Type: text/html, Size: 868 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Set luatex cache directory path
  2021-04-05 22:19 Set luatex cache directory path Thangalin
@ 2021-04-06  7:31 ` Aditya Mahajan
  2021-04-06 18:59   ` Thangalin
  0 siblings, 1 reply; 9+ messages in thread
From: Aditya Mahajan @ 2021-04-06  7:31 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 732 bytes --]

On Mon, 5 Apr 2021, Thangalin wrote:

> Peter Münster once asked:
> 
> > What should I do please, to prevent ConTeXt from creating
> $HOME/luatex-cache?
> 
> I'd like to do the same:
> 
> $ cd $HOME
> $ ls luatex-cache
> ls: cannot access 'luatex-cache': No such file or directory
> $ context test.tex
> $ ls luatex-cache/
> context
> $ rm -rf luatex-cache
> $ export TEXMFCACHE=/tmp

Add

$ mtxrun --generate

> $ context test.tex
> mtxrun          | unknown script 'mtx-context.lua' or 'mtx-mtx-context.lua'
> $ export TEXMFCACHE=
> $ context --version
> ...
> mtx-context     | current version: 2021.03.31 18:04
> 
> What environment variable must change to set the luatex-cache directory?

Aditya

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Set luatex cache directory path
  2021-04-06  7:31 ` Aditya Mahajan
@ 2021-04-06 18:59   ` Thangalin
  2021-04-06 19:24     ` Aditya Mahajan
  2021-04-06 21:38     ` Hans Hagen
  0 siblings, 2 replies; 9+ messages in thread
From: Thangalin @ 2021-04-06 18:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1437 bytes --]

Thanks Aditya.

What do you think of changing the default luatex-cache directory to the
system's temporary directory? Consider:

   - The $HOME directory is sacrosanct (4784 people agree:
   https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1575053)
   - The temp directory is cleared on Linux (Unix?) system reboots; purged
   during regular Windows upkeep
   - The temp directory is writable by default
   - Changing the location requires calling an additional program, which
   isn't obvious (principle of least astonishment)

My text editor invokes ConTeXt like:

    if( TYPESETTER.canRun() ) {
      env.put( "TEXMFCACHE", System.getProperty( "java.io.tmpdir" ) );

      mArgs.add( TYPESETTER.getName() );
      mArgs.add( .. --path .. --purge .. --batch .. --result ..
--environment .. etc. );
      mArgs.add( inputFilename );
    }

The first line ensures that "context" is an executable located in a PATH
directory. The second line attempts to change the luatex-cache directory.
The remaining lines configure the command-line arguments prior to running
ConTeXt.

Fearing flaming wrath from users, an additional mtxrun call is required,
which incurs overhead:

   - Check for mtxrun executable
   - Run mtxrun each time

This would work but feels like a leaky abstraction (i.e., the context
executable should honour TEXMFCACHE without needing to invoke mtxrun
because context creates the luatex-cache directory).

Thoughts?

[-- Attachment #1.2: Type: text/html, Size: 1833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Set luatex cache directory path
  2021-04-06 18:59   ` Thangalin
@ 2021-04-06 19:24     ` Aditya Mahajan
  2021-04-06 21:06       ` Thangalin
  2021-04-10 23:30       ` Thangalin
  2021-04-06 21:38     ` Hans Hagen
  1 sibling, 2 replies; 9+ messages in thread
From: Aditya Mahajan @ 2021-04-06 19:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Tue, 6 Apr 2021, Thangalin wrote:

> Thanks Aditya.
> 
> What do you think of changing the default luatex-cache directory to the
> system's temporary directory? Consider:
> 
>    - The $HOME directory is sacrosanct (4784 people agree:
>    https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1575053)
>    - The temp directory is cleared on Linux (Unix?) system reboots; purged
>    during regular Windows upkeep
>    - The temp directory is writable by default
>    - Changing the location requires calling an additional program, which
>    isn't obvious (principle of least astonishment)

Use:

mtxrun --autogenerate --script mtx-context ...

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Set luatex cache directory path
  2021-04-06 19:24     ` Aditya Mahajan
@ 2021-04-06 21:06       ` Thangalin
  2021-04-10 23:30       ` Thangalin
  1 sibling, 0 replies; 9+ messages in thread
From: Thangalin @ 2021-04-06 21:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 39 bytes --]

Perfect, thank you.

Will be Wikified.

[-- Attachment #1.2: Type: text/html, Size: 99 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Set luatex cache directory path
  2021-04-06 18:59   ` Thangalin
  2021-04-06 19:24     ` Aditya Mahajan
@ 2021-04-06 21:38     ` Hans Hagen
  1 sibling, 0 replies; 9+ messages in thread
From: Hans Hagen @ 2021-04-06 21:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Thangalin

On 4/6/2021 8:59 PM, Thangalin wrote:
> Thanks Aditya.
> 
> What do you think of changing the default luatex-cache directory to the 
> system's temporary directory? Consider:
> 
>   * The $HOME directory is sacrosanct (4784 people agree:
>     https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1575053
>     <https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1575053>)
>   * The temp directory is cleared on Linux (Unix?) system reboots;
>     purged during regular Windows upkeep
>   * The temp directory is writable by default
>   * Changing the location requires calling an additional program, which
>     isn't obvious (principle of least astonishment)

Do you really want to recahe fonts so often?

> My text editor invokes ConTeXt like:
> 
>      if( TYPESETTER.canRun() ) {
>        env.put( "TEXMFCACHE", System.getProperty( "java.io.tmpdir" ) );
> 
>        mArgs.add( TYPESETTER.getName() );
>        mArgs.add( .. --path .. --purge .. --batch .. --result .. 
> --environment .. etc. );
>        mArgs.add( inputFilename );
>      }

--batch only makes sense for an unattended run
--purging every time can lead to extra runs

> The first line ensures that "context" is an executable located in a PATH 
> directory. The second line attempts to change the luatex-cache 
> directory. The remaining lines configure the command-line arguments 
> prior to running ConTeXt.
> 
> Fearing flaming wrath from users, an additional mtxrun call is required, 
> which incurs overhead:
> 
>   * Check for mtxrun executable
>   * Run mtxrun each time

see aditya's reply ... the --autogenerate is clever enough not to do 
redundant things (and context knows when it has been updated so ...)

> This would work but feels like a leaky abstraction (i.e., the context 
> executable should honour TEXMFCACHE without needing to invoke mtxrun 
> because context creates the luatex-cache directory).
see aditya's reply ... quite some effort has gone into making sure 
context starts up fast so i'm not going to advocate a different practice

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Set luatex cache directory path
  2021-04-06 19:24     ` Aditya Mahajan
  2021-04-06 21:06       ` Thangalin
@ 2021-04-10 23:30       ` Thangalin
  2021-04-11  9:16         ` Hans Hagen
  1 sibling, 1 reply; 9+ messages in thread
From: Thangalin @ 2021-04-10 23:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1744 bytes --]

Are two runs always required to generate a PDF when TEXMFCACHE is set?

$ sudo su -
$ mkdir -p /opt/context
$ cd /opt/context
$ wget http://lmtx.pragma-ade.nl/install-lmtx/context-linux-64.zip
$ unzip *zip
$ sh install.sh
$ exit
$ cat test.tex
\starttext
Test
\stoptext
$ export TEXMFCACHE=/tmp
$ rm -rf $TEXMFCACHE/luatex-cache
$ /opt/context/tex/texmf-linux-64/bin/mtxrun --autogenerate --script
mtx-context --autopdf test.tex
...
resolvers       | resolving | remembered file 'mtx-context.lua'
resolvers       | resolving | remembered file 'mtx-contexts.lua'
resolvers       | resolving | remembered file 'mtx-context.lua'
resolvers       | resolving | remembered file 'mtx-t-mtx-context.lua'
resolvers       | resolving | remembered file 'mtx-t-mtx-contexts.lua'
resolvers       | resolving | remembered file 'mtx-t-mtx-context.lua'
resolvers       | resolving | remembered file 'mtx-context.lua'
mtxrun          | unknown script 'mtx-context.lua' or 'mtx-mtx-context.lua'
$ /opt/context/tex/texmf-linux-64/bin/mtxrun --script context --version
mtx-context     | current version: 2021.04.10 17:09
$ mtxrun --autogenerate --script mtx-context --autopdf test.tex
...
mkiv lua stats  > runtime: 0.432 seconds, 1 processed pages, 1 shipped
pages, 2.315 pages/second
system          | total runtime: 3.318 seconds of 3.372 seconds

The first run fails; the second run succeeds.

If TEXMFCACHE is not set, then the first run succeeds. If TEXMFCACHE is set
to any non-empty value and $TEXMFCACHE/luatex-cache has not been created,
mtxrun always terminates with the same unknown script error.

What am I missing to ensure that ConTeXt will create luatex-cache in /tmp
when TEXMFCACHE is set and successfully build the PDF on first run?

Thank you!

[-- Attachment #1.2: Type: text/html, Size: 2362 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Set luatex cache directory path
  2021-04-10 23:30       ` Thangalin
@ 2021-04-11  9:16         ` Hans Hagen
  2021-04-11 21:13           ` Thangalin
  0 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2021-04-11  9:16 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Thangalin

On 4/11/2021 1:30 AM, Thangalin wrote:
> Are two runs always required to generate a PDF when TEXMFCACHE is set?
> 
> $ sudo su -
> $ mkdir -p /opt/context
> $ cd /opt/context
> $ wget http://lmtx.pragma-ade.nl/install-lmtx/context-linux-64.zip 
> <http://lmtx.pragma-ade.nl/install-lmtx/context-linux-64.zip>
> $ unzip *zip
> $ sh install.sh
> $ exit
> $ cat test.tex
> \starttext
> Test
> \stoptext
> $ export TEXMFCACHE=/tmp
> $ rm -rf $TEXMFCACHE/luatex-cache
> $ /opt/context/tex/texmf-linux-64/bin/mtxrun --autogenerate --script 
> mtx-context --autopdf test.tex
> ...
> resolvers       | resolving | remembered file 'mtx-context.lua'
> resolvers       | resolving | remembered file 'mtx-contexts.lua'
> resolvers       | resolving | remembered file 'mtx-context.lua'
> resolvers       | resolving | remembered file 'mtx-t-mtx-context.lua'
> resolvers       | resolving | remembered file 'mtx-t-mtx-contexts.lua'
> resolvers       | resolving | remembered file 'mtx-t-mtx-context.lua'
> resolvers       | resolving | remembered file 'mtx-context.lua'
> mtxrun          | unknown script 'mtx-context.lua' or 'mtx-mtx-context.lua'
> $ /opt/context/tex/texmf-linux-64/bin/mtxrun --script context --version
> mtx-context     | current version: 2021.04.10 17:09
> $ mtxrun --autogenerate --script mtx-context --autopdf test.tex
> ...
> mkiv lua stats  > runtime: 0.432 seconds, 1 processed pages, 1 shipped 
> pages, 2.315 pages/second
> system          | total runtime: 3.318 seconds of 3.372 seconds
> 
> The first run fails; the second run succeeds.
> 
> If TEXMFCACHE is not set, then the first run succeeds. If TEXMFCACHE is 
> set to any non-empty value and $TEXMFCACHE/luatex-cache has not been 
> created, mtxrun always terminates with the same unknown script error.
> 
> What am I missing to ensure that ConTeXt will create luatex-cache in 
> /tmp when TEXMFCACHE is set and successfully build the PDF on first run?
what happens if you also set TEXMFCACHE before running install.sh

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Set luatex cache directory path
  2021-04-11  9:16         ` Hans Hagen
@ 2021-04-11 21:13           ` Thangalin
  0 siblings, 0 replies; 9+ messages in thread
From: Thangalin @ 2021-04-11 21:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 3085 bytes --]

$ sudo su -
$ rm -rf /opt/context
$ mkdir -p /opt/context
$ cd /opt/context
$ wget http://lmtx.pragma-ade.nl/install-lmtx/context-linux-64.zip
$ unzip *zip
$ export TEXMFCACHE=/tmp
$ sh install.sh
$ exit
$ cat test.tex
\starttext
Test
\stoptext
$ export TEXMFCACHE=/tmp
$ sudo rm -rf /tmp/luatex-cache
$ /opt/context/tex/texmf-linux-64/bin/mtxrun --autogenerate --script
mtx-context --autopdf test.tex
resolvers       | resolving | remembered file 'mtx-context.lua'
resolvers       | resolving | remembered file 'mtx-contexts.lua'
resolvers       | resolving | remembered file 'mtx-context.lua'
resolvers       | resolving | remembered file 'mtx-t-mtx-context.lua'
resolvers       | resolving | remembered file 'mtx-t-mtx-contexts.lua'
resolvers       | resolving | remembered file 'mtx-t-mtx-context.lua'
resolvers       | resolving | remembered file 'mtx-context.lua'
mtxrun          | unknown script 'mtx-context.lua' or 'mtx-mtx-context.lua'

If the cache directory isn't deleted, the PDF is generated. However, as
soon as the computer reboots, or the temporary directory is otherwise
erased, two runs are required.

I've addressed this in my code, but it's a little awkward and somewhat
brittle because the code cannot know what makes for a valid luatex-cache
directory:

    private boolean reinitialize() {
      // variable assignments ... exists = check for luatex-cache directory

      mArgs.clear();
      mArgs.add( TYPESETTER.getName() );

      if( exists ) {
        mArgs.add( "--autogenerate" );
        mArgs.add( "--script" );
        mArgs.add( "mtx-context" );
        mArgs.add( ... remaining args ... );
      }
      else {
        mArgs.add( "--generate" );
      }

      return exists;
    }

    private boolean typeset() throws Exception {
      return reinitialize() ? call() : call() && reinitialize() && call();
    }

    // Invoke ConTeXt to either typeset the document or generate the cache
directory
    public Boolean call() throws Exception {
      final var builder = new ProcessBuilder( mArgs );
      builder.directory( mDirectory.toFile() );

      final var cacheDir = getCacheDir();
      final var env = builder.environment();
      env.put( "TEXMFCACHE", cacheDir.toString() );

      builder.redirectOutput( DISCARD );
      builder.redirectError( DISCARD );

      final var process = builder.start();
      process.waitFor();
      final var exit = process.exitValue();
      process.destroy();
      return exit == 0;
    }

Also, unless my application installs ConTeXt, setting the TEXMFCACHE
directory before the installation begins will require asking users to do
this. Ideally, using the software would take the following steps:

1. Download text editor
2. Download and install ConTeXt (e.g., click link, extract archive, run
install.sh)
3. Run text editor
4. Export PDF (editor configures ConTeXt as required, reducing the number
of steps for end users)

At some point in the future, the editor may prompt the user for permission
to install ConTeXt on their behalf---to simplify step 2---but that's much
more effort.

Stay safe!

[-- Attachment #1.2: Type: text/html, Size: 4477 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-04-11 21:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-05 22:19 Set luatex cache directory path Thangalin
2021-04-06  7:31 ` Aditya Mahajan
2021-04-06 18:59   ` Thangalin
2021-04-06 19:24     ` Aditya Mahajan
2021-04-06 21:06       ` Thangalin
2021-04-10 23:30       ` Thangalin
2021-04-11  9:16         ` Hans Hagen
2021-04-11 21:13           ` Thangalin
2021-04-06 21:38     ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).