2

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
Zack
  • 2,078
  • 10
  • 33
  • 58
  • Why don't you install `ghc-7.10.2` and `cabal-1.22` from [`hvr/ghc`](https://launchpad.net/~hvr/+archive/ubuntu/ghc)? Unless you really want GHC 7.6, I wouldn't use `haskell-platform` on Trusty. – Zeta Nov 11 '15 at 07:39
  • @Zeta : It works when I do the same steps manually in the VM. It is just that it is installing in the root directory when I do the same with Vagrantfile. If I am able to solve this issue, I am fine. – Zack Nov 11 '15 at 07:45
  • Did you try adding `su - vagrant` prior cabal install step? – daniel.kahlenberg Nov 11 '15 at 10:16
  • yes. I have tried that – Zack Nov 11 '15 at 15:47

1 Answers1

1

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
David McHealy
  • 2,471
  • 18
  • 34
  • I have not tried this. I tried to do su vagrant but it did not work. I will try what you said now. – Zack Nov 11 '15 at 20:03