首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么“阴谋集团”破坏了"ghc-mod检查“?

为什么“阴谋集团”破坏了"ghc-mod检查“?
EN

Stack Overflow用户
提问于 2014-12-04 15:52:35
回答 2查看 964关注 0票数 3

ghc工作在一个只有一个haskell源文件的目录中,但是如果我在该目录(/tmp/test)中运行"cabal“,则会得到以下错误:

代码语言:javascript
复制
(p1)dave@peach:/tmp/test$ !ghc
ghc-mod check Main.hs 
ghc-mod: /tmp/test/dist/setup-config: hGetContents: invalid argument (invalid byte sequence)

这里出什么问题了?

我正在一台64位的ubuntu14.04计算机上运行ghc 5.2.11和阴谋1.21.1.0。LANG环境变量被设置为en_US.UTF-8 (我看到了对其他一些问题的答复,这些问题表明LANG设置在这里可能很重要)。我试着运行阴谋版本1.16.0,但没有产生任何区别。

这是一份记录,显示了更多细节:

代码语言:javascript
复制
(p1)dave@peach:/tmp/test$ ls -la
total 80
drwxrwxr-x  2 dave dave  4096 Dec  4 07:07 .
drwxrwxrwt 35 root root 69632 Dec  4 07:06 ..
-rw-rw-r--  1 dave dave   143 Dec  4 07:04 Main.hs

(p1)dave@peach:/tmp/test$ set | grep LANG
GDM_LANG=en_US
LANG=en_US.UTF-8
LANGUAGE=en_US

(p1)dave@peach:/tmp/test$ ghc-mod version
ghc-mod version 5.2.1.1 compiled by GHC 7.6.3

(p1)dave@peach:/tmp/test$ cabal -V
cabal-install version 1.21.1.0
using version 1.21.1.0 of the Cabal library 

(p1)dave@peach:/tmp/test$ ghc-mod check Main.hs 
Main.hs:7:1:Warning: Top-level binding with no type signature:  haqify :: [Char] -> [Char]

(p1)dave@peach:/tmp/test$ cabal init
Package name? [default: test] 
Package version? [default: 0.1.0.0] 
Please choose a license:
 * 1) (none)
   2) GPL-2
   3) GPL-3
   4) LGPL-2.1
   5) LGPL-3
   6) AGPL-3
   7) BSD2
   8) BSD3
   9) MIT
  10) ISC
  11) MPL-2.0
  12) Apache-2.0
  13) PublicDomain
  14) AllRightsReserved
  15) Other (specify)
Your choice? [default: (none)] 2
Author name? [default: XXXXXXXXXXXX] 
Maintainer email? [default: XXXXXXXXXXXXXXXXXXXXXX] 
Project homepage URL? 
Project synopsis? 
Project category:
 * 1) (none)
   2) Codec
   3) Concurrency
   4) Control
   5) Data
   6) Database
   7) Development
   8) Distribution
   9) Game
  10) Graphics
  11) Language
  12) Math
  13) Network
  14) Sound
  15) System
  16) Testing
  17) Text
  18) Web
  19) Other (specify)
Your choice? [default: (none)] 
What does the package build:
   1) Library
   2) Executable
Your choice? 2
What is the main module of the executable:
 * 1) Main.hs
   2) Other (specify)
Your choice? [default: Main.hs] 
What base language is the package written in:
 * 1) Haskell2010
   2) Haskell98
   3) Other (specify)
Your choice? [default: Haskell2010] 
Include documentation on what each field means (y/n)? [default: n] 
Source directory:
 * 1) (none)
   2) src
   3) Other (specify)
Your choice? [default: (none)] 

Guessing dependencies...

Generating LICENSE...
Generating Setup.hs...
Generating test.cabal...

Warning: no synopsis given. You should edit the .cabal file and add one.
You may want to edit the .cabal file and add a Description field.

(p1)dave@peach:/tmp/test$ !ghc
ghc-mod check Main.hs 
ghc-mod: /tmp/test/dist/setup-config: hGetContents: invalid argument (invalid byte sequence)
(p1)dave@peach:/tmp/test$ 
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-01-20 15:26:45

ghc-mod不适用于GHC < 7.10和Cabal-1.22. 如果您仍在使用GHC 7.8.3或7.8.4,则可能需要推迟更新阴谋或阴谋安装。

票数 3
EN

Stack Overflow用户

发布于 2015-03-15 13:36:40

简言之:

  1. 在你的项目中使用沙箱;
  2. 在路径变量中添加沙箱所在文件夹的本地路径;
  3. 在那里安装Cabal version <= 1.20.0.6 (版本1.20.0.6是最新版本,不会破坏ghc-mod);
  4. 在路径变量中添加沙箱所在文件夹的本地路径;
  5. 安装到您的沙箱所需的软件包(ghc-mod等)。

转到项目的根文件夹并创建一个沙箱:

代码语言:javascript
复制
cd ~/tmp/test       #go to you project's root directory
cabal sandbox init  #create a sandbox

每次从当前目录运行cabal sandbox init时,它都会在给定目录中创建一个.cabal-sandbox文件夹。如果您将ghc-mod安装到您的沙箱(即隔离的)上,它仍然会使用cabalcabal-install的非沙箱版本来安装它,因为它在您的PATH中。要解决此问题,请在~/.bash_profile文件中添加以下行:

代码语言:javascript
复制
export PATH="./.cabal-sandbox/bin:$PATH"

路径开始处的点意味着您希望在当前目录中搜索一个名为.cabal-sandbox的文件夹,并在其中搜索一个名为bin的子文件夹,其中安装了沙箱包。如果在包含沙箱的文件夹中运行命令,系统将从适当的沙箱运行可执行文件。如果文件夹不包含沙箱,它将使用通常的路径到您的*/.cabal/bin目录。

确保到沙箱的路径位于path变量中到*/.cabal/bin的通常路径之前。您可以使用终端$PATH命令查看路径的顺序。

使用终端~/.bash_profile命令重新加载您的source ~/.bash_profile文件,或者只需关闭&重新打开终端。

接下来安装Cabal version <= 1.20.0.6,它不会破坏ghc-mod

代码语言:javascript
复制
cabal install cabal-install-1.20.0.6  #install the latest cabal supported by ghc-mod

使用终端~/.bash_profile命令重新加载您的source ~/.bash_profile文件,或者只是关闭&重新打开您的终端。

从沙箱的文件夹中运行cabal --version。它应该显示您正在使用cabal-install version 1.20.0.6version 1.20.0.3 of the Cabal library。在没有沙箱的文件夹中运行cabal --version,以查看全局上仍然使用当前版本的cabal-installCabal library

返回到项目的根文件夹并安装到您需要的沙箱包中:

代码语言:javascript
复制
cd ~/tmp/test                 #go to you project's root directory
cabal install ghc-mod-5.2.1.2 #explicitly indicate version of ghc-mod you want to install, otherwise cabal will try to install an ancient version 0.3.0
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27298268

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档