mathbook/xsl/pretext-html.xsl line 487 element document xsltDocumentElem: unable to save to index.html I/O error

85 views
Skip to first unread message

Zheng-Chao Han

unread,
Jan 9, 2023, 12:24:10 PM1/9/23
to PreTeXt support
Hi, 

After having not used PreTeXt for a few months, I encountered multiple errors today  in compiling an existing file which used to work, and when I tested out the minimal example file, it worked, but testing essentially the same file in my working directory initially gave the same kind of errors as in the Subject line, but after a few rounds, the main message in the console file becomes "Use of mathbook-*.xsl stylesheets is deprecated. These will be removed in future versions. Switch now to using the pretext-*.xsl variant instead.", but may occasionally still produce the "I/O error : Operation timed out" message.

I did a "git pull" this morning. It initially had the message 
"error: Your local changes to the following files would be overwritten by merge:

   examples/sample-article/sample-article.xml

   xsl/pretext-latex.xsl

Please commit your changes or stash them before you merge.

Aborting"

I ran "git checkout xsl/pretext-latex.xsl" and got a response "Updated 1 path from the index".

I use TeXShop's 
<!--
% !TEX TS-program =PreTeXt-HTML
-->
to build the html file, which works for the minimal example file and exhibits the html file automatically with Safari, but not with the similar file in my working directory, which
would prompt the following error message in Safari 
Screen Shot 2023-01-09 at 11.41.05 AM.png

---when I chose to use Chrome to open the relevant html file there, the file looks fine despite the error message. 

Is this an issue with browsers? But the minimal example file works fine with Safari. Could this have to do with my working directory being on a Box directory?  Here is the path:
file:///Users/zchan/Library/CloudStorage/Box-Box/My%20Documents/teaching/412/NotesPTX/Source/frontmatter.html
while the minimal example resides on my laptop:
file:///Users/zchan/Documents/mathbook/examples/minimal/source/frontmatter-1.html

I would be interested in learning whether anybody else has had a similar issue.

Thanks,
Zheng-Chao

Rob Beezer

unread,
Jan 9, 2023, 12:40:54 PM1/9/23
to pretext...@googlegroups.com
It would be very hard to diagnose what is wrong with your repository.  Could you just clone a fresh copy and make sure you are on the "master" branch?  (There were stylesheet renames, a move away from the old "dev" branch, and maybe you has edited files locally in your copy.)

That would get us up to where you start talking about TeXShop.  See how much of the bad behavior persists and follow-up?

Thanks,
Rob

--
You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-support/e4da09c5-6c9d-407d-bae4-9af6afbf3325n%40googlegroups.com.

Zheng-Chao Han

unread,
Jan 9, 2023, 1:42:11 PM1/9/23
to PreTeXt support
Thanks for your quick response. I don't really understand how the git repository works with the local copy. So it seems that "git pull" may not do the same as "git clone"? I suppose that if I have the current version, then compiling a file should not produce the message "Use of mathbook-*.xsl stylesheets is deprecated. These will be removed in future versions. Switch now to using the pretext-*.xsl variant instead"? 

Incidentally when I followed the instructions in the Guide at https://pretextbook.org/doc/guide/html/quickstart-getting-pretext.html
 to see whether my installation already has the cli interface, instead of just getting a version number,  I got the following

% pretext --version

/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/watchdog/observers/__init__.py:71: UserWarning: Failed to import fsevents. Fall back to kqueue

  warnings.warn("Failed to import fsevents. Fall back to kqueue")

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/pretext", line 5, in <module>

    from pretext.cli import main

  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pretext/cli.py", line 14, in <module>

    from . import utils, templates, VERSION, CORE_COMMIT

  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pretext/utils.py", line 19, in <module>

    from lxml import etree as ET

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/lxml/etree.cpython-310-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/lxml/etree.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))


But I don't understand the implications of these messages.

Zheng-Chao

Sean Fitzpatrick

unread,
Jan 10, 2023, 3:48:32 PM1/10/23
to pretext...@googlegroups.com
If you have already made a copy of the repo, "git pull" will bring the latest changes from the repo to your machine.

But if you have edited any of those files, git pull will fail, because it doesn't want to replace your modified files with the new versions from the repo.

If you need to keep those changes, just rename the modified files to something else.
If not, you can run "git checkout <file name>" to restore the file, and then git pull.

Or, you can make another copy of the repo in a different folder. "git clone" is the command to download a fresh copy.

Zheng-Chao Han

unread,
Jan 10, 2023, 9:03:05 PM1/10/23
to PreTeXt support
Thanks for your suggestions.  I didn't have any background on git, and only used "git clone" and "git pull" following the set up instructions without knowing what they do. I just spent a couple hours today looking up some basics. Following one site, I did "git status" to get

On branch dev

Your branch is behind 'origin/dev' by 116 commits, and can be fast-forwarded.

  (use "git pull" to update your local branch)

