原因:閑來(lái)無(wú)事想學(xué)習(xí)flutter進(jìn)行開(kāi)發(fā)惕澎,于是就下載VSCode,但是在配置Dart環(huán)境時(shí)出現(xiàn)了問(wèn)題
1.Homebrew的問(wèn)題
在輸入rudy時(shí)終端提示找不到命令颜骤,緊接著提示
-bash: rudy: command not found 找不到命令
ERROR: Error installing redis:
The last version of redis (>= 0) to support your Ruby & RubyGems was 4.1.1. Try installing it with `gem install redis -v 4.1.1`
(“支持Ruby&RubyGems的最新版本redis(>=0)是4.1.1。試著用'gem install redis-v4.1.1安裝它`”)
redis requires Ruby version >= 2.3.0. The current ruby version is 2.2.0.
此處是是已經(jīng)給出了提示使用gem install redis-v4.1.1進(jìn)行安裝捣卤,主要原因就是redis版本太低忍抽,需要升級(jí),提示的錯(cuò)誤中已經(jīng)給出了操作步驟董朝,以后遇到此情況需謹(jǐn)記
2.brew的安裝問(wèn)題鸠项,比較復(fù)雜,同樣是找不到命令行
brew: command not found
先是修改了/.bash_profile文件子姜,vi ~/.bash_profile打開(kāi)文件祟绊,添加了一句
export PATH=/usr/local/bin:$PATH
export HOMEBREW_NO_AUTO_UPDATE=true
之后,source .bash_profile,之后輸入 brew命令之后看到了brew的信息
3.之后就是更新問(wèn)題
雖然中間還有其他問(wèn)題牧抽,不過(guò)問(wèn)度娘之后基本都可解決
brew的更新嘉熊,需要換鏡像,如果不換鏡像的話會(huì)卡住扬舒,度娘上有很多源阐肤,本人換的是阿里的源
# 替換成阿里巴巴的 brew.git 倉(cāng)庫(kù)地址:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替換成阿里巴巴的 homebrew-core.git 倉(cāng)庫(kù)地址:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
之后還需要修改/.bash_profile中的URL
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
之后source .bash_profile
緊接著brew update,走起
此處已經(jīng)可以看到brew的版本好讲坎,之后brew的命令行生效了
4.dart的問(wèn)題
以為學(xué)習(xí)flutter就是直接使用flutter就可以了孕惜,但是dart是flutter的基礎(chǔ),就像OC是swift的基礎(chǔ)一樣晨炕,不能不學(xué)衫画,所以也需要安裝dart的環(huán)境
傳送門:https://dart.dev/get-dart
安裝dart有兩種方式,我一開(kāi)始是使用的就是使用工具安裝瓮栗,就是通過(guò)brew進(jìn)行安裝削罩,但是
無(wú)法成功的下載軟件包,甚至通過(guò)git改了代理仍然不行遵馆,
嘗試通過(guò)手動(dòng)下載鲸郊,獲取目錄
$ brew --cache
/Users/shockerli/Library/Caches/Homebrew
把剛下載好的軟件包拷貝到這個(gè)目錄下:
$ cp ~/Downloads/dartsdk-macos-x64-release.zip /Users/shockerli/Library/Caches/Homebrew/
重新執(zhí)行安裝命令
brew install dart
一般人,到這里就已經(jīng)安裝成功了货邓,但是很可惜仍然抱錯(cuò)
之后通過(guò)命令行秆撮,打印詳細(xì)的日志
brew install dart -v
brew install dart -v
==> Installing dart from dart-lang/dart
/usr/bin/sandbox-exec -f /private/tmp/homebrew20190810-60798-mlb2s.sb nice /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -W0 -I /usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/simplecov-cobertura-1.3.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/ruby-macho-2.2.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rubocop-rspec-1.35.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rubocop-performance-1.4.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rubocop-0.74.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/unicode-display_width-1.6.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/ruby-progressbar-1.10.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-wait-0.0.9/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-retry-0.6.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-its-1.3.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-3.8.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-mocks-3.8.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-expectations-3.8.4/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-core-3.8.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-support-3.8.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/ronn-0.7.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rdiscount-2.2.0.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/rdiscount-2.2.0.1:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rainbow-3.0.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/plist-3.5.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/parser-2.6.3.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/parallel_tests-2.29.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/parallel-1.17.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/mustache-1.1.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/mechanize-2.7.6/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/webrobots-0.1.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/ntlm-http-0.1.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/nokogiri-1.10.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/nokogiri-1.10.3:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/mini_portile2-2.4.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/net-http-persistent-3.1.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/net-http-digest_auth-1.4.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/mime-types-3.2.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/mime-types-data-3.2019.0331/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/jaro_winkler-1.5.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/jaro_winkler-1.5.3:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/http-cookie-1.0.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/hpricot-0.8.6/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/hpricot-0.8.6:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/domain_name-0.5.20190701/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/unf-0.1.4/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/unf_ext-0.0.7.6/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/unf_ext-0.0.7.6:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/diff-lcs-1.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/coveralls-0.8.23/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/thor-0.20.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/term-ansicolor-1.7.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/tins-1.21.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/simplecov-0.16.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/simplecov-html-0.10.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/docile-1.3.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/json-2.2.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/json-2.2.0:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/connection_pool-2.2.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/backports-3.15.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/ast-2.4.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/activesupport-5.2.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/tzinfo-1.2.5/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/thread_safe-0.3.6/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/minitest-5.11.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/i18n-1.6.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/concurrent-ruby-1.1.5/lib:/Library/Ruby/Site/2.3.0:/Library/Ruby/Site/2.3.0/x86_64-darwin18:/Library/Ruby/Site/2.3.0/universal-darwin18:/Library/Ruby/Site:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby/2.3.0:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby/2.3.0/x86_64-darwin18:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby/2.3.0/universal-darwin18:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/x86_64-darwin18:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18:/usr/local/Homebrew/Library/Homebrew -- /usr/local/Homebrew/Library/Homebrew/build.rb /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart/dart.rb --verbose
==> Downloading https://storage.googleapis.com/dart-archive/channels/stable/release/2.4.1/sdk/dartsdk-macos-x64-release.zip
/usr/bin/curl -q --show-error --user-agent Homebrew/2.1.9-21-g625a780\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.14.2\)\ curl/7.54.0 --fail --location --remote-time --continue-at 0 --output /Users/shockerli/Library/Caches/Homebrew/downloads/4d2412a5d84521393e0e1ecdce0662569e13c2c47762093a760939fa9dd4a917--dartsdk-macos-x64-release.zip.incomplete https://storage.googleapis.com/dart-archive/channels/stable/release/2.4.1/sdk/dartsdk-macos-x64-release.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:43 --:--:-- 0
curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
Error: An exception occurred within a child process:
DownloadError: Failed to download resource "dart"
Download failed: https://storage.googleapis.com/dart-archive/channels/stable/release/2.4.1/sdk/dartsdk-macos-x64-release.zip
發(fā)現(xiàn)了homedart 下載時(shí)的緩存地址
/Users/shockerli/Library/Caches/Homebrew/downloads/4d2412a5d84521393e0e1ecdce0662569e13c2c47762093a760939fa9dd4a917--dartsdk-macos-x64-release.zip.incomplete
XXX.incomplete 表示下載未完成,但這是 Homebrew 期望的下載文件路徑换况。
那我們就將下載的軟件包拷貝到這個(gè)路徑职辨,并去除 .incomplete:
mv ~/Downloads/dartsdk-macos-x64-release.zip /Users/shockerli/Library/Caches/Homebrew/downloads/4d2412a5d84521393e0e1ecdce0662569e13c2c47762093a760939fa9dd4a917--dartsdk-macos-x64-release.zip
之后再brew install dart -v,原以為進(jìn)行到這里就可以了戈二,但是最近的運(yùn)氣一直不是很好舒裤,還是報(bào)錯(cuò),此路不通觉吭,沒(méi)有辦法腾供,一般人到這里之后就會(huì)放棄的,但是一想起自己那無(wú)處安放的魅力之后鲜滩,毅然決然的繼續(xù)進(jìn)行下去伴鳖,整理了一下思路,既然此路不通的話徙硅,就往回找榜聂,開(kāi)頭提到了安裝dart有兩種方式,一種是通過(guò)homebrew工具安裝嗓蘑,一種是通過(guò)手動(dòng)下載dartSDK安裝须肆,主要目的就是dart的SDK匿乃,那直接下載dart的SDK不就行了,之后在度娘上找到了dart的SDK
版本雖然是2.4.0的豌汇,最新的版本是2.8.0的嗎但是能用就行了幢炸,下載之后,在source文件中改一下路徑就行了瘤礁,之后運(yùn)行VScode和終端發(fā)現(xiàn)阳懂,
問(wèn)題解決了
補(bǔ)充:在修改source文件時(shí),修改路徑之后 source ~/.bash_profile報(bào)錯(cuò)柜思,(將源文件的名稱給改了岩调,出現(xiàn)了)
-bash: /Users/xxx/.profile: No such file or directory
這是將源文件的抬頭改了,只需要改回source ~/.profile就可以了
或者:
將source ~/.profile 刪除赡盘,然后在第一行編輯加入:
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
這是系統(tǒng)默認(rèn)初始環(huán)境變量号枕,直接復(fù)制粘貼就行
最后退出保存,重新打開(kāi)終端問(wèn)題解決陨享。