Cabal getting installed in root directory instead of /home/vagrant directory using Vagrantfile

扶醉桌前 提交于 2020-01-04 05:23:07

问题


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:


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


来源:https://stackoverflow.com/questions/33645957/cabal-getting-installed-in-root-directory-instead-of-home-vagrant-directory-usi

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