SimulaVR / Simula

Linux VR Desktop
MIT License
2.91k stars 87 forks source link

Building dev branch in Ubuntu 20 #145

Closed CaydenPierce closed 2 years ago

CaydenPierce commented 3 years ago

Some issues below. Let me know if there is a better format I can provide this information to help better.

1. Failed to run nsBuildSimulaLocal

Error:

installSimula::9 = command not found *I didn't record the error, this is from human memory

I think this is an issue with zsh

Solution:

comment out lines 209 - 212 in utils/Helpers.sh

2.

Error:

cabal : command not found

Ubuntu 20 uname -a == Linux computername 5.8.0-53-lowlatency #60~20.04.1-Ubuntu SMP PREEMPT Thu May 6 10:59:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Solution:

sudo apt-get install cabal-install
cabal update

I assume this will happen for anyone who doesn't already have Haskell dev utils installed on their system (I've never touched Haskell)

3.

Try to build simula with nsBuildSimulaLocal

Error:

Please switch to using either the new project style and the new-build command
or the legacy v1-build alias as new-style projects will become the default in
the next version of cabal-install. Please file a bug if you cannot replicate a
working v1- use case with the new-style commands.

For more information, see: https://wiki.haskell.org/Cabal/NewBuild

Warning: Unknown/unsupported 'ghc' version detected (Cabal 2.4.0.1 supports
'ghc' version < 8.7):
/nix/store/9kqd7zyc1crfds7fkvmb5di1259zmswx-ghc-8.10.4-with-packages/bin/ghc
is version 8.10.4
Resolving dependencies...
Warning: solver failed to find a solution:
Could not resolve dependencies:
[__0] trying: godot-haskell-plugin-0.1.0.0 (user goal)
[__1] unknown package: godot-haskell (dependency of godot-haskell-plugin)
[__1] fail (backjumping, conflict set: godot-haskell, godot-haskell-plugin)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: godot-haskell-plugin, godot-haskell
Trying configure anyway.
Configuring godot-haskell-plugin-0.1.0.0...
cabal: Encountered missing dependencies:
godot-haskell -any

~/biggem/Tester/SimulaDev
~/biggem/Tester/SimulaDev

Try to launch anyways: ./result/bin/simula_local

Response is a grey GODOT screen in Gnome, SteamVR remains in launcher room, and the following error is given:

ERROR: bind_methodfi: Class WlrXdgSurface already has a method get_geometry.
   At: core/class_db.cpp:1232.
ERROR: open_dynamic_library: Can't open dynamic library: /home/cayden/biggem/Tester/SimulaDev/addons/godot-haskell-plugin/libgodot-haskell-plugin.so. Error: /home/cayden/biggem/Tester/SimulaDev/submodules/godot/bin/../lib/libgodot-haskell-plugin.so: cannot open shared object file: No such file or directory
   At: drivers/unix/os_unix.cpp:432.
ERROR: get_symbol: No valid library handle, can't get symbol from GDNative object
   At: modules/gdnative/gdnative.cpp:483.
ERROR: init_library: No nativescript_init in "res://addons/godot-haskell-plugin/libgodot-haskell-plugin.so" found
   At: modules/gdnative/nativescript/nativescript.cpp:1506.

Solution:

not yet resolved, working on it

CaydenPierce commented 3 years ago

Error 3

In the command nsBuildSimulaLocal

nsBuildGodotHaskell runs successfully

Error occurs when nsBuildGodotHaskellPlugin is run:

arning: The build command is a part of the legacy v1 style of cabal usage.

Please switch to using either the new project style and the new-build command
or the legacy v1-build alias as new-style projects will become the default in
the next version of cabal-install. Please file a bug if you cannot replicate a
working v1- use case with the new-style commands.

For more information, see: https://wiki.haskell.org/Cabal/NewBuild

