为什么“cabal init”打破“ghc-mod检查”? [英] Why does "cabal init" break "ghc-mod check"?

查看:162
本文介绍了为什么“cabal init”打破“ghc-mod检查”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ghc-mod在一个只有haskell源文件的目录中工作,但如果我在该目录(/ tmp / test)中运行cabal init,则会出现以下错误:

 (p1)dave @ peach:/ tmp / test $!ghc 
ghc -mod check Main.hs
ghc-mod:/ tmp / test / dist / setup-config:hGetContents:无效的参数(无效的字节序列)

这里怎么回事?



我在64位ubuntu 14.04计算机上运行ghc-mod 5.2.11和cabal 1.21.1.0。 LANG环境变量设置为en_US.UTF-8(我看到了对其他一些问题的回应,这些问题表明LANG设置在这里可能很重要)。我试过运行cabal版本1.16.0,但它没有任何区别。



这是一个可以显示更多细节的记录:

 (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版本
ghc-mod版本5.2.1.1由GHC编译7.6.3

(p1)dave @ peach:/ tmp / test $ cabal -V
cabal-install版本1.21 .1.0
使用Cabal库的版本1.21.1.0
$ b $(p1)dave @ peach:/ tmp / test $ ghc -mod check Main.hs
Main.hs: 7:1:警告:没有类型签名的顶级绑定:haqify :: [Char] - > [Char]

(p1)dave @ peach:/ tmp / test $ cabal init
软件包名称? [默认:测试]
软件包版本? [默认值:0.1.0.0]
请选择一个许可证:
* 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)其他(请指定)
您的选择? [默认:(无)] 2
作者姓名? [默认:XXXXXXXXXXXX]
维护者邮件? [默认:XXXXXXXXXXXXXXXXXXXXXX]
项目主页URL?
项目简介?
项目类别:
* 1)(无)
2)编解码器
3)并发
4)控制
5)数据
6 )数据库
7)开发
8)分配
9)游戏
10)图形
11)语言
12)数学
13)网络
14)声音
15)系统
16)测试
17)文本
18)Web
19)其他(具体说明)
你的选择? [默认值:(无)]
包的内容是什么:
1)库
2)可执行文件
您的选择? 2
可执行文件的主要模块是什么:
* 1)Main.hs
2)其他(指定)
您的选择? [默认值:Main.hs]
编写的软件包的基本语言:
* 1)Haskell2010
2)Haskell98
3)其他(指定)
您选择? [默认:Haskell2010]
包含每个字段的含义(y / n)的文档? [默认:n]
源目录:
* 1)(无)
2)src
3)其他(请指定)
您的选择? [默认值:(none)]

猜测依赖项...

生成许可证...
生成Setup.hs ...
生成测试.cabal ...

警告:没有提供任何简介。您应该编辑.cabal文件并添加一个。
您可能想编辑.cabal文件并添加说明字段。
$ b $(p1)dave @ peach:/ tmp / test $!ghc
ghc-mod check Main.hs
ghc-mod:/ tmp / test / dist / setup- config:hGetContents:无效参数(无效字节序列)
(p1)dave @ peach:/ tmp / test $


解决方案




ghc-mod不适用于GHC< 7.10和Cabal-1.22。

如果你仍然在GHC 7.8.3或7.8.4上,你可能想要在
更新cabal或cabal -安装。



ghc-mod works in a directory with just a haskell source file but if I run "cabal init" in that directory (/tmp/test), I get the following error:

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

What's going wrong here?

I'm running ghc-mod 5.2.11, and cabal 1.21.1.0, on a 64 bit ubuntu 14.04 computer. the LANG environment variable is set to en_US.UTF-8 ( I saw responses to some other questions that suggest that the LANG setting may be important here ). I tried running cabal version 1.16.0 but it didn't make any difference.

Here's a transcript that shows more detail:

(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$ 

解决方案


ghc-mod doesn't work with GHC < 7.10 and Cabal-1.22.

If you are still on GHC 7.8.3 or 7.8.4, you may want to hold off on updating cabal or cabal-install.

这篇关于为什么“cabal init”打破“ghc-mod检查”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