如何在本地安装Haskell堆栈? [英] How do I install Haskell Stack locally?

查看:86
本文介绍了如何在本地安装Haskell堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学校服务器上工作,我需要安装Haskell的堆栈。在 README 文件中和网站我找不到如何在本地安装。如果我不是sudo用户,该怎么办? 您不需要超级用户权限来安装堆栈;你可以将它安装在你自己的主目录中。您需要的只是安装了 GMP 的Linux系统(GHC依赖于其基础级别) 。如果GMP没有安装 - 管理员真的不应该有任何安装问题。

 #!/ bin / bash 

#堆叠安装脚本,改编自:
#https://github.com/yantonov/install-ghc/blob/af0b968b9e8423efb152ccec4224821e29317710/ubuntu/install-ghc-ubuntu.md

DOWNLOADS_DIR = $ HOME /下载
STACK_INSTALL_DIR = $ HOME /开发/ BIN
STACK_VERSION = 1.1.2
STACK_ARCHITECTURE = x86_64的
STACK_PLATFORM = linux

#检查libgmp是否已安装。这是Haskell环境中可能不存在的主要关键系统级
#依赖项。

函数check_lib()
{
echoint main(){}| gcc -o / dev / null -lgmp -x c -
return $?
}

GMP_OK = false
if(ldconfig -p | grep -qlibgmp.so.10);那么
GMP_VERSION_POSTFIX =
if(check_lib -lgmp);那么GMP_OK = true; fi
elif(ldconfig -p | grep -qlibgmpxx.so.4);那么
GMP_VERSION_POSTFIX = - gmp4
if(check_lib -lgmp);那么GMP_OK = true; fi
fi


if [$ GMP_OK = false];那么
echo>& 2Haskell需要版本4或10中的GNU多精度库(带头文件)
echo>& 2,但都不能找到。
echo>& 2
echo>& 2$ sudo apt-get install libgmp-dev
echo>& 2
exit 1
音响

STACK_DIST_FILENAME = 重新建立了新$ $ STACK_VERSION- $ STACK_PLATFORM- STACK_ARCHITECTURE.tar.gz
STACK_DIST_UNZIPPED_DIR = 重新建立了新$ $ STACK_VERSION- $ STACK_PLATFORM- STACK_ARCHITECTURE
STACK_DIST_URL = https://www.stackage.org/stack/$STACK_PLATFORM-$STACK_ARCHITECTURE
STACK_TARGET_DIR = 重新建立了新$ STACK_VERSION

$ CD DOWNLOADS_DIR

卷曲-L -o $ STACK_DIST_FILENAME $ STACK_DIST_URL
焦油xvfz $ STACK_DIST_FILENAME

#的情况下,如果像这样的错误:
#curl:(77)错误设置证书验证地点:CAfile:
#/etc/pki/tls/certs/ca-bundle.crt CApath:
#...
#create〜/ .curlrc文件
#并放入这行代码
#capath = / etc / ssl / certs /
#cacert = / etc / ssl / certs / ca-certificates.crt

#移至开发目录
rm -rf $ STACK_INSTALL_DIR / $ STACK_TARGET_DIR
$ MV $ STACK_DIST_UNZIPPED_DIR STACK_INSTALL_DIR / $ STACK_TARGET_DIR

$ CD STACK_INSTALL_DIR

#符号链接
RM -rvi栈
LN -s`pwd` / $ STACK_TARGET_DIR堆栈

#添加到PATH环境
STACK_HOME = $ HOME / Development / bin / stack
PATH = $ STACK_HOME:$ PATH

#清理
cd $ DOWNLOADS_DIR
rm -rf stack- $ STACK_VERSION *

#install ghc
堆栈设置


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

解决方案

You don't need superuser privileges to install stack; you can as well install it in your own home directory. All you need for this to work is a Linux system with GMP installed (which GHC depends on at a very fundamental level). If GMP is not installed – the admins really shouldn't have any concerns installing that.

#!/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 -x c -
    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

这篇关于如何在本地安装Haskell堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