Starefossen / docker-aspell

:whale: Docker image for running GNU Aspell spell checking
https://registry.hub.docker.com/u/starefossen/aspell/
MIT License
3 stars 4 forks source link

Difference between CLI use and Docker container use: 'Could not open the file for reading' #4

Open richelbilderbeek opened 1 year ago

richelbilderbeek commented 1 year ago

Hi @Starefossen,

Thanks for this Docker container! You are -AFAICS- the only one that actually documented his aspell Docker container, hence I think your work is the best :-)

I do have some silly problem, probably due to my lack of understanding than your container. I have re-created the problem at https://github.com/richelbilderbeek/docker_aspell_issue, but below in friendly English text :-)

Expectation

I expect that running aspell (i.e. a locally installed aspell) and docker-aspell to have the same behavior.

Setup

Below I show the code and output for

Running aspell (i.e. a locally installed aspell)

Here is how I run aspell:

echo "File without spelling errors, interactively"
aspell -c --mode=tex correct.tex --lang=en_GB

echo "File with spelling errors, interactively"
echo "This command is commented out, as it will start an interactive session"
# aspell -c --mode=tex incorrect.tex --lang=en_GB

echo "File without spelling errors"
cat correct.tex | aspell pipe --mode=tex --lang=en_GB

echo "File with spelling errors"
cat incorrect.tex | aspell pipe --mode=tex --lang=en_GB

This gives (also in GitHub Actions log):

File without spelling errors, interactively
[?1049h(B[?7h[?1h=[?1h=[?1049l
[?1l>[?1049l
[?1l>File with spelling errors, interactively
This command is commented out, as it will start an interactive session
File without spelling errors
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.8)
*
*
*

File with spelling errors
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.8)
& Swegliome 16 0: Welcome, Selim, Slime, Salome, Swelling, Seraglio, Whilom, Sublime, Gloom, Glimmer, Slimmer, Swimmer, Selma, Clime, Slimy, Swell
& LaegraerhahTeX 10 10: Lagrange's, Loggerheads, Caretakers, Loggerhead's, Caretaker's, Figureheads, Curettage's, Figurehead's, Giraudoux, Lucretius
# trtheartjrxt 25

Running docker-aspell

echo "File without spelling errors, interactive"
sudo docker run starefossen/aspell -c --mode=tex correct.tex --lang=en_GB

echo "File with spelling errors, interactive"
sudo docker run starefossen/aspell -c --mode=tex incorrect.tex --lang=en_GB

echo "File without spelling errors"
cat correct.tex | sudo docker run starefossen/aspell pipe --mode=tex --lang=en_GB

echo "File with spelling errors"
cat incorrect.tex | sudo docker run starefossen/aspell pipe --mode=tex --lang=en_GB

This gives (also in GitHub Actions log):

File without spelling errors, interactive
File with spelling errors, interactive
File without spelling errors
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.6.1)
File with spelling errors
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.6.1)

and stderr output:

Error: Could not open the file "correct.tex" for reading
Error: Could not open the file "incorrect.tex" for reading

Question

Why can't my files be found? Or what else causes the difference in output?

Thanks for your help and cheers, Richel

Starefossen commented 1 year ago

Thanks for the kind words, I haven't used this for a while but I can look into it. Do you know what version of aspell you have locally?

richelbilderbeek commented 1 year ago

Hi @Starefossen,

Thanks for the friendly and helpful reply! Here is the answer to your question:

$ aspell version
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.8)

It seems to me the aspell versions are exactly the same versions.

I run Ubuntu 22.04 Jammy LTS.

Thanks again, Richel

richelbilderbeek commented 1 year ago

I made some progress here.

Obviously, I should mount the file, say that Docker can read it:

sudo docker run --volume $PWD/correct.tex:/correct.tex starefossen/aspell -c correct.tex --mode=tex --lang=en_GB

This, however, gives the error Error: Stdin not a terminal.. This is understandable: aspell -c starts an interactive mode.

To run aspell in passive/non-interactive mode, the argument --pipe is used, together with a pipe (|). However, I cannot get this combination to work, with both these failing:

sudo docker run --volume $PWD/correct.tex:/correct.tex starefossen/aspell cat correct.tex | aspell --pipe --mode=tex --lang=en_GB
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.8)
Error: Unknown Action: cat

or:

cat correct.tex | sudo docker run  starefossen/aspell --pipe --mode=tex --lang=en_GB
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.6.1)

How to use this Docker container correctly?

richelbilderbeek commented 1 year ago

Ah, I found the solution, thanks to this Stack Overflow post:

cat correct.tex | sudo docker run -i starefossen/aspell --pipe --mode=tex --lang=en_GB
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.6.1)
*
& LaTeX 33 5: Latex, La TeX, La-TeX, Playtex, TeX, Tex, Latex's, Lax, Late, Lattes, Lats, Later, Lat's, Lades, Lakes, Laxer, Lutes, Tax, LyX, TWX, Latte's, Lets, Legates, Ligates, Locates, Lix, Lox, Tux, Lake's, Lute's, Latter's, Let's, Legate's
*