parsonsmatt/intero-neovim

Error while loading shared libraries: libHSnetwork-2.6.3.3

Closed this issue · 2 comments

Ashe commented

Hey there. Intero crashes when I start Intero inside a specific project. Changing the file to another hs file in some other project still crashes Intero, whereas starting intero in another project works perfectly fine (and thus loading a file from the problematic project works, although it doesn't compile due to the wrong project settings being used by intero).

Here's the error I get. Intero crashes when this appears, and any attempt to restart it gives this error. I can't call any intero commands until it has started up, and this is preventing it from doing so:

FirstGameHS-0.1.0.0: initial-build-steps (exe)
Configuring GHCi with the following packages: FirstGameHS
/home/ashe/Documents/FirstGameHS/.stack-work/install/x86_64-linux-tinfo6-nopie/lts-10.7/8.2.2/bin/intero: error while loading shared libraries: libHSnetwork-2.6.3.3-LsInmfJLY3IBO2L8iqXwV9-ghc8.2.2.so: cannot open shared object fi
le: No such file or directory

[Process exited 127]

Here's a copy paste of the cabal of the project that doesn't work:

name:                   FirstGameHS
version:                0.1.0.0
-- synopsis:
-- description:
homepage:               https://github.com/crysikrend/FirstGameHS#readme
license:                BSD3
license-file:           LICENSE
author:                 Ashley Smith
maintainer:             ashley@aas.sh
copyright:              2018 Ashley Smith
category:               Game
build-type:             Simple
cabal-version:          >=1.10
extra-source-files:     README.md
data-dir:               Assets
data-files:             *.bmp

executable FirstGameHS
  hs-source-dirs:       src
  main-is:              Main.hs
  default-language:     Haskell2010
  build-depends:        base >= 4.7 && < 5
                        , sdl2
  other-modules:        Paths_FirstGameHS

Here's the one and only file of the problematic project:

{-# LANGUAGE OverloadedStrings #-}
module Main where

import Control.Monad
import Foreign.C.Types
import SDL.Vect
import SDL (($=))
import qualified SDL

import Paths_FirstGameHS(getDataFileName)

screenWidth, screenHeight :: CInt
(screenWidth, screenHeight) = (640, 480)

loadBMP :: FilePath -> IO SDL.Surface
loadBMP path = getDataFileName path >>= SDL.loadBMP

main :: IO ()
main = do

  -- Initialise SDL
  SDL.initialize [SDL.InitVideo]

  -- Create a window with the correct screensize and make it appear
  window <- SDL.createWindow "SDL Tutorial"
    SDL.defaultWindow { SDL.windowInitialSize = V2 screenWidth screenHeight }
  SDL.showWindow window

  -- Create a renderer for the window for rendering textures
  renderer <-
    SDL.createRenderer
      window
      (-1)
      SDL.RendererConfig
        { SDL.rendererType = SDL.AcceleratedRenderer
        , SDL.rendererTargetTexture = False
        }

  SDL.rendererDrawColor renderer $= V4 maxBound maxBound maxBound maxBound

  -- Make a surface from file
  xOutSurface <- getDataFileName "foo.bmp" >>= SDL.loadBMP
  texture <- SDL.createTextureFromSurface renderer xOutSurface

  -- Free the surface as we have a texture now
  SDL.freeSurface xOutSurface

  let loop = do
        events <- SDL.pollEvents

        let quit = elem SDL.QuitEvent $ map SDL.eventPayload events

        SDL.clear renderer
        SDL.copy renderer texture Nothing (Just $ SDL.Rectangle (P $ V2 0 0) (V2 200 200))
        SDL.present renderer

        unless quit loop

  loop

  SDL.destroyWindow window
  SDL.quit

Finally, I'd like to add that this project does compile both in stack ghci and stack build, and stack exec works perfectly fine too. One thing to take note of is that I have extra data-files being packaged when the game is built, and so Paths_FirstGameHS is a module generated by cabal which allows these files to be moved and included automatically, providing their new path etc.

I followed this guide to achieve this

Ashe commented

While I'm not sure what causes the error, deleting the .stack-work folder seems to fix everything. Not sure where that came from though!

Weird. Definitely reopen if you find this again, please!