JeffreyBenjaminBrown / hode

rslt, take five-ish
GNU General Public License v3.0
147 stars 4 forks source link

Can't `stack run` on macOS #3

Closed adaszko closed 5 years ago

adaszko commented 5 years ago

Hi, this is an amazing project. I was trying to build it on macOS and failed due to a dependency on a X11 library:

(master)% stack run
X11-1.9: configure
kan-extensions-5.2: download
X11-1.9: build
kan-extensions-5.2: configure
kan-extensions-5.2: build
kan-extensions-5.2: copy/register
lens-4.17: download
lens-4.17: configure
lens-4.17: build
lens-4.17: copy/register
Progress 3/6

--  While building package X11-1.9 using:
      /private/var/folders/t5/cscwwl_n3n1_8_5j_00x_3t40000gn/T/stack-3bc6286fcc933911/X11-1.9/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/setup --builddir=.stack-work/dist/x86_64-osx/Cabal-2.4.0.1 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/adaszko/repos/hode/.stack-work/logs/X11-1.9.log

    [1 of 2] Compiling Main             ( /private/var/folders/t5/cscwwl_n3n1_8_5j_00x_3t40000gn/T/stack-3bc6286fcc933911/X11-1.9/Setup.hs, /private/var/folders/t5/cscwwl_n3n1_8_5j_00x_3t40000gn/T/stack-3bc6286fcc933911/X11-1.9/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/Main.o )

    /private/var/folders/t5/cscwwl_n3n1_8_5j_00x_3t40000gn/T/stack-3bc6286fcc933911/X11-1.9/Setup.hs:6:29: warning: [-Wdeprecations]
        In the use of ‘defaultUserHooks’
        (imported from Distribution.Simple):
        Deprecated: "Use simpleUserHooks or autoconfUserHooks, unless you need Cabal-1.2
                 compatibility in which case you must stick with defaultUserHooks"
      |
    6 | main = defaultMainWithHooks defaultUserHooks
      |                             ^^^^^^^^^^^^^^^^
    [2 of 2] Compiling StackSetupShim   ( /Users/adaszko/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /private/var/folders/t5/cscwwl_n3n1_8_5j_00x_3t40000gn/T/stack-3bc6286fcc933911/X11-1.9/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/StackSetupShim.o )
    Linking /private/var/folders/t5/cscwwl_n3n1_8_5j_00x_3t40000gn/T/stack-3bc6286fcc933911/X11-1.9/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/setup ...
    Warning: defaultUserHooks in Setup script is deprecated.
    Configuring X11-1.9...
    configure: WARNING: unrecognized options: --with-hc
    checking for gcc... /usr/bin/gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether /usr/bin/gcc accepts -g... yes
    checking for /usr/bin/gcc option to accept ISO C89... none needed
    checking how to run the C preprocessor... /usr/bin/gcc -E
    checking for X... libraries /usr/X11/lib, headers /usr/X11/include
    checking whether -R must be followed by a space... neither works
    checking for gethostbyname... yes
    checking for connect... yes
    checking for remove... yes
    checking for shmat... yes
    checking for IceConnectionNumber in -lICE... yes
    checking whether to build Xinerama... yes
    checking for grep that handles long lines and -e... /usr/local/bin/ggrep
    checking for egrep... /usr/local/bin/ggrep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking X11/extensions/Xinerama.h usability... yes
    checking X11/extensions/Xinerama.h presence... yes
    checking for X11/extensions/Xinerama.h... yes
    checking X11/extensions/Xrandr.h usability... yes
    checking X11/extensions/Xrandr.h presence... yes
    checking for X11/extensions/Xrandr.h... yes
    checking X11/extensions/scrnsaver.h usability... yes
    checking X11/extensions/scrnsaver.h presence... yes
    checking for X11/extensions/scrnsaver.h... yes
    checking whether to include X.org keysyms... yes
    checking X11/keysym.h usability... yes
    checking X11/keysym.h presence... yes
    checking for X11/keysym.h... yes
    checking X11/DECkeysym.h usability... yes
    checking X11/DECkeysym.h presence... yes
    checking for X11/DECkeysym.h... yes
    checking X11/Sunkeysym.h usability... yes
    checking X11/Sunkeysym.h presence... yes
    checking for X11/Sunkeysym.h... yes
    checking X11/ap_keysym.h usability... yes
    checking X11/ap_keysym.h presence... yes
    checking for X11/ap_keysym.h... yes
    checking X11/HPkeysym.h usability... yes
    checking X11/HPkeysym.h presence... yes
    checking for X11/HPkeysym.h... yes
    checking X11/XF86keysym.h usability... yes
    checking X11/XF86keysym.h presence... yes
    checking for X11/XF86keysym.h... yes
    checking X11/keysymdef.h usability... yes
    checking X11/keysymdef.h presence... yes
    checking for X11/keysymdef.h... yes
    checking X11/cursorfont.h usability... yes
    checking X11/cursorfont.h presence... yes
    checking for X11/cursorfont.h... yes
    configure: creating ./config.status
    config.status: creating config.mk
    config.status: creating X11.buildinfo
    config.status: creating include/HsX11Config.h
    config.status: creating include/X11_extras_config.h
    configure: WARNING: unrecognized options: --with-hc
    Preprocessing library for X11-1.9..
    In file included from AP.hsc:166:
    In file included from include/HsAllKeysyms.h:48:
    /opt/X11/include/X11/HPkeysym.h:58:9: warning: '_HPKEYSYM_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
    #ifndef _HPKEYSYM_H
            ^~~~~~~~~~~
    /opt/X11/include/X11/HPkeysym.h:60:9: note: '_HPKEYSYM' is defined here; did you mean '_HPKEYSYM_H'?
    #define _HPKEYSYM
            ^~~~~~~~~
            _HPKEYSYM_H
    1 warning generated.
    In file included from DEC.hsc:111:
    In file included from include/HsAllKeysyms.h:48:
    /opt/X11/include/X11/HPkeysym.h:58:9: warning: '_HPKEYSYM_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
    #ifndef _HPKEYSYM_H
            ^~~~~~~~~~~
    /opt/X11/include/X11/HPkeysym.h:60:9: note: '_HPKEYSYM' is defined here; did you mean '_HPKEYSYM_H'?
    #define _HPKEYSYM
            ^~~~~~~~~
            _HPKEYSYM_H
    1 warning generated.
    In file included from HP.hsc:504:
    In file included from include/HsAllKeysyms.h:48:
    /opt/X11/include/X11/HPkeysym.h:58:9: warning: '_HPKEYSYM_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
    #ifndef _HPKEYSYM_H
            ^~~~~~~~~~~
    /opt/X11/include/X11/HPkeysym.h:60:9: note: '_HPKEYSYM' is defined here; did you mean '_HPKEYSYM_H'?
    #define _HPKEYSYM
            ^~~~~~~~~
            _HPKEYSYM_H
    1 warning generated.
    In file included from Sun.hsc:236:
    In file included from include/HsAllKeysyms.h:48:
    /opt/X11/include/X11/HPkeysym.h:58:9: warning: '_HPKEYSYM_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
    #ifndef _HPKEYSYM_H
            ^~~~~~~~~~~
    /opt/X11/include/X11/HPkeysym.h:60:9: note: '_HPKEYSYM' is defined here; did you mean '_HPKEYSYM_H'?
    #define _HPKEYSYM
            ^~~~~~~~~
            _HPKEYSYM_H
    1 warning generated.
    In file included from XF86.hsc:915:
    In file included from include/HsAllKeysyms.h:48:
    /opt/X11/include/X11/HPkeysym.h:58:9: warning: '_HPKEYSYM_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
    #ifndef _HPKEYSYM_H
            ^~~~~~~~~~~
    /opt/X11/include/X11/HPkeysym.h:60:9: note: '_HPKEYSYM' is defined here; did you mean '_HPKEYSYM_H'?
    #define _HPKEYSYM
            ^~~~~~~~~
            _HPKEYSYM_H
    1 warning generated.
    In file included from XorgDefault.hsc:10047:
    In file included from include/HsAllKeysyms.h:48:
    /opt/X11/include/X11/HPkeysym.h:58:9: warning: '_HPKEYSYM_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
    #ifndef _HPKEYSYM_H
            ^~~~~~~~~~~
    /opt/X11/include/X11/HPkeysym.h:60:9: note: '_HPKEYSYM' is defined here; did you mean '_HPKEYSYM_H'?
    #define _HPKEYSYM
            ^~~~~~~~~
            _HPKEYSYM_H
    1 warning generated.
    Building library for X11-1.9..
    [ 1 of 28] Compiling Graphics.X11.Types ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Types.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Types.o )
    [ 2 of 28] Compiling Graphics.X11.ExtraTypes.XorgDefault ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/XorgDefault.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/XorgDefault.o )
    [ 3 of 28] Compiling Graphics.X11.ExtraTypes.XF86 ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/XF86.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/XF86.o )
    [ 4 of 28] Compiling Graphics.X11.ExtraTypes.Sun ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/Sun.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/Sun.o )
    [ 5 of 28] Compiling Graphics.X11.ExtraTypes.HP ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/HP.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/HP.o )
    [ 6 of 28] Compiling Graphics.X11.ExtraTypes.DEC ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/DEC.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/DEC.o )
    [ 7 of 28] Compiling Graphics.X11.ExtraTypes.AP ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/AP.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes/AP.o )
    [ 8 of 28] Compiling Graphics.X11.ExtraTypes ( Graphics/X11/ExtraTypes.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/ExtraTypes.o )
    [ 9 of 28] Compiling Graphics.X11.Xlib.Internal ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Internal.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Internal.o )
    [10 of 28] Compiling Graphics.X11.Xlib.Types ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Types.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Types.o )
    [11 of 28] Compiling Graphics.X11.Xlib.Screen ( Graphics/X11/Xlib/Screen.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Screen.o )
    [12 of 28] Compiling Graphics.X11.Xlib.Region ( Graphics/X11/Xlib/Region.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Region.o )
    [13 of 28] Compiling Graphics.X11.Xlib.Image ( Graphics/X11/Xlib/Image.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Image.o )
    [14 of 28] Compiling Graphics.X11.Xlib.Font ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Font.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Font.o )
    [15 of 28] Compiling Graphics.X11.Xlib.Cursor ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Cursor.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Cursor.o )
    [16 of 28] Compiling Graphics.X11.Xlib.Display ( Graphics/X11/Xlib/Display.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Display.o )
    [17 of 28] Compiling Graphics.X11.Xlib.Event ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Event.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Event.o )
    [18 of 28] Compiling Graphics.X11.Xlib.Context ( Graphics/X11/Xlib/Context.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Context.o )
    [19 of 28] Compiling Graphics.X11.Xlib.Color ( Graphics/X11/Xlib/Color.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Color.o )
    [20 of 28] Compiling Graphics.X11.Xlib.Atom ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Atom.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Atom.o )
    [21 of 28] Compiling Graphics.X11.Xlib.Misc ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Misc.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Misc.o )
    [22 of 28] Compiling Graphics.X11.Xlib.Window ( Graphics/X11/Xlib/Window.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Window.o )
    [23 of 28] Compiling Graphics.X11.Xlib ( Graphics/X11/Xlib.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib.o )
    [24 of 28] Compiling Graphics.X11.XScreenSaver ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/XScreenSaver.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/XScreenSaver.o )
    [25 of 28] Compiling Graphics.X11     ( Graphics/X11.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11.o )
    [26 of 28] Compiling Graphics.X11.Xrandr ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xrandr.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xrandr.o )
    [27 of 28] Compiling Graphics.X11.Xlib.Extras ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Extras.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xlib/Extras.o )
    [28 of 28] Compiling Graphics.X11.Xinerama ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xinerama.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Graphics/X11/Xinerama.o )
    ld: library not found for -lXss
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    `gcc' failed in phase `Linker'. (Exit code: 1)
zsh: exit 1     stack run