Warning: Unknown/unsupported 'ghc' version detected (Cabal 2.4.0.1 supports
'ghc' version < 8.7):
/nix/store/9kqd7zyc1crfds7fkvmb5di1259zmswx-ghc-8.10.4-with-packages/bin/ghc
is version 8.10.4
Resolving dependencies...
Warning: solver failed to find a solution:
Could not resolve dependencies:
[__0] trying: godot-haskell-plugin-0.1.0.0 (user goal)
[__1] unknown package: godot-haskell (dependency of godot-haskell-plugin)
[__1] fail (backjumping, conflict set: godot-haskell, godot-haskell-plugin)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: godot-haskell-plugin, godot-haskell
Trying configure anyway.
Configuring godot-haskell-plugin-0.1.0.0...
cabal: Encountered missing dependencies:
godot-haskell -any

~/biggem/Tester/SimulaDev
georgewsinger commented 3 years ago

This might be a cabal issue. Can you tell me the output of

cabal --version

? Mine is 3.4.0.0. If you're getting something lower, can you try deleting cabal on your system and installing via

nix-env -iA nixpkgs.cabal-install

and then re-running cabal update?

CaydenPierce commented 3 years ago

Output of cabal --version:

cabal-install version 2.4.0.0
compiled using version 2.4.0.1 of the Cabal library 

Run sudo apt-get remove cabal-install

Run nix-env -iA nixpkgs.cabal-install -> Successful install

Now cabal --version:

cabal-install version 3.4.0.0
compiled using version 3.4.0.0 of the Cabal library

Again run:

source ./utils/Helpers.sh #this is my modified version of Helpers.sh, see original comment above
nsBuildSimulaLocal

Build successful.

Run ./result/bin/simula_local after launching SteamVR SimulaVR window appears, then crashes, Error:

WARNING: load: Loaded resource as image file, this will not work on export: 'res://cursor.png'. Instead, import the image file as an Image resource and load it normally as a resource.
   At: core/image.cpp:1880.
WARNING: load: Loaded resource as image file, this will not work on export: 'res://cursor_plus.png'. Instead, import the image file as an Image resource and load it normally as a resource.
   At: core/image.cpp:1880.
touch: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /nix/store/4712fsjq670jsqjrpkkmpfzhi9g1k4nj-systemd-247.3/lib/libsystemd.so.0)
touch: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/librt.so.1)
touch: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /nix/store/8nxvl94y69nsi0bc5glzakpmd1v755k2-xz-5.2.5/lib/liblzma.so.5)
touch: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libpthread.so.0)
touch: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /nix/store/bqgh27q7fhkavvn7jf7gmyy084n5xgy2-glib-2.66.4/lib/libglib-2.0.so.0)
libGodotHaskellPlugin.so: readCreateProcess: touch "./log.txt" (exit 1): failed
J: warning: too many hs_exit()s

Attempted to run sudo apt-get install libc6, remove /result/ dir (probably not the right way to clean the build) and rebuild. Same error.

Bedtime for me will look at further tomorrow.

georgewsinger commented 3 years ago

Can you tell me the output of lsb_release -a and ldd --version ldd? For reference, on my machine it's:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.10
Release:    20.10
Codename:   groovy

$ ldd --version ldd
ldd (Ubuntu GLIBC 2.32-0ubuntu3) 2.32
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
georgewsinger commented 3 years ago

There's an issue with dev build only which requires that your system glibc version must match our current nix glibc version (2.32). If you switch to Ubuntu 20.10, this should fix the issue.

We haven't fixed this issue so far because it's only an issue with dev builds, and we've been the only devs (until now : )

georgewsinger commented 3 years ago

Here's a fuller explanation of the issue, as I understand it:

The error

touch: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /nix/store/4712fsjq670jsqjrpkkmpfzhi9g1k4nj-systemd-247.3/lib/libsystemd.so.0)

comes from our call to

readProcess "touch" ["./log.txt"] []

Now readProcess ultimately wraps a call to a system /bin/sh

image

which depends upon your system GLIBC:

$ ldd /bin/sh
    linux-vdso.so.1 (0x00007ffdd8b7d000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f79bea4b000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f79bec7a000)

This isn't usually a problem, but in dev branch we set the environment variable LD_PRELOAD=./submodules/wlroots/build/libwlroots.so.0, which depends upon our nix glibc version:

