THISPROJECTISNOWDEPRECATEDINFAVOROFghcup-hs
--
ghcupmakesiteasytoinstallspecificversionsofghconGNU/LinuxaswellasmacOS(akaDarwin),andcanalsobootstrapafreshHaskelldeveloperenvironmentfromscratch.ItfollowstheunixUNIXphilosophyofdoonethinganddoitwell.
Similarinscopetorustup,pyenvandjenv.
Ubuntuusersmaypreferhvr'sppa.
ThisprojectwasstartedwhenCMwasswitchingfromstacktocabalnix-stylebuilds.
TableofContentsInstallationUsageManpagesDesigngoalsHowKnownusersKnownproblemsFAQInstallationChooseoneofthefollowinginstallationmethods.
Simplebootstrapofghcup,GHCandcabal-install#completebootstrapcurlhttps://gitlab.haskell.org/haskell/ghcup/raw/master/bootstrap-haskell-sSf|sh#prepareyourenvironment."$HOME/.ghcup/env"echo'.$HOME/.ghcup/env'>>"$HOME/.bashrc"#orsimilar#nowcreateaproject,suchas:mkdirmyproject&&cdmyprojectcabalinit-n--is-executablecabalv2-runManualinstallJustplacetheghcupshellscriptintoyourPATHanywhere.
E.g.:
(mkdir-p~/.ghcup/bin&&curlhttps://gitlab.haskell.org/haskell/ghcup/raw/master/ghcup>~/.ghcup/bin/ghcup&&chmod+x~/.ghcup/bin/ghcup)&&echo"Success"ThenadjustyourPATHin~/.bashrc(orsimilar,dependingonyourshell)likeso,forexample:
exportPATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH"Securityawareusersmaywanttousethefilesfromthereleasepageandverifythegpgsignatures.
UsageSeeghcup--help.
Commonusecasesare:
#installthelastknown"best"GHCversionghcupinstall#installaspecificGHCversionghcupinstall8.2.2#setthecurrently"active"GHCversionghcupset8.4.4#installcabal-installghcupinstall-cabal#updatecabal-installcabalnew-installcabal-installGenerallythisismeanttobeusedwithcabal-install,whichhandlesyourhaskellpackagesandcandemandthataspecificversionofghcisavailable,whichghcupcando.
ManpagesFormanpagestoworkyouneedman-dbasyourmanprovider,thenissuemanghc.Manpagesonlyworkforthecurrentlysetghc.MANPATHmayberequiredtobeunset.
Designgoalssimplicitynon-interactiveportabledoonethinganddoitwell(UNIXphilosophy)Non-goalsinvokingsudo,apt-getoranypackagemanagerhandlingsystempackageshandlingcabalprojectsbeingastackalternativeHowInstallsaspecifiedGHCversioninto~/.ghcup/ghc/<ver>,andplacesghc-<ver>symlinksin~/.ghcup/bin/.
Optionally,anunversionedghclinkcanpointtoadefaultversionofyourchoice.
ThisusesprecompiledGHCbinariesthathavebeencompiledonfedora/debianbyupstreamGHC.
Alternatively,youcanalsotellittocompilefromsource(notethatthismightfailduetomissingrequirements).
Inadditionthisscriptcanalsoinstallcabal-install.
KnownusersvabalKnownproblemsLimiteddistributionssupportedCurrentlyonlyGNU/LinuxdistributionscompatiblewiththeupstreamGHCbinariesaresupported.
PrecompiledbinariesSincethisusesprecompiledbinariesyoumayrunintoseveralproblems.
Missinglibtinfo(ncurses)Youmayrunintoproblemswithncursesandmissinglibtinfo,incaseyourdistributiondoesn'tusethelegacywayofbuildingncursesandhasnocompatibilitysymlinksinplace.
Askyourdistributoronhowtosolvethisortrytocompilefromsourceviaghcupcompile<version>.
LibnumarequiredThiswasabuginthebuildsystemofsomeGHCversionsthatleadtounconditionallyenabledlibnumasupport.Tomitigatethisyoumighthavetoinstallthelibnumapackageofyourdistribution.Seehereforadiscussion.
CompilationAlthoughthisscriptcancompileGHCforyou,it'sjustaverythinwrapperaroundthebuildsystem.Itmakesnoeffortintryingtofigureoutwhetheryouhavethecorrecttoolchainandthecorrectdependencies.RefertotheofficialdocsonhowtoprepareyourenvironmentforbuildingGHC.
FAQWhyreimplementstack?ghcupisnotareimplementationofstack.TheonlycommonpartisautomaticinstallationofGHC,buteventhatdiffersinscopeanddesign.
Whynotcontributetostackandcreatealibraryforthecommonpart?Whilethismightbeaninterestingidea,ghcupisaboutsimplicity.
Whywritea>1000kLOCbashscript?ghcupisPOSIXsh.
Whywritea>1000kLOCPOSIXshscript?Mainlybecausetheimplementationisfairlystraight-forwardandthescriptishighlyportable.NoneedtobootstrapanythingorsetupyetanotherCItobuildghcupbinariesforallpossiblearchesanddistrosjusttoperformaverysimpletask:identifydistroandplatformanddownloadaGHCbindist.
Whynotsupportwindows?ConsiderusingChocolateyorghcups.
评论