Portable package installation on Haskell Platform with Cabal on windows

霸气de小男生 提交于 2019-12-22 18:26:41

问题


I have Windows XP and Haskell Platform 2013 installed on it. When I want to compile my code on some computer, which has not Haskell Platform installed on it, and I'm not allowed to install anything, I can copy my Haskell Platform on USB flashcard, and run on this computer, and it's work just fine.

But sometimes I need additional packages, that are not part of the standard Haskell Platform build.

I can simply install it on my personal computer with Cabal, but I don't know, how to install them in such a way that they could work portable, i. e. from my USB flashcard on not my computer.

I tried this:

cabal install gnuplot --prefix "C:\Program Files\Haskell Platform\2013.2.0.0"

This installed package into Haskell platform directory, but when I run Haskell Platform on another computer, it don't see it.

I think, I should make configuration file to be installed in Haskell Platform directory, but I don't how to do it.

Please, help me to solve this problem. Thank you in advance!



Thank you very much, Mikhail Glushenkov! All work fine now.

For convenience of newbies like me, that looking for answers, I merely describe the instruction, what to do, to have same result:

0) Read the instruction before doing anything/

1) Uninstall all additional packages, that is needed to be installed portable (with dependencies): unregister this packages with

ghc-pkg unregister gnuplot

, and then delete package-files from where it stores. Also delete all related files from "package.conf.d" folders. To search them, use

ghc-pkg list

.

2) Run (maybe it's unnecessary)

ghc-pkg recache

.

3) Install package in desired directory in haskell platform. I did it in "C:\Program Files\Haskell Platform\2013.2.0.0\addlib":

cabal install gnuplot --prefix "C:\Program Files\Haskell Platform\2013.2.0.0\addlib" --global

.

4) Change every new file, related to installed packages in "package.conf.d": replace "C:\Program Files\Haskell Platform\2013.2.0.0\addlib\utility-ht-0.0.9\ghc-7.6.3" in them like that: "$topdir\..\addlib\utility-ht-0.0.9\ghc-7.6.3", i. e. "C:\Program Files\Haskell Platform\2013.2.0.0\addlib\" -> "$topdir\..\addlib\".

5) Run

ghc-pkg recache

.

3a) Maybe, this would work better, then 3 (I did not tested it). If so, don't do 3, 4, and 5.

cabal install gnuplot --prefix "$topdir\..\addlib" --global

.

End.

*UPD*

I found some stupid mistakes in this instructions (in 3a and 4). Fixed now.

3a is not working!


回答1:


You need to replace the absolute paths in $GHCDIR\lib\package.conf.d\*.conf files with relative paths referencing $topdir and then run ghc-pkg recache.

Take a look at how the Haskell Platform's Windows installer does it.



来源:https://stackoverflow.com/questions/19007105/portable-package-installation-on-haskell-platform-with-cabal-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!