install-ruby-on-macos开源项目

我要开发同款
匿名用户2021年11月09日
75阅读

技术信息

开源地址
https://gitee.com/J_Sky/jiance
授权协议
View license

作品详情

IstallRubyomacOS

istall-rubyisascriptthatreliablycofiguresyourMacsoyoucaistallRubygems(likeBudler,Jekyll,Rails),adswitchbetweemultipleversiosofRuby.

Itcaberumultipletimesothesamemachiesafely.Itistalls,upgrades,orskipspackagesbasedowhatisalreadyistalledothemachie.

Importat

IfyoucameherefrommyasweroStackOverflow,youmostlikelywatmylaptopscriptistead,ulessyoukowforsurethatallyoueedisRuby.

Afterruigeitherthisscriptorthelaptopscript,makesuretorestartyourtermialforthechagestotakeeffect.

MoregoodiesJoithe1300+peopleomylistwhoarebecomigcofidetcodersthroughmyfreeweeklycodigguidesadexclusivetutorialsadcourses.Checkoutmycustomizablelaptopscriptthatistallsmoreessetialdevelopmettools,aswellastheJekylladRailsgems.Irecommedthelaptopscriptformostpeople.What'ssupported

Supportedchips:

AppleSilicoM1Itel

Supportedoperatigsystems:

BigSurCataliaMojave

Usupportedoperatigsystems.Giveitashot,butIca'tguarateeitwillwork.

macOSHighSierra(10.13.x)macOSSierra(10.12.x)OSXElCapita(10.11.x)OSXYosemite(10.10.x)OSXMavericks(10.9.x)

Supportedshells:

bashfishzshWhatitsetsupBudlerformaagigRubygemschrubyformaagigRubyversios(recommededoverRVMadrbev)Homebrewformaagigoperatigsystemlibraries(whichalsoistallstheprerequisiteApplecommadlietools)ruby-istallforistalligdifferetversiosofRubyIstall

IMPORTANT!CHECKALLOFTHEITEMSBELOWBEFOREANDAFTERRUNNINGTHESCRIPT!

Checkprerequisites

Makesureyourcomputermeetsallprerequisitesfirst.

IfyouareoaM1Mac,dootuseRosetta

HomebrewworksativelyoM1Macs.MakesurethatwhatevertermialappyouuseisotiRosettamode.ReadmyguideoistalligRubyoAppleSilicoformoredetails.

QuitadrelauchTermialafterruigmyscript

ImetiothisseveraltimesithisREADME,aswellaswhethescriptfiishessuccessfully,butI'llsayitagai.Forthechagestotakeeffect,youhaveto"refresh"yourtermial.Thebestwayistoquitadrelauchit.

Nowototheistallatio

BegibyopeigtheTermialoriTermapplicatiooyourMac.TheeasiestwaytoopeaapplicatioimacOSistosearchforitviaSpotlight.ThedefaultkeyboardshortcutforivokigSpotlightiscommad-Space.OceSpotlightisup,starttypigthefirstfewlettersoftheappyouarelookigfor,adoceitappears,pressreturtolauchit.

IyourTermialwidow,ruthefollowigcommads:

cd~curl--remote-amehttps://raw.githubusercotet.com/mofresh/istall-ruby-o-macos/master/istall-ruby/usr/bi/evbashistall-ruby2>&1|tee~/laptop.log

Thescriptitselfisavailableithisrepoforyoutoreviewifyouwattoseewhatitdoesadhowitworks.

NotethatthescriptmightaskyoutoeteryourmacOSpasswordatvariouspoits.ThisisthesamepasswordthatyouusetologitoyourMac.ThepromptcomesfromHomebrew,becauseiteedspermissiostowritetothe/usr/local(or/opt/homebrewoM1Macs)directory.

Ocethescriptisdoe,quitadrelauchTermial.

Debuggig

Yourlastruofthescriptwillbesavedtoafilecalledlaptop.logiyourhomefolder.Readthroughittoseeifyoucadebugtheissueyourself,withthehelpoftheTroubleshootigErrorsWikiarticle.Ifot,copytheetirecotetsoflaptop.logitoaewGitHubIssue(orattachthewholelogfiletotheissue)formeadI'llbegladtohelpyou.

Howtotellifthescriptworked

Ifthelastthigthescriptdisplayedwas"Alldoe!",theeverythigthescriptwasmeattodoworked.Nowmakesureyouquitadrestartyourtermial.

ToverifythattheRubyevirometisproperlycofigured,ruoeormoreofthesecommads:

ruby-v

Thisshouldshowruby2.7.2orruby3.0.0.Ifot,tryquittigadrelauchigTermial.Thetryswitchigmauallyto2.7.2:

