I'm trying to use the Hoe utility from a cabal sandbox and am presented with the following error:
lyndon#endpin ~/Haskell-Sandboxes/hoe-1.0.1 ./.cabal-sandbox/bin/hoe head
compile error: <no location info>:
Could not find module ‘System.Random’
Use -v to see a list of the files searched for.
I believe that this is due to Hoe using Hint to interpret expressions at runtime, and as part of this, expecting to be able to load globally installed modules. However, since I'm using a cabal-sandbox, modules are only installed locally.
I've attempted to look for any environment variables I can use to specify the location of the random module as ./.cabal-sandbox/lib/x86_64-osx-ghc-7.8.3/random-1.1, however nothing obvious has appeared.
22070308 suggested that HASKELL_PACKAGE_SANDBOX might help, but it doesn't seem to.
I actually just came across the solution
Setting GHC_PACKAGE_PATH to include the sandbox, and the default package location:
lyndon#endpin ~/Haskell-Sandboxes/hoe-1.0.1 find ~/ghc_versions/ghc-7.8.3/ | grep package.cache
/Users/lyndon/ghc_versions/ghc-7.8.3//lib/ghc-7.8.3/package.conf.d/package.cache
lyndon#endpin ~/Haskell-Sandboxes/hoe-1.0.1 GHC_PACKAGE_PATH=~/ghc_versions/ghc-7.8.3//lib/ghc-7.8.3/package.conf.d:./.cabal-sandbox/x86_64-osx-ghc-7.8.3-packages.conf.d ./.cabal-sandbox/bin/hoe head
asdf
'a'
Related
Hi I use GHCI and can normally load my files. Now I need to load a file that uses random. I get this error.
Chatterbot.hs:3:1: error:
Could not find module ‘System.Random’
Use -v to see a list of the files searched for.
|
3 | import System.Random
| ^^^^^^^^^^^^^^^^^^^^
This is very weird since it works for my friend who also have just installed GHCI and did nothing other than me. The main difference is that I am on windows. I really don t understand this and have tried googling a bit and many people speak about stack but it seems annoying and It obviously works for my friend without it.
Thanks in advance
EDIT problem solved. I needed to update cabal then I ran cabal install random and it worked well. Thanks everyone for the help!
If you are using a version of cabal-install >= 3.0 (check with cabal --version), then, instead of creating a cabal package, you can move to an empty folder and type:
cabal install --lib --package-env . random
This creates a .ghc.environment file in the folder. ghci sessions started inside that folder will pick it up, and they will be able to import System.Random.
If that works correctly, you might want to install "random" globally so that any invocation of ghci can use it:
cabal install --lib random
This creates/modifies the global environment file located at ~/.ghc/$ARCH-$OS-$GHCVER/environments/default.
The System.Random module is part of the random package, not of the base package. You thus should install it. If you for example use cabal, you can install it with cabal install random.
If you use Haskell stack for example, you can add it to your package-name.cabal file:
-- …
build-depends:
base >=4.7 && <5
, random >=1.0 && <2
I'm developing a website with scaffolded Yesod (stack) and I have to import Yesod.Auth.Account to use internals accounts instead openid or others. But when i try import this module i've this output:
/usr/home/giulio/Lavori/karmen/src/Foundation.hs:27:1: error:
Could not find module `Yesod.Auth.Account'
Use -v to see a list of the files searched for.
|
27 | import Yesod.Auth.Account
| ^^^^^^^^^^^^^^^^^^^^^^^^^
I tried to install the module, build, use stack clean and stack build but
nothing work.
That comes from the yesod-auth-account package which doesn't seem to be on Stackage. This means you must add it to the extra-deps stanza of your stack.yaml file. Docs here.
Probably something like this:
extra-deps:
- yesod-auth-account-1.4.3
You may also want to use the stack solver command.
I am trying to install "threepenny-gui", I simply do it by
cabal install threepenny-gui
It is a school project that I have to use it and you can find the start code here.
After I have installed it and run Calculator.hs without changing anything I get the error
ThreepennyPages.hs:13:18:
Could not find module ‘Data.Aeson’
Perhaps you meant Data.Version (from base-4.8.2.0)
Use -v to see a list of the files searched for.
ThreepennyPictures.hs:17:18:
Could not find module ‘Graphics.UI.Threepenny’
Use -v to see a list of the files searched for.
ThreepennyPictures.hs:18:8:
Could not find module ‘Graphics.UI.Threepenny.Core’
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
I read here in section 4.1 that
This happens when you install a package globally, and the previous packages were installed locally.
But does not give any real solution. How should I install it correctly? Have been having similar problems when installing other modules.
I have a Haskell desktop application that uses Snap. This application has been building for years now and is an everyday part of our fielded solution. I upgraded to a new development machine some months ago, running Windows 10 with version 7.10.3 of the GHC and 1.22.3.0 of the cabal library with 1.22.4.0 of cabal-install. I have installed version 0.9.8.0 of snap-core and version 0.9.5.1 of snap-server.
When I try and build my application in this environment, it get the following error:
Could not find module `Snap.Internal.Http.Server.Exception'
Perhaps you meant
Snap.Internal.Http.Server.Backend
Snap.Internal.Http.Server.Config
Snap.Internal.Http.Server.Date
I cannot find this module in Hackage. Did something change in Snap since I last built this code? Please, any advice will be appreciated.
Dave
P.S. Here are links to the output of the ghc-pkg list command and to the cabal file for this project.
http://zelda.designacourse.com/dave/ghc-pkg_list.txt
http://zelda.designacourse.com/dave/PreviewWrapper.cabal
With the help of, and gratitude to, epsilonhalbe we found a solution to this problem. I still do not know why the import of Snap.Internal.Http.Server.Exception started to throw an error from the compiler. However, removing that import and adding a type declaration to the variable now allows the code to build without error. i.e. catch ((_ :: IOException) -> return True).
I'm new with Haskell and have trouble with its package.
I want to import System.Random but
Could not find module `System.Random'
Then I tried to import System but
Could not find module `System'.
It is a member of the hidden package `haskell98-2.0.0.0'.
I tried to search this problem, but those solutions still don't work.
As this said, I tried to install cabal on my Mac OS X using MacPort, but
Error: The following dependencies were not installed: ghc
Error: Status 1 encountered during processing.
I have installed Haskell Platform and can use ghci in command-line.
GHCi, version 7.2.1
Then I tried to use ghc-pkg expose haskell98-2.0.0.0 as this one says.
But this time, I can't even run ghci.
Top level:
Ambiguous interface for `Prelude':
it was found in multiple packages: base haskell98-2.0.0.0
So, what can I do without using cabal?
The System.Random module belongs to the random package, which is no longer included with GHC as of version 7.2.1.
I'm not sure what to do about your Cabal problem, as I'm not familiar with Mac OS X, but I'd recommend getting that to work first. Installing random should then be trivial using Cabal.
As a possible workaround, you might want to consider using an older version of GHC.
the cabal incantation:
cabal install random
The answer here is a little bit dated and would lead to a global install and should be discouraged.
A better approach will be to add the random package as dependency in the .cabal file.
Something like this:
build-depends: base ^>=4.13.0.0 --base package
, random -- random package where System.Random can be found
cabal repl -b random # -b is short for --build-depends
This answer was based on another stackoverflow thread here. Basically it installs the package random as a dependency of your project rather than installing it globally. Packages are installed globally if you just write cabal install random - which we dont usally want.