and a long list of files. Then I did "git stash" , then "git pull". This time the "pull" completed without aborting. But when I tried to compiled a test file, the console log suggests that I do "git switch master" then "git pull"---I don't understand why at that point it suggested that I do "git switch master". However, after this is done and I tried to compile a test file, the console is complaining "warning: failed to load external entity "/Users/zchan/Documents/mathbook/xsl/mathbook-html.xsl"

cannot parse /Users/zchan/Documents/mathbook/xsl/mathbook-html.xsl

Translation to LaTeX failed. Please use the PreTeXt-Validate engine to check your file."

This suggests to me that the new pull can't seem to find the right path to mathbook-html.xsl? 

Also, when I ran pretext --version earlier in the day, I got the following error message---could the last line of the error message indicate some conflicts with my new Mac Air architecture (with Apple M2 chip, macOS 12.5.1)? I don't get the following errors on my old Mac.

/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/watchdog/observers/__init__.py:71: UserWarning: Failed to import fsevents. Fall back to kqueue

  warnings.warn("Failed to import fsevents. Fall back to kqueue")

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/pretext", line 5, in <module>

    from pretext.cli import main

  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pretext/cli.py", line 14, in <module>

    from . import utils, templates, VERSION, CORE_COMMIT

  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pretext/utils.py", line 19, in <module>

    from lxml import etree as ET

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/lxml/etree.cpython-310-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/lxml/etree.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))


Sean Fitzpatrick

unread,
Jan 10, 2023, 10:06:08 PM1/10/23
to pretext...@googlegroups.com
You are using a very old version, I think. PreTeXt moved to a new repository on GitHub a long time ago (this summer, I think), and moved away from the "dev" branch to a master branch.

But is there a reason you are using this rather than the CLI? At this point the only people using the GitHub version should be those who are working on developing new features for PreTeXt.
For those who are writing books, the PreTeXt CLI is much easier.

Oscar Levin

unread,
Jan 10, 2023, 10:12:02 PM1/10/23
to PreTeXt support
I don't know anything about the TeXShop setup, but from the rest of your messages, it seems you are trying to use a combination of the PreText-CLI and the pretext github repository.  Since you are spending time trying to fix this anyway, I'd strongly recommend just moving the the CLI and not worrying about github (except for your own project, if you choose to track it with git).  

If that sounds reasonable to you, then we first want to make sure that the CLI is installed correctly.  Can you try running `pip uninstall pretext pretextbook` and then `pip install pretext` (if you are on mac, this might be pip3 instead of pip, or you might need to do python -m pip or pything3 -m pip).  We want to make sure first that nothing called pretext is on your machine on your path, before installing a fresh copy.

Alternatively, you can now do almost everything in the cloud using GitHub's codespaces.  If that sounds appealing, I can help you get set up with that too.

Oscar.

Steven Clontz

unread,
Jan 11, 2023, 7:35:05 AM1/11/23
to PreTeXt support
Agreed with Oscar - we're doing our best to make sure that except for advanced or very fringe use-cases, the only installation you need is PreTeXt-CLI, or even better, our new online editing workflow via Codespaces.

Zheng-Chao Han

unread,
Jan 11, 2023, 11:57:12 AM1/11/23
to PreTeXt support
Hi Steve and Oscar,

Thank you both for taking your time to help!  I now have some better (still rudimentary) understanding of my setup, but ran into errors when trying to uninstall the pretext.

First, my initial setup was from two years ago, mainly using the TeXShop's processing of the html/latex output, and occasionally used the xsltproc command line if I had to use a modified xsl style sheet. I tried to migrate to the cli environment this past August, but after having some initial issues, I didn't make that move. Throughout the process I didn't know the back-end work flow, as a result I have just realized that many of my trials and errors are the errors of a total novice---quite embarrassing.  The following is what I have observed on my new Mac Air (with Apple M2 chip, macOS 12.5.1). The "pretext build web" in item 6 works fine on my old mac (with a warning like                                                                                                                                                                                          'Using CLI version 0.8.2a4 but project's `requirements.txt`

warning: is configured to use 0.7.0. Consider either installing