Can the dependency be made optional so that the project is usable on macOS too?

JeffreyBenjaminBrown commented 5 years ago

I believe MacOS uses X11. Recent versions of MacOS are based on Linux.

[EDIT: I was wrong about this.] X11 is a dependency because the project uses Brick. Brick is implemented using Vty, which includes a note that it does not support Windows, which leads me to suspect it supports Mac.

Can you run terminfo in your terminal? If not, do you have another terminal app in which it does run? (terminfo is what Vty uses to figure out how to talk to the terminal.)

Can you run any of the example programs from Brick or Vty?

The GUI is a small fraction of the entire codebase. In the worst case you could remove all the GUI code and the Brick and Vty dependencies, and use it from GHCI. I wouldn't recommend that as a regular application experience -- too slow --- but it might be useful if you're just trying to get a sense for what's possible in Hode.

JeffreyBenjaminBrown commented 5 years ago

I just realized there's a much better worst-case possibility: using Docker we can create a portable Linux that runs on your Mac, with Hode already installed. If you find yourself without terminals that respond to terminfo let me know and I'll make one and put it on DockerHub.

adaszko commented 5 years ago

This has nothing to do with terminal capabilities. The problem is the dependency on Clipboard, which in turn, depends on X11. See left hand side of (sorry, GitHub doesn't support SVG):

deps

JeffreyBenjaminBrown commented 5 years ago

That's great news! (And accompanied by an outstanding picture! What did you use to draw that?)

Tonight I'll make a branch where UI.Clipboard doesn't do anything. Later, if someone finds a way to make that module platform-agnostic, I'll join the two branches again. In the meantime I'll be able to keep the no-Clipboard version in sync easily, but I might forget to do it until prompted.

JeffreyBenjaminBrown commented 5 years ago

It turns out I wasn't even using the Clipboard library! I've removed the dependency. Please let me know whether it works for you now.

adaszko commented 5 years ago

Great. I can confirm now that stack run builds the project successfully!

The dependency graph was produced by stack dot command.

adaszko commented 5 years ago

The GUI is a small fraction of the entire codebase. In the worst case you could remove all the GUI code and the Brick and Vty dependencies, and use it from GHCI. I wouldn't recommend that as a regular application experience -- too slow --- but it might be useful if you're just trying to get a sense for what's possible in Hode.

I think there's a usable middle ground: a REPL with autocompletion. It is very hard to interface the ncurses interface with other apps, like a text editor such as Vim.

JeffreyBenjaminBrown commented 5 years ago

Great. I can confirm now that stack run builds the project successfully!

Sweet!

I think there's a usable middle ground: a REPL with autocompletion. It is very hard to interface the ncurses interface with other apps, like a text editor such as Vim.

Interesting. Can you point me at some model (Haskell) code that does that?

adaszko commented 5 years ago

I was thinking of something based on either haskeline or maybe even repline. I haven't used any of the two packages but GHCi uses haskeline so it should be solid.

adaszko commented 5 years ago

Thank you!

JeffreyBenjaminBrown commented 4 years ago

The UI just got formally (in the sense that stack understands the change) divided from the rest of the code.