bib2gls icon indicating copy to clipboard operation
bib2gls copied to clipboard

Version 3.8 and 3.9 fail to find aux files in subdirectories of build directory

Open Bidski opened this issue 10 months ago • 9 comments

I am using latexmk with bib2gls via this script

add_cus_dep('aux', 'glstex', 0, 'run_bib2gls');
sub run_bib2gls {
  my ($base, $path) = fileparse( $_[0] );
  my $silent_command = $silent ? "--silent" : "";
  if ( $path ) {
    my $ret = system("./bib2gls/bib2gls.sh $silent_command --dir '$path' --group '$base'");
  } else {
    my $ret = system("./bib2gls/bib2gls.sh $silent_command --group '$_[0]'");
  };
  # Analyze log file.
  local *LOG;
  $LOG = "$_[0].glg";
  if (!$ret && -e $LOG) {
    open LOG, "<$LOG";
    while (<LOG>) {
      if (/^Reading (.*\.bib)\s$/) {
        rdb_ensure_file( $rule, $1 );
      }
    }
    close LOG;
  }
  return $ret;
}

My project folder structure is (reduced for brevity)

root/
 |-- build/
 |    |-- chapters/  chapter build artefacts with aux files in subdirectories to match the source file structure
 |    |    |-- introduction/introduction.aux
 |    |    |-- background/background.aux
 |    |-- main.aux
 |-- chapters/    chapter source files in multiple subdirectories
 |    |-- introduction/introduction.tex
 |    |-- background/background.tex
 | -- main.tex
 | -- glossaries.bib

With version 3.7 bib2gls (executed with --dir 'build/' --group 'main') correctly finds all of the aux files in all of the subdirectories of the build directory.

In versions 3.8 and 3.9 I get the following warnings (reduced for brevity)

Warning: build/main.aux:71: File 'chapters/introduction/introduction.aux' not found.
Warning: build/main.aux:186: File 'chapters/background/background.aux' not found.

On top of this, version 3.7 tries to write to build/build/main.glstex which is incorrect, it should be build/main.glstex. This does not happen in version 3.6.

Writing build/build/main.glstex
Error: build/build/main.glstex (No such file or directory)

Bidski avatar Mar 30 '24 01:03 Bidski

I think the problem may stem from a change in the TeX Parser Library, which is used to parse the aux files. I'll look into it.

nlct avatar Mar 30 '24 12:03 nlct

It's possible the change in behaviour occurred when fixing issue #27. --dir was primarily intended to work with LaTeX's --output-directory. I think it needs another switch for changing the current working directory.

Incidentally, the bib2gls.sh file is designed for TeX Live as it uses kpsewhich to find the jar files in TeX Live's scripts directory. If you have downloaded the files to a user directory without using the TeX Live Manager installer, the bib2gls.sh may run the wrong jar file.

nlct avatar Apr 01 '24 09:04 nlct

It's possible the change in behaviour occurred when fixing issue #27. --dir was primarily intended to work with LaTeX's --output-directory. I think it needs another switch for changing the current working directory.

I'm not sure I am trying to change the current working directory? The bib files I am using are in the project root directory and build is the directory that is used as the --output-directory for LaTeX.

Incidentally, the bib2gls.sh file is designed for TeX Live as it uses kpsewhich to find the jar files in TeX Live's scripts directory. If you have downloaded the files to a user directory without using the TeX Live Manager installer, the bib2gls.sh may run the wrong jar file.

I did notice this. In my tests with the specific versions I ran the java command directly and specificied the path to the jar file.

Bidski avatar Apr 01 '24 11:04 Bidski

I'm not sure I am trying to change the current working directory? The bib files I am using are in the project root directory and build is the directory that is used as the --output-directory for LaTeX.

I'm sorry, I'm not particularly familiar with latexmk. It's been a long time since I last used it.

Incidentally, the bib2gls.sh file is designed for TeX Live as it uses kpsewhich to find the jar files in TeX Live's scripts directory. If you have downloaded the files to a user directory without using the TeX Live Manager installer, the bib2gls.sh may run the wrong jar file.

I did notice this. In my tests with the specific versions I ran the java command directly and specificied the path to the jar file.

Okay.

nlct avatar Apr 01 '24 11:04 nlct

I suppose I should have mentioned this initially. In the tests I ran for each version I ran the java command manually without using latexmk just to make sure there was nothing interesting happening with latexmk. Each time I ran the java command from the project root directory

Bidski avatar Apr 01 '24 11:04 Bidski

Specifically I ran this command which I took from bib2gls.sh

java -Djava.locale.providers=CLDR,JRE,SPI -jar ./bib2gls-3.x/bib2gls.jar --dir build --group main

Bidski avatar Apr 01 '24 11:04 Bidski

Could you try downloading bib2gls.zip from https://www.dickimaw-books.com/expl/ and see if that works for your document.

nlct avatar Apr 01 '24 18:04 nlct

That appears to work well

bib2gls version 3.9.20140401 (2024-04-01)
Apr 02, 2024 8:59:45 AM sun.util.locale.provider.LocaleProviderAdapter <clinit>
WARNING: COMPAT locale provider will be removed in a future release
Reading build/main.aux
Encoding: UTF-8
Reading build/chapters/introduction/introduction.aux
Encoding: UTF-8
Reading build/chapters/background/background.aux
Encoding: UTF-8
Reading glossaries.bib
Encoding: UTF-8
Writing build/main.glstex
22 entries written to build/main.glstex.
22 entries written in total.
Transcript written to build/main.glg.

Bidski avatar Apr 01 '24 22:04 Bidski

Thank you for your feedback. (I'll remove the java.locale.providers setting in the bash script in the next version, which is causing the COMPAT warning.)

nlct avatar Apr 02 '24 08:04 nlct