How to install Haskell Stack locally?

I am working on my school server and I need to install the Haskell stack. In the README file and on the website, I might not find how to install locally. What if I am not a sudo user?

+5
source share
2 answers

You do not need superuser privileges to set the stack; You can also install it in your own home directory. All you need for this is a GMP Linux system (which GHC depends on a very fundamental level). If GMP is not installed - administrators really do not have to worry about installing it.

#!/bin/bash # Stack installation script, adapted from: # https://github.com/yantonov/install-ghc/blob/af0b968b9e8423efb152ccec4224821e29317710/ubuntu/install-ghc-ubuntu.md DOWNLOADS_DIR=$HOME/Downloads STACK_INSTALL_DIR="$HOME/Development/bin" STACK_VERSION="1.1.2" STACK_ARCHITECTURE="x86_64" STACK_PLATFORM="linux" # Check that libgmp is installed. This is the main critical system-level # dependency of the Haskell environment that may not be present. function check_lib() { echo "int main(){}" | gcc -o /dev/null -lgmp -xc - return $? } GMP_OK=false if (ldconfig -p | grep -q "libgmp.so.10"); then GMP_VERSION_POSTFIX="" if (check_lib -lgmp); then GMP_OK=true; fi elif (ldconfig -p | grep -q "libgmpxx.so.4"); then GMP_VERSION_POSTFIX="-gmp4" if (check_lib -lgmp); then GMP_OK=true; fi fi if [ $GMP_OK = false ]; then echo >&2 "Haskell requires the GNU multi-precision library (with headers)" echo >&2 "in version 4 or 10, but neither can be found. Try" echo >&2 echo >&2 "$ sudo apt-get install libgmp-dev" echo >&2 exit 1 fi STACK_DIST_FILENAME="stack-$STACK_VERSION-$STACK_PLATFORM-$STACK_ARCHITECTURE.tar.gz" STACK_DIST_UNZIPPED_DIR="stack-$STACK_VERSION-$STACK_PLATFORM-$STACK_ARCHITECTURE" STACK_DIST_URL="https://www.stackage.org/stack/$STACK_PLATFORM-$STACK_ARCHITECTURE" STACK_TARGET_DIR="stack-$STACK_VERSION" cd $DOWNLOADS_DIR curl -L -o $STACK_DIST_FILENAME $STACK_DIST_URL tar xvfz $STACK_DIST_FILENAME # in case if error like this: #curl: (77) error setting certificate verify locations: CAfile: # /etc/pki/tls/certs/ca-bundle.crt CApath: # ... # create ~/.curlrc file # and put this lines to it # capath=/etc/ssl/certs/ # cacert=/etc/ssl/certs/ca-certificates.crt # move to home development dir rm -rf $STACK_INSTALL_DIR/$STACK_TARGET_DIR mv $STACK_DIST_UNZIPPED_DIR $STACK_INSTALL_DIR/$STACK_TARGET_DIR cd $STACK_INSTALL_DIR # sym link rm -rvi stack ln -s `pwd`/$STACK_TARGET_DIR stack # add to PATH environment STACK_HOME=$HOME/Development/bin/stack PATH=$STACK_HOME:$PATH # clean up cd $DOWNLOADS_DIR rm -rf stack-$STACK_VERSION* # install ghc stack setup 
+4
source

The Haskell stack is successfully installed using the instructions in the Documentation here .

As with "sudo user", the sudo gives the user superuser privileges by flipping mode bit . Details about the mechanism can be found here.

Problem in your case, it may be the reason that in school networks, " users are not allowed to use sudo for security purposes, and therefore either administrators must provide their account privileges, or they must install the Haskell stack themselves. If this is part of the job, administrators You donโ€™t have to worry about it, but you should inform the administrators about it, after which you can use it comfortably .

If the above steps are not possible, I suggest you try the Haskell stack in your personalized account on the device. You can even try cloud services like Cloud9, Nitrous and others. An incredible reason may be that you are not using the Haskell stack properly.

Note I have been using the Haskell stack for some time, so I can conclude that it works.

+1
source

Source: https://habr.com/ru/post/1258675/


All Articles