Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Tags more
Archives
Today
Total
관리 메뉴

HASKELL

Haskell Stack: Golbal vs. Project 본문

Environment

Haskell Stack: Golbal vs. Project

__main__ 2018. 9. 16. 13:00

Haskell stack: global vs. project


1. Project 

 stack new 명령으로 project folder를 만든 후에 stack ghci 명령을 실행하였다. 아직 ghc가 설치되지 않아서 이를 설치하되, "Preparing to install GHC to an isolated location. This will not interfere with any system-level installation."이라는 메시지를 띄우면서 project에 한정되도록 설치를 한다는 메시지가 뜬다. 

PS C:\Documents> stack new hsproj
Downloading template "new-template" to create project "hsproj" in hsproj\ ...

The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in D:\HaskellStack\config.yaml, like this:
templates:
  params:
    author-email: value
    author-name: value
    category: value
    copyright: value
    github-username: value
Or you can pass each one as parameters like this:
stack new hsproj new-template -p "author-email:value" -p "author-name:value" -p "category:value" -p "copyright:value" -p "github-username:value"

Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- hsproj\

Selecting the best among 14 snapshots...

Downloaded lts-12.9 build plan.
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcom

Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcom

Downloading root
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcom

Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcom

Downloading timestamp
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcom

Downloading snapshot
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcom

Downloading mirrors
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcom

Cannot update index (no local copy)
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcom

Downloading index
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcom

Updated package index downloaded
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcom

Update complete
Populated index cache.
* Matches lts-12.9

Selected resolver: lts-12.9
Initialising configuration using resolver: lts-12.9
Total number of user packages considered: 1
Writing configuration to file: hsproj\stack.yaml
All done.

PS C:\Documents> cd hsproj

PS C:\Documents\hsproj> stack ghci
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-8.4.3.
Downloaded 7z.dll.
Downloaded 7z.exe.

...
...

Everything is Ok

Folders: 698
Files: 13859
Size:       270783149
Compressed: 281825280
Copying skeleton files.
These files are for the users to personalise their msys2 experience.

...


 그럼 project에 한정하여 ghc를 isolated location에 설치했으니 project 밖에서 stack ghci 명령을 실행하면 에러가 나는지 확인해보고 싶다. 아래와 같이 해보니 에러가 나지는 않고, 명시적이 아닌 암시적으로 global project setting에 대한 파일을 생성하고 있다. 그리고 project에서 stack ghci를 실행하면서 설치되었던 ghc 버전을 사용하여 ghci REPL을 열고 있다. 

PS C:\Users\K\Documents\hsproj> cd ..                                           
PS C:\Users\K\Documents> stack ghci                                             
Writing implicit global project config file to: D:\HaskellStack\global-project\sck.yaml                                                                         
Note: You can change the snapshot via the resolver field there.                 
Using latest snapshot resolver: lts-12.9                                        
                                                                                
Note: No local targets specified, so a plain ghci will be started with no packag hiding or package  options.                                                                  
                                                                                
If you want to use package hiding and options, then you can try one of the following:                                                                       
                                                                                
* If you want to start a different project configuration than D:\HaskellStack\global-project\stack.yaml, then you can use stack it to create a new stack.yaml for the packages in the current directory.                   
                                                                                
      * If you want to use the project configuration                            
        at D:\HaskellStack\global-project\stack.yaml, then you can add to its 'pkages' field.                                                                   
                                                                                
Configuring GHCi with the following packages:                                   
GHCi, version 8.4.3: http://www.haskell.org/ghc/  :? for help                   
Loaded GHCi configuration from C:\Users\K\AppData\Local\Temp\haskell-stack-ghci\3bbd58\ghci-script                                                              
Prelude> :q                                                                     


2. Global 

 Project를 만들지 않고 아무 폴더에서 stack ghci 명령을 실행하였다. 당연히 ghc가 설치되지 않은 상태라서 ghc를 먼저 설치하는데, global project라고 암시적으로 가정하고 그에 대한 setting 파일인 stack.yaml 파일을 만들면서 시작한다. 그리고 그 다음에 다시 project를 stack new 명령으로 만든 후에 그 폴더에서 stack ghci를 실행하면 이 global 하게 설치했던 ghc를 사용하는 것 같다. 그러나 이는 추측일 뿐이다. local project와 global ghc를 설치한 시간 차이가 없어서 그럴 뿐이다. 새로운 버전의 ghc가 나왔다면 서로 다른 버전의 gch를 여러 개 설치하여 용량이 엄청나게 늘어나게 된다. (이 문제에 대해 좀 더 살펴봐야 하겠다.)

PS D:\HaskellStack> stack ghci
Writing implicit global project config file to: D:\HaskellStack\global-project\stack.yaml
Note: You can change the snapshot via the resolver field there.
Using latest snapshot resolver: lts-12.9
Downloaded lts-12.9 build plan.
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
ghc-8.4.3:   49.53 KiB / 183.45 MiB (  0.03%) downloaded...


'Environment' 카테고리의 다른 글

Haskell project setting - cabal file  (0) 2019.01.27
How to Uninstall Old GHC  (0) 2019.01.11
HaskellDevEnv: Project Management  (0) 2018.09.04
HaskellDevEnv: Lectures, Resources  (0) 2018.09.03
HaskellDevEnv: IDE for Haskell Programming  (0) 2018.09.02
Comments