2014-12-04 8 views
3

GHC-모드 작동하지만 내가 그 디렉토리 (/ tmp를/시험)의 "음모 초기화"를 실행하면, 나는 다음과 같은 오류 얻을 :"cabal init"이 "ghc-mod check"를 중단하는 이유는 무엇입니까? 단지 하스켈 소스 파일이있는 디렉토리에

(p1)[email protected]:/tmp/test$ !ghc 
ghc-mod check Main.hs 
ghc-mod: /tmp/test/dist/setup-config: hGetContents: invalid argument (invalid byte sequence) 

잘못 여기서 뭐하는거야을 ?

64 비트 우분투 14.04 컴퓨터에서 ghc-mod 5.2.11 및 cabal 1.21.1.0을 실행 중입니다. LANG 환경 변수가 en_US.UTF-8로 설정되었습니다 (여기서 LANG 설정이 중요 할 수 있음을 제안하는 다른 질문에 대한 응답을 보았습니다). 나는 cabal 버전 1.16.0을 실행 해 보았지만 아무런 차이가 없었습니다. 한마디로

(p1)[email protected]:/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)[email protected]:/tmp/test$ set | grep LANG 
GDM_LANG=en_US 
LANG=en_US.UTF-8 
LANGUAGE=en_US 

(p1)[email protected]:/tmp/test$ ghc-mod version 
ghc-mod version 5.2.1.1 compiled by GHC 7.6.3 

(p1)[email protected]:/tmp/test$ cabal -V 
cabal-install version 1.21.1.0 
using version 1.21.1.0 of the Cabal library 

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

(p1)[email protected]:/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)[email protected]:/tmp/test$ !ghc 
ghc-mod check Main.hs 
ghc-mod: /tmp/test/dist/setup-config: hGetContents: invalid argument (invalid byte sequence) 
(p1)[email protected]:/tmp/test$ 
+0

GHC-모드 실행'음모 configure', 그래서 나는 그 명령의 출력을 캡처하고 의심스러운 아무것도 볼 수 있는지 것 . – ErikR

+0

또한'ghc-mod check ...'를 실행하기 전에'cabal configure'를 실행하면 어떻게됩니까? – ErikR

+1

또한'dist/setup-config' 파일을 확인하십시오. 'cab config '를 실행 한 후'ghc-mod' 파일을 읽습니다. – ErikR

답변

3

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.

+0

님이 nix 설치 후 문제를 일으킬 수 있다고 믿을 수 없습니다 ... grr – nicolas

+1

more info : https://mail.haskell.org/pipermail/haskell-cafe/2015-Jauary/117692.html –

1

: 여기

자세히 보여주는 증명서의 프로젝트에

  1. 사용 샌드 박스;
  2. PATH 변수에 샌드 박스가있는 폴더의 로컬 경로를 추가합니다.
  3. 거기에 Cabal version <= 1.20.0.6 (버전 1.20.0.6은 ghc-mod을 깨지 않는 최신 버전 임);
  4. PATH 변수에 샌드 박스가있는 폴더의 로컬 경로를 추가합니다.
  5. 샌드 박스 필수 패키지 (ghc-mod 등)에 설치하십시오.

는 프로젝트의 루트 폴더로 이동하여 샌드 박스를 만들 :

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에 있기 때문에 샌드 박스 버전을 설치합니다.

export PATH="./.cabal-sandbox/bin:$PATH" 

경로의 시작 부분에있는 점은 당신의 샌드 박스 위치를 하위 폴더에 .cabal-sandbox라는 이름의 폴더가 bin라는 이름의 현재 디렉토리에서 검색 할 것을 의미 :이 문제를 해결하려면 ~/.bash_profile 파일에 다음 행을 추가 패키지가 설치됩니다. 샌드 박스를 포함하는 폴더 내에서 명령을 실행하면 시스템은 적절한 샌드 박스에서 실행 파일을 실행합니다. 폴더에 샌드 박스가 없으면 */.cabal/bin 디렉토리의 일반적인 경로를 사용합니다.

PATH 변수에 평소 경로 인 */.cabal/bin 앞에 샌드 박스 경로가 있는지 확인하십시오. 터미널 $PATH 명령을 사용하여 경로 순서를 볼 수 있습니다.

파일을 터미널 source ~/.bash_profile 명령으로 다시로드하거나 & 터미널을 다시 닫으십시오.터미널 source ~/.bash_profile 명령을

cabal install cabal-install-1.20.0.6 #install the latest cabal supported by ghc-mod 

다시로드 다시 ~/.bash_profile 파일을하거나 가까운 &는 터미널을 다시 :

다음 ghc-mod을 중단하지 않는 Cabal version <= 1.20.0.6를 설치합니다.

sandbox '폴더의 cabal --version을 실행하십시오. cabal-install version 1.20.0.6version 1.20.0.3 of the Cabal library을 사용 중이어야합니다. 샌드 박스가없는 폴더에서 cabal --version을 실행하면 현재 사용중인 cabal-installCabal library의 최신 버전을 계속 사용할 수 있습니다. 프로젝트의 루트 폴더에

반환하고 당신이 필요로하는 샌드 박스 패키지로 설치 :

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 
+0

detaied 정보를 제공해 주셔서 감사합니다. 아아, 이것은 GHC 7.6.3에서 나에게 효과가 없었습니다. 나는 여전히 hGetContents : 잘못된 인수 (유효하지 않은 바이트 순서)와 cabal, cabal-install, ghc-mod의 버전을 확인하고 sandbox 버전 (사용 중)을 실행 중임을 확인했습니다. –

+0

바보 같은 짓을 저지른 Cabal 빌드를 수행하는 것을 잊었습니다. 위의 지시 후에 다시! 지금 일하고있다. –