【问题标题】:Not able to initialize sandbox using cabal on haskell platform无法在 haskell 平台上使用 cabal 初始化沙箱
【发布时间】:2015-11-11 02:47:33
【问题描述】:

我已完成以下步骤来安装 cabal 。我已经使用sudo apt-get install haskell-platform安装了haskell平台

http://coldwa.st/e/blog/2013-08-20-Cabal-sandbox.html

Building Cabal from git
Assuming you already have a previous version of cabal installed:

$ git clone git://github.com/haskell/cabal.git /path/to/cabal
$ cd /path/to/cabal
$ cabal install Cabal/ cabal-install/

但是,当我尝试初始化沙盒时,它会抛出如下错误。

vagrant@vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ cabal sandbox --help
cabal: unrecognised command: sandbox (try --help)

添加更多细节:

vagrant@vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
vagrant@vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ which cabal
/home/vagrant/.cabal/bin/cabal



vagrant@vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ cabal --help
This program is the command line interface to the Haskell Cabal infrastructure.
See http://www.haskell.org/cabal/ for more information.

Usage: cabal COMMAND [FLAGS]
   or: cabal [GLOBAL FLAGS]

Global flags:
 -h --help            Show this help text
 -V --version         Print version information
    --numeric-version Print just the version number

Commands:
  install      Installs a list of packages.
  update       Updates list of known packages
  list         List packages matching a search string.
  info         Display detailed information about a particular package.
  fetch        Downloads packages for later installation.
  unpack       Unpacks packages for user inspection.
  check        Check the package for common mistakes
  sdist        Generate a source distribution file (.tar.gz).
  upload       Uploads source packages to Hackage
  report       Upload build reports to a remote server.
  init         Interactively create a .cabal file.
  configure    Prepare to build the package.
  build        Make this package ready for installation.
  copy         Copy the files into the install locations.
  haddock      Generate Haddock HTML documentation.
  clean        Clean up after a build.
  hscolour     Generate HsColour colourised code, in HTML format.
  register     Register this package with the compiler.
  test         Run the test suite, if any (configure with UserHooks).
  bench        Run the benchmark, if any (configure with UserHooks).
  upgrade      (command disabled, use install instead)
  help         Help about commands

For more information about a command use:
  cabal COMMAND --help

To install Cabal packages from hackage use:
  cabal install foo [--dry-run]

Occasionally you need to update the list of available packages:
  cabal update

You can edit the cabal configuration file to set defaults:
  /home/vagrant/.cabal/config
vagrant@vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ cabal COMMAND --help
cabal: unrecognised command: COMMAND (try --help)
vagrant@vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ cabal sandbox --help
cabal: unrecognised command: sandbox (try --help)

【问题讨论】:

  • cabal sandbox 仅适用于 cabal-install 1.18 及更高版本。 cabal --version 告诉你什么?
  • 我相信 Ubuntu 的软件包系统有一个过时的 haskell 平台(看起来至少过时了几年,非常过时)。我建议从其他来源安装它。
  • vagrant@vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ cabal --version cabal-install 版本 1.16.0.2 使用 Cabal 库 vagrant@vagrant 的版本 1.16.0 -ubuntu-trusty-32:/usr/lib/haskell-packages$ which cabal /home/vagrant/.cabal/bin/cabal
  • @DavidYoung:我添加了更多细节。检查
  • @Zack 好吧,就像我说的,我建议从更新的来源获取 haskell-platform/ghc。该安装可能充其量只有 GHC 7.6.3,它是最新稳定版本之后的两个(很快将是三个)主要版本(并且功能数量存在很大差异。您可能会遇到很多不兼容问题与 Haskell 库)。不过,您可以通过升级 cabal 来解决这个特定问题(虽然这不会升级 GHC 编译器)。这可以通过cabal update && cabal install cabal-install 完成。

标签: haskell cabal cabal-install


【解决方案1】:

apt 安装的 Cabal 有点老,这可能是你的 PATH 中的那个。它被安装到/usr/bin。您可以通过以下方式检查:

which cabal

并查看版本:

cabal -v

你应该把~/.cabal/bin中的那个放在你的PATH中,首先是:

export PATH="$HOME/.cabal/bin:$PATH

(最好将其放在您的~/.bash_profile 或类似名称中)

在我的系统上:

.whogan:~$ which cabal
/home/whogan/.cabal/bin/cabal

.whogan:~$ cabal -V
cabal-install version 1.22.6.0
using version 1.22.4.0 of the Cabal library 

.whogan:~$ /usr/bin/cabal -V
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library 

编辑:尝试使用新的 Vagrant 框,运行 apt-get install haskell-platform 并从 git 安装:

[vagrant@vagrantbox:~] $ git clone git://github.com/haskell/cabal.git cabal-wip
Cloning into 'cabal-wip'...
remote: Counting objects: 48926, done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 48926 (delta 16), reused 0 (delta 0), pack-reused 48876
Receiving objects: 100% (48926/48926), 26.39 MiB | 10.37 MiB/s, done.
Resolving deltas: 100% (29033/29033), done.
Checking connectivity... done.

[vagrant@vagrantbox:~] $ cd cabal-wip
[vagrant@vagrantbox:~/cabal-wip][master] $ cabal install Cabal/ cabal-install/
Config file path source is default config file.
Config file /home/vagrant/.cabal/config not found.
Writing default configuration to /home/vagrant/.cabal/config
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
Resolving dependencies...
Configuring Cabal-1.23.0.0...
Building Cabal-1.23.0.0...
Preprocessing library Cabal-1.23.0.0...
[ 1 of 85] Compiling Distribution.Lex ( Distribution/Lex.hs, dist/build/Distribution/Lex.o )
..
[85 of 85] Compiling Distribution.Simple ( Distribution/Simple.hs, dist/build/Distribution/Simple.o )
In-place registering Cabal-1.23.0.0...
Installing library in /home/vagrant/.cabal/lib/Cabal-1.23.0.0/ghc-7.6.3
Registering Cabal-1.23.0.0...
Installed Cabal-1.23.0.0
[1 of 1] Compiling Main             ( cabal-install/Setup.hs, cabal-install/dist/setup/Main.o )
Linking cabal-install/dist/setup/setup ...
Configuring cabal-install-1.23.0.0...
Building cabal-install-1.23.0.0...
Preprocessing executable 'cabal' for cabal-install-1.23.0.0...
[ 1 of 81] Compiling Distribution.Client.Utils.LabeledGraph ( Distribution/Client/Utils/LabeledGraph.hs, dist/build/cabal/cabal-tmp/Distribution/Client/Utils/LabeledGraph.o )
...
[81 of 81] Compiling Main             ( Main.hs, dist/build/cabal/cabal-tmp/Main.o )
Linking dist/build/cabal/cabal ...
Generating manual page dist/build/cabal/cabal.1 ...
Installing executable(s) in /home/vagrant/.cabal/bin
Installed cabal-install-1.23.0.0

它安装了 1.23.0.0 到 ~/.cabal/bin,但之后 PATH 仍然指向系统一:

[vagrant@vagrantbox:~/cabal-wip][master] $ which cabal
/usr/bin/cabal
[vagrant@vagrantbox:~/cabal-wip][master] $ cabal -V
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library

所以我修改为把用户/git版本放在第一位:

[vagrant@vagrantbox:~/cabal-wip][master] $ export PATH="~/.cabal/bin:$PATH"
[vagrant@vagrantbox:~/cabal-wip][master] $ which cabal
/home/vagrant/.cabal/bin/cabal
[vagrant@vagrantbox:~/cabal-wip][master] $ cabal -V
cabal-install version 1.23.0.0
compiled using version 1.23.0.0 of the Cabal library 

之后好像没问题:

[vagrant@vagrantbox:~/cabal-wip][master] $ mkdir ~/tmp && cd ~/tmp
[vagrant@vagrantbox:~/tmp] $ cabal sandbox init
Writing a default package environment file to
/home/vagrant/tmp/cabal.sandbox.config
Creating a new sandbox at /home/vagrant/tmp/.cabal-sandbox

我使用的是 trusty64 而不是 trusty32,但我希望这在这种情况下并不重要。

【讨论】:

  • 您的回答对我没有任何帮助。您能否详细说明如何解决该错误?正如我的帖子中提到的,阴谋集团已经在我的道路上。
  • 我知道它在您的PATH 中,我的意思是系统级安装首先在您的PATH 中,这与~/.cabal/bin 中的用户级安装不同。为了解决这个问题,正如我所说,您修改您的路径以使用export PATH="$HOME/.cabal/bin:$PATH" 将用户级别放在第一位。博客文章中也提到了这一点,他们声明“就是这样!现在你已经在 ~/.cabal/bin 下安装了最新版本的 cabal 工具”。 which cabal 的输出是什么?如果不是~/.cabal/bin,那么你需要修复你的路径。
  • 好的。会试试这个。可能是我错过了这一步。谢谢。
  • 我看到您已经注意到上面另一个线程中的路径,并且您在 ~/.cabal/bin 中不知何故得到了 1.16。虽然我不明白从 git 源安装如何会发生这种情况,但您可能应该接受 David Young 的建议。
  • 谢谢。我可以通过登录 VM 以交互方式进行操作。但是,通过 vagrantfile 执行相同操作时,我遇到了问题。你能看看这个帖子吗:stackoverflow.com/questions/33645957/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-05-19
  • 1970-01-01
  • 1970-01-01
  • 2014-09-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多