warning: CLI version 0.7.0 or changing `requirements.txt` to match 0.8.2a4.')

  1. When I decided to look into the TeXShop's set up in its code "<!-- % !TEX TS-program =PreTeXt-HTML-->", I now understand that it is always pointing to "xsltproc --xinclude $HOME/Documents/mathbook/xsl/mathbook-html.xsl "$1" ", so none of my updated installation has had any effect when I keep using TeXShop to process the files. 
  2. After I modified the "xsltproc --xinclude $HOME/Documents/mathbook/xsl/mathbook-html.xsl "$1" " to "xsltproc --xinclude $HOME/Documents/pretext/xsl/pretext-html.xsl "$1" " in TeXShop's PreTeXt-HTML.engine---attached for your reference, I was able to process the minimal example file main.ptx. But after I made a copy of that main.ptx file into my Box cloud working directory, file:///Users/zchan/Library/CloudStorage/Box-Box/My%20Documents/teaching/412/NotesPTX/Source/, I would get the error message from Safari Screen Shot 2023-01-09 at 11.41.05 AM.pngAgain when I chose to use Chrome to open the relevant html file there manually, the file looks fine. This may have to do with the line "open "$HTMLFILE" " in the TeXShop's PreTeXt-Html.engine file? But I don't know what that line does. The instruction in the minimal example main.ptx for processing with xsltproc still uses the style sheet in the mathbook directory: xsltproc PATH_TO/mathbook/xsl/pretext-html.xsl source/main.ptx?
  3. The reported issues and errors yesterday were done when I performed the "git pull" etc  in the $HOME/Documents/mathbook directory without remembering that I had installed a newer version in the $HOME/Documents/pretext directory. I did the "git pull" etc in the $HOME/Documents/pretext directory today and have the same issues when checkin "pretext --version" as reported below in item 5.
  4. When I tried to follow Oscar's suggestion to uninstall pretext, I ran into the following (Permission denied:) error message:                                                                                       % pip uninstall pretext pretextbook

    WARNING: Skipping pretext as it is not installed.

    Found existing installation: pretextbook 0.8.2a4

    Uninstalling pretextbook-0.8.2a4:

      Would remove:

        /Library/Frameworks/Python.framework/Versions/3.10/bin/pretext

        /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pretext/*

        /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pretextbook-0.8.2a4.dist-info/*

    Proceed (Y/n)? y

    ERROR: Exception:

  1. Traceback (most recent call last):

  1.   File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 813, in move

        os.rename(src, real_dst)

    PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.10/bin/pretext' -> '/private/var/folders/gl/5v_gndc978984dhdlht9fqn40000gp/T/pip-uninstall-baukojys/pretext'


    During handling of the above exception, another exception occurred:


  1. Traceback (most recent call last):

  1.   File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper

        status = run_func(*args)

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/commands/uninstall.py", line 98, in run

        uninstall_pathset = req.uninstall(

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/req/req_install.py", line 658, in uninstall

        uninstalled_pathset.remove(auto_confirm, verbose)

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/req/req_uninstall.py", line 373, in remove

        moved.stash(path)

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/req/req_uninstall.py", line 271, in stash

        renames(path, new_path)

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/utils/misc.py", line 311, in renames

        shutil.move(old, new)

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 834, in move

        os.unlink(src)

    PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.10/bin/pretext'

    zchan@MacBook-Air pretext % python3 -m pip uninstall pretext pretextbook

    WARNING: Skipping pretext as it is not installed.

    Found existing installation: pretextbook 0.8.2a4

    Uninstalling pretextbook-0.8.2a4:

      Would remove:

        /Library/Frameworks/Python.framework/Versions/3.10/bin/pretext

        /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pretext/*

        /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pretextbook-0.8.2a4.dist-info/*

    Proceed (Y/n)? y

    ERROR: Exception:

  1. Traceback (most recent call last):

  1.   File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 813, in move

        os.rename(src, real_dst)

    PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.10/bin/pretext' -> '/private/var/folders/gl/5v_gndc978984dhdlht9fqn40000gp/T/pip-uninstall-8vqhzk7j/pretext'


    During handling of the above exception, another exception occurred:


  1. Traceback (most recent call last):

  1.   File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper

        status = run_func(*args)

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/commands/uninstall.py", line 98, in run

        uninstall_pathset = req.uninstall(

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/req/req_install.py", line 658, in uninstall

        uninstalled_pathset.remove(auto_confirm, verbose)

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/req/req_uninstall.py", line 373, in remove

        moved.stash(path)

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/req/req_uninstall.py", line 271, in stash

        renames(path, new_path)

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_internal/utils/misc.py", line 311, in renames

        shutil.move(old, new)

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 834, in move

        os.unlink(src)

    PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.10/bin/pretext'

    5. The pretext --version check continues to indicate some architecture issues?                                                                                                                                % pretext --version

  1. /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/watchdog/observers/__init__.py:71: UserWarning: Failed to import fsevents. Fall back to kqueue

      warnings.warn("Failed to import fsevents. Fall back to kqueue")

    Traceback (most recent call last):

      File "/Library/Frameworks/Python.framework/Versions/3.10/bin/pretext", line 5, in <module>

        from pretext.cli import main

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pretext/cli.py", line 14, in <module>

        from . import utils, templates, VERSION, CORE_COMMIT

      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pretext/utils.py", line 19, in <module>

        from lxml import etree as ET

    ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/lxml/etree.cpython-310-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/lxml/etree.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))

  1. 6. When I test ran "pretext build web" in the source directory for the minimal example, I got the same error message as above. 


I hope to be able to install a clean  PreTeXt-CLI, or fine some guidelines about  Codespaces as mentioned by Steve.

Thanks,
Zheng-Chao
PreTeXt-HTML.engine
Reply all
Reply to author
Forward
0 new messages