Cabal getting installed in root directory instead

2019-07-18 15:28发布

THe below is the content of the vagrant file. When I run vagrant up command, it installs cabal as required but it is in the root directory. Hence, it becomes unusable. I want to update the cabal version to latest version using cabal update. But it is not happening.

Finally, in my VM, I have old version of cabal which comes with haskell-platform which is of no use to me. However, when I execute these commands separately by explicitly logging into VM, and not putting anything in Vagrantfile, it works and I get cabal version 1.22.6.0 which is what I need, but by using Vagrantfile. How do I make sure that cabal is not getting installed in the root directory ? Instead I think it should get installed in the /home/vagrant directory like this: /home/vagrant/.cabal/bin

==> default: Setting up haskell-platform (2013.2.0.0.debian3) ...
==> default: Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
==> default:  ********************************

    ==> default: Config file path source is default config file.
    ==> default: Config file /root/.cabal/config not found.
    ==> default: Writing default configuration to /root/.cabal/config
    ==> default: Downloading the latest package list from hackage.haskell.org
    ==> default:  ********************************
    ==> default: Resolving dependencies...
    ==> default: Downloading binary-0.7.6.1...
    ==> default: Configuring binary-0.7.6.1...
    ==> default: Building binary-0.7.6.1...
    ==> default: Preprocessing library binary-0.7.6.1...

CONTENTS OF VAGRANT FILE BELOW:

Vagrant.configure(2) do |config| 
      config.vm.box = "ubuntu/trusty32"
      config.vm.box_check_update = false 
      config.vm.provider "virtualbox" do |vb| 
        vb.gui = true  
        vb.memory = "2048"
      end

      config.vm.provision "shell", inline: <<-SHELL
      cd /home/vagrant      
      sudo apt-get update 
      echo "-----------------------------" 
      echo "-----------------------------" 
      sudo apt-get -y install zip
      sudo apt-get -y install git
      sudo apt-get -y install build-essential
      sudo apt-get -y install libmakefile-parser-perl
      sudo apt-get -y install libreoffice-dev
      sudo apt-get -y install haskell-platform

      echo " ********************************" 
      cabal update

      echo " ********************************" 

      cabal install cabal-install
      echo "+++++++++++==========++++====="

      # echo "PATH=/home/vagrant/.cabal/bin:$PATH" >> /home/vagrant/.bashrc 

      SHELL

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-07-18 16:12

I've personally had more luck configuring vagrant with ansible, but if you wish to do it this way, have you tried:

sudo -u vagrant cabal install cabal-install
查看更多
登录 后发表回答