Really portable installation of Haskell on Windows

Is it possible to have a truly portable Haskell installation on Windows, so everything related to Haskell happens in the same directory. I want to have Haskell installed on a USB drive, so I can use it on any other Windows computer just by plugging it in.

This means that when I say cabal install somePackageeverything happens locally and relative to this single directory (nb for different computers may have a different drive letter assigned to the USB drive). I would like to be able to run this cabal install somePackageon any Windows machine. It would also be nice if I could copy the contents of the USB drive to a local hard drive, and it still works from there (on some Windows computers, USB drives are read-only).

I am aware of the following related StackOverflow questions here and here . Can I customize the cabal configuration file to use relative paths? What about other Haskell tools (e.g. winghci)?

So how do I do this? Install the Haskell platform portable, and then do what?

+4
source share
2 answers

Follow the procedure below:

  • Use a portable installation to install the Haskell Platform , for example. h:\dev\hp. Select Do Not Create Shortcuts. To install Haskell Stack, select h:\dev\hp\local\binas the destination folder. De select Add to user% PATH%.

  • You should get the following first level directory structure:

    dev
      hp
        8.0.1
        local
          bin (this where stack.exe gets installed)
    
  • Create additional subfolders:

    mkdir projects
    mkdir user
    cd user
    mkdir AppData
    mkdir AppData\Roaming
    
    dev
      hp
        projects
        user
          AppData
            Roaming
    
  • junction user. user\create-symlink.bat . .

    %~dp0junction -nobanner -accepteula -d "%~dp0Application Data"
    %~dp0junction -nobanner -accepteula "%~dp0Application Data" %~dp0AppData\Roaming
    junction "Application Data" AppData\Roaming
    
  • haskell.bat h:\dev\hp :

    @ECHO OFF
    set HSROOT=%~dp08.0.1
    SET USERPROFILE=%~dp0user
    SET Path=%HSROOT%\bin;%HSROOT%\winghci;%~dp0local\bin;%HSROOT%\mingw\bin;%HSROOT%\msys\usr\bin;%HSROOT%\lib;%HSROOT%\lib\extralibs\bin;%Path%
    CMD /k "cd %~dp0projects"
    
  • haskell.bat . user\AppData\Roaming

    cabal update
    cabal user-config init
    stack setup
    
  • cabal (user\AppData\Roaming\cabal\config) , :

    remote-repo-cache: $prefix\..\..\user\AppData\Roaming\cabal\packages
    world-file: $prefix\..\..\user\AppData\Roaming\cabal\world
    extra-prog-path: $prefix\..\msys\usr\bin
    extra-lib-dirs: $prefix\..\mingw\lib
    extra-include-dirs: $prefix\..\mingw\include
    build-summary: $prefix\..\..\user\AppData\Roaming\cabal\logs\build.log
    
  • , : user\AppData\Roaming\ghc\i386-mingw32-8.0.1\package.conf.d\*.conf

    • $topdir ( 8.0.1, , h:\dev\hp\8.0.1\lib). , , h:\\dev\\hp\user\\Application Data $topdir\\..\\..\\user\\AppData\\Roaming. , h:\dev\hp\8.0.1, $topdir\...
  • , . user\AppData\Roaming\stack\snapshots\XXX\pkgdb:

  • - :

    `ghc-pkg recache --global`
    `ghc-pkg recache --user`
    `ghc-pkg recache --package-db="h:\dev\hp\user\AppData\Roaming\stack\snapshots\XXX\pkgdb"`
    
  • , . cabal install --enable-relocatable <package> , .

  • , , . haskell.bat , ghc, cabal, stack, winghci ..

  • . , gcc, :

    Configuring network-2.6.3.1...
    bash.exe: warning: could not find /tmp, please create!
    configure: WARNING: unrecognized options: --with-compiler
    checking build system type... bash.exe: warning: could not find /tmp, please create!
    bash.exe: warning: could not find /tmp, please create!
    i686-pc-mingw32
    checking host system type... i686-pc-mingw32
    checking for gcc... h:\dev\hp\80227D~1.1Ăé´ÉŐĂőýŽÇ┬ćýŁŻ┬îŃąÇĂéňżö┬łŃŽ«ĂéŃąÇĂéň庤ťO
    checking whether the C compiler works... no
    configure: error: in `/cygdrive/c/DOCUME~1/UserName/LOCALS~1/Temp/stack4268/network-2.6.3.1':
    configure: error: C compiler cannot create executables
    See `config.log' for more details
    

    , configure script gcc (h:\dev\hp\80227D~1.1Ăé´ÉŐĂőýŽÇ┬ćýŁŻ┬îŃąÇĂéňżö┬łŃŽ«ĂéŃąÇĂéň庤ťO). , , , :

    stack unpack network-2.6.3.1
    cd network-2.6.3.1
    stack init
    # edit `configure` script and put `CC=` on the first line to kill system supplied path to `gcc`
    stack build
    
+2

:

penultimo :: [Int] -> Int
penultimo l = head(tail(reverse l))
-2

Source: https://habr.com/ru/post/1658496/


All Articles