alefore / edge

Edge - a text editor
GNU General Public License v3.0
77 stars 2 forks source link

Cannot build on ArchLinux: “ncursesw/curses.h: No such file or directory” #6

Open kseistrup opened 10 months ago

kseistrup commented 10 months ago

I've attempted to build this on ArchLinux a couple of times, but although it goes well for a long time, it always fails with:

   ⋮
g++ -DHAVE_CONFIG_H -I.  -std=c++20 -g -Wall -Wextra -Iglog-0.4.0/src -DDOCDIR='"/usr/local/share/doc/edge-0.0"' -Werror=return-type -Werror=switch -Werror=unused-function -Werror=missing-field-initializers -Werror=unused-but-set-variable -Werror=range-loop-construct -Wshadow -Wtrampolines -Wnull-dereference -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=native -O2 -pipe -flto -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -MT src/screen_curses.o -MD -MP -MF $depbase.Tpo -c -o src/screen_curses.o src/screen_curses.cc &&\
mv -f $depbase.Tpo $depbase.Po
src/screen_curses.cc:4:10: fatal error: ncursesw/curses.h: No such file or directory
    4 | #include <ncursesw/curses.h>
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:2112: src/screen_curses.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/tmp/build/edge'
make[1]: *** [Makefile:2172: all-recursive] Error 1
make[1]: Leaving directory '/tmp/build/edge'
make: *** [Makefile:1171: all] Error 2

ArchLinux currently includes this curses library:

core/ncurses 6.4_20230520-1 [installed]
    System V Release 4.0 curses emulation library

that has curses.h in /usr/include/:

/usr/include/curses.h
/usr/include/ncurses.h

When I edit the src/screen_curses.cc file to have

 #include <curses.h>

the compilation will fail later on instead:

src/test.cc: In function ‘void TreeTestsLong()’:
src/test.cc:86:41: error: no match for ‘operator=’ (operand types are ‘afc::language::ConstTree<afc::language::VectorBlock<int, 128>, 128>::Ptr’ {aka ‘std::shared_ptr<const afc::language::ConstTree<afc::language::VectorBlock<int, 128>, 128> >’} and ‘afc::language::NonNull<std::shared_ptr<const afc::language::ConstTree<afc::language::VectorBlock<int, 128>, 128> > >’)
   86 |                   T::Suffix(t, position));
      |                                         ^
In file included from /usr/include/c++/13.2.1/memory:80,
                 from ./src/language/safe_types.h:6,
                 from ./src/language/error/value_or_error.h:12,
                 from ./src/language/text/line_column.h:9,
                 from ./src/buffer_variables.h:4,
                 from src/test.cc:7:

I am not a dev. I don't know how to proceed from here. Any suggestions?

kseistrup commented 10 months ago

PS: I tried a make edge in the hope that it would skip the tests, and then I end up with what I believe is a working copy of edge (I still have to use just #include <curses.h>, but the second error described above doesn't occur).

alefore commented 10 months ago

I believe commit 8fdf7f7 should fix the test binaries.

That said, Edge depends on the ncursesw/curses.h header. I don't know how you'd get that in ArchLinux. I know that in Debian this file is provided by package libncurses-dev.

Can you search to see if directory ncursesw exists at all in your system? https://man.archlinux.org/man/ncurses.3x.en#ncursesw has some details, explaining that there's two configurations: ncurses and ncursesw. Edge needs ncursesw (which supports wide characters). I wonder if there's a way to get the ncursesw configuration in ArchLinux.

kseistrup commented 10 months ago

TL:DR: ArchLinux' ncurses package provides the libncursesw library with wide char support, and its header files resides in /usr/include/ (not in a separate subdirectory).

Can you search to see if directory ncursesw exists at all in your system?

It doesn't.

$ locate /ncursesw
/usr/bin/ncursesw6-config
/usr/lib/pkgconfig/ncursesw.pc
/usr/share/man/man1/ncursesw6-config.1.gz

The ncurses package I mentioned earlier provides ncurses and ncursesw (and curses) by employing the alternate configuration described at:

E.g., the /usr/lib/libncurses.so file is an ASCII text file with the following content:

$ cat /usr/lib/libncurses.so
INPUT(-lncursesw)

The ncurses package in ArchLinux provides everything ncurses as ArchLinux doesn't have separate development packages the way e.g. Debian does.

You can see the PKGBUILD file that ArchLinux uses to configure and build the ncurses package here (it's just a bash script):

It does include the --enable-widec, but it does not include the --disable-overwrite option, and the header files are not placed in a separate subdirectory.

I will try and compile the latest commit of edge (editing the #include line, if necessary) and see what the tests say.

alefore commented 10 months ago

Ahhh, that makes sense. Thanks for the update.

These days the majority of the tests can be executed through edge --tests=run. Hopefully you'll be able to build the edge binary, though I suspect you may need to adjust a few #include lines.

kseistrup commented 10 months ago

The following is valid for commit 8fdf7f76ffa167497a7e9e9228b26b1f2dcf95e9

I didn't rerun the configure step since the changes between my original post and now didn't involve configuring, so what I did was: git pull && make clean && make.

The src/screen_curses.cc already had #include <curses.h>, and no other changes were required to fully compile the edge binary, the libglog library and the tests.

Running edge --tests=run mostly went well. I'm incompetent to get anything meaningful out of the error messages, so I have attached the full output (interleaved stdout + stderr) from running the tests.

Running edge leaves behind lots of pipes (e.g., /tmp/edge-server-wBkY4t), temporary files (e.g., /tmp/edge-initial-commands-Z0Tod2) and log files (e.g., $TMPDIR/edge.$HOSTNAME.$USER.log.WARNING.20231109-114524.924184), something I feel that edge should clean up upon exit, but perhaps that is configurable, and it is something for potential other issue anyway, so I am just mentioning it here for the record.

Here $TMPDIR != /tmp.

📎 tests-commit-8fdf7f76ffa167497a7e9e9228b26b1f2dcf95e9.txt

alefore commented 10 months ago

Oh, cool to hear that you managed to get it to run.

Thank you for attaching the output, that's very helpful. Looks like there's a failure in the test HelpCommand::GenerateContents which is ... very strange. All the other tests pass (some tests print stack traces, but that's OK: these tests assert that if the code does something unexpected, the error is caught and, as desired, crashes the program (rather than silently ignore the problem)).

I'll have to look into that to figure out the failure for HelpCommand. Very interesting. I guess that might mean that if you press ? to get the help (while running Edge), Edge may crash? Would you mind filling a separate issue? You can attach the output of edge --tests=run --tests_filter=HelpCommand::GenerateContents.GenerateContents (which will only run the test that is failing and skip all the other less relevant information, about the tests that pass).

You're absolutely right that Edge leaves behind lots and lots of uh garbage files (hopefully all in /tmp or $TMPDIR). It has never bothered me, but I can totally see that it's not very desirable. I guess I'll write some logic to start cleaning up the mess. :-) Maybe we should also file a separate issue to track this, or even separate issues for (1) edge-server-XXXXX pipes, (2) edge-initial-commands-XXXXX, and (3) log files. I think whether #3 should be fixed or is intended behavior is subjective (i.e., I think this is a decision in the Google Logging library, more than in Edge).

Thanks again.

kseistrup commented 10 months ago

I have a meeting so we'll have to wait with the details, but I can confirm that edge somefile.txt crashes with a SIGABRT when I press ? in the editor.