chruby2.7.2

adchecktheversiotodoublecheck:

ruby-v

ThecheckwhereRubyisistalled:

whichruby

Thisshouldpoittothe.rubiesdirectoryiyourhomefolder.Forexample:

/Users/mofresh/.rubies/ruby-2.7.2/bi/rubyHowtoswitchbetweeRubyversiosadistalldifferetversios

Bydefault,thescriptistallsRuby2.7.2.Ifyouruitagai,itwillalsoistallRuby3.0.0.Forow,ifyou'reotaexperiecedRubyist,IrecommedusigRuby2.7.2becausesomegemslikeJekyllare'tyetfullycompatiblewithRuby3.0.0.

Toistallaolderversio,ruruby-istallfollowedbyruby-adthedesiredversio.Forexample:

ruby-istallruby-2.7.2

Toswitchtothisewly-istalledversio,ruchrubyfollowedbytheversio.Forexample:

chruby2.7.2

Ifthisdoes'twork,tryquittigadrestartigyourtermial.

Aotherwaytoautomaticallyswitchbetweeversiosistoadda.ruby-versiofileiyourRubyprojectwiththeversioumberprefixedwithruby-,suchasruby-2.7.2.Totestthatthisworks:

cditoafolderoutsideofyourprojectRuchruby3.0.0(orsomeotherversiothatisottheoespecifiediyour.ruby-versio)Verifythatyouareusig3.0.0withruby-vcditoyourprojectVerifythatyouareusigthespecifiedversiowithruby-v

NotethatgemsolygetistallediaspecificversioofRuby.Ifyouistalledjekylli3.0.0,adtheyouistall2.7.2forexample,you'llhavetoistalljekyllagaii2.7.2.

Why

IstalligRubyad/orgemsisacommosourceofcofusioadfrustratio.SearchforYoudo'thavewritepermissiosforthe/Library/Ruby/Gems/2.3.0directoryor"commadotfoud"iyourfavoritesearchegie,adyouwillseepagesadpagesofresults.

Tomakemattersworse,thevastmajorityofsuggestiosarebadadviceadicomplete.ThereasofortheerrormessageaboveisbecausepeoplearetryigtoistallgemsusigtheversioofRubythatcomespre-istalledbyApple.Thaterrormessageisthereforareaso:youshouldotmodifymacOSsystemfiles.Acommosuggestioistobypassthatsecurityprotectiobyusigsudo,whichisotsafeadcacauseissuesdowtheliethatarehardtoudo.

TherecommededwayofusigRubyoaMacistoistallaewer(themacOSversioisofteoutdatedadisolyupdateddurigamajorrelease),separateversioiadifferetfolderthatheoethatcomesbydefaultomacOS.ThebestadmostflexiblewaytodothatiswithaRubymaager.Themostpopularoesare:RVM,rbev,adchruby,adasdf.Ihavechosechrubyithisscript.Seebelowformyreasos.Therearedifferetwaystoistallthesetools,adtheyallrequireadditioalcofiguratioiyourshellstartupfile,suchas.bash_profileor.zshrc.

WheattemptigtoistalladcofigureaRubymaagermaually,it'seasytomissorfumbleastepduetohumaerrororicompleteoroutdatedistructios.Siceallofthestepsareautomatable,thebestadmostreliablewaytosetupRubyoaMacistoruascriptliketheoeI'vewritte.ItestitregularlyomysparelaptopwhereIdeletetheharddriveadistallfreshversiosofmacOS.Ifyou'vealreadyattemptedtosetupadevelopmetevirometoyourMac,adyouruitoissueswithmyscript,pleasereadthroughtheTroubleshootigErrorsarticle.Ifthatdoes'thelp,feelfreetoopeaissue,adIwilldomybesttohelpyou.

ReadmoreimydefiitiveguidetoistalligRubygemsoaMac.

WhychrubyadotRVMorrbev?

Itisthesmallest,mostreliable,adeasiesttouderstad.Ilikethatitdoesotdosomeofthethigsthatothertoolsdo:

Doesothookcd.Doesotistallexecutableshims.DoesotrequireRubiestobeistalleditoyourhomedirectory.DoesotautomaticallyswitchRubiesbydefault.Doesotrequirewrite-accesstotheRubydirectoryiordertoistallgems.

Otherfolkswhopreferchruby:

https://kgrz.io/programmers-guide-to-choosig-ruby-versio-maager.htmlhttps://stevemarshall.com/joural/why-i-use-chruby/https://lihmtra168.github.io/blog/2014/02/27/movig-from-rbev-to-chruby/

功能介绍

Install Ruby on macOS install-ruby is a script that reliably configures your Mac so you can insta...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论