$ ldd ./submodules/wlroots/build/libwlroots.so.0 | grep glibc
    libm.so.6 => /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libm.so.6 (0x00007ff9798cb000)
    librt.so.1 => /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/librt.so.1 (0x00007ff9796f0000)
    libc.so.6 => /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6 (0x00007ff97952d000)
    libpthread.so.0 => /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libpthread.so.0 (0x00007ff97937d000)
    libdl.so.2 => /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libdl.so.2 (0x00007ff9792b0000)
    libresolv.so.2 => /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libresolv.so.2 (0x00007ff978d64000)

So the conflict between the two versions cause the error.

Ways to fix. One way to fix the issue would be to replace our calls to readProcess to an altered readProcess' which ultimately wraps a call to our nix ${stdenv}/bin/sh (perhaps stored in ./result/bin/sh) instead of our system /bin/sh.

CaydenPierce commented 3 years ago

Alright, thanks to some messing around and help from @georgewsinger dev is building and running on my box.

Steps:

  1. Install Ubuntu 20.10. 20.04, 21 will NOT work.
  2. git clone --recursive --branch dev https://https://github.com/SimulaVR/Simula SimulaDev
    cd SimulaDev
  3. Edit utils/Helpers.sh bug/issue (I think only for zsh due to error) and comment out lines 209 - 212
  4. source ./utils/Helpers.sh
  5. Install cabal in simula nix environment: nix-env -iA nixpkgs.cabal-install
  6. nsBuildSimulaLocal
  7. Launch Steam + SteamVR
  8. ./results/bin/simula_local
  9. Success!
georgewsinger commented 3 years ago
    elif [ $1 == "i" ]; then    
      switchToNix      
      NIXPKGS_ALLOW_UNFREE=1 nix-instantiate -Q -K default.nix --arg 
      onNixOS "$(checkIfNixOS)" --arg devBuild "true"      
      switchToLocal

From https://github.com/SimulaVR/Simula/blob/6766f578e07755cd7710e083999bcebd64e577fd/utils/Helpers.sh#L209

CaydenPierce commented 3 years ago
  • We've added cabal to Simula in recent dev commits, so step (5) should no longer be needed.

Great.

  • RE (3), were these the problematic lines for zsh?
    elif [ $1 == "i" ]; then    
      switchToNix      
      NIXPKGS_ALLOW_UNFREE=1 nix-instantiate -Q -K default.nix --arg 
      onNixOS "$(checkIfNixOS)" --arg devBuild "true"      
      switchToLocal

Yes. Specifically the first line. According to this StackOverflow answer, POSIX specifies =, not == for string comparison. That's important only because it will allow all (POSIX-ish) shells to be compatible.

So we change

elif [ $1 == "i" ]; then 

to

elif [ "$1" = "i" ]; then 

and this successfully runs on zsh. You can see for yourself by running executing the following script with zsh and bash:

if [ "$1" = "i" ]; then
    echo "YES"
else
    echo "NO"
fi

E.g. bash myscript.sh i

  • RE (1): If we fix the /bin/sh Haskell issue (discussed above), then Simula dev branch should work on any version of Ubuntu/distro.

OK. I included it above as instructions for anyone else trying to build dev branch. If this issue is still around next week I will take a look.

CaydenPierce commented 2 years ago

Working on this over at: https://github.com/CaydenPierce/Simula/commits/compat

So far have: -modified installSimula to be POSIX compatible (fix string comparison that was failing in zsh) -removed LD_PRELOAD from simula launch scripts that are generated in Simula.nix -added a patchGodotWlroots function in utils/Helpers.sh to patch the godot executable to point to our locally built wlroot lib -tested fresh dev build and run in Ubuntu 20.10

TODO: -test in Ubuntu 18, Ubuntu 21, any GNU/Linux that ISN'T using glibc 2.32 by default

CaydenPierce commented 2 years ago

Fixed with merge e9b3666c023f345c57b2b16e0cf48df084a0467e