[問題] 安裝rails問題

看板Ruby作者 (公子小白-痴)時間3年前 (2021/03/06 17:42), 3年前編輯推噓2(205)
留言7則, 5人參與, 最新討論串1/1
各位大能好 我在輸入sudo gem install rails時 跑出了最下面那一大串敘述 幾乎不懂 我是看網路教學影片 其中用RVM管理ruby 但後來發現這臺mac原本有舊的rbenv跟ruby 導致有點衝突 這兩天我上網胡亂抓藥 好像亂碰了PATH 現在有點不知道該怎麼重新開始回到最初 所以想來此求助 如何解決這問題 重新上學習rails的軌道 btw 我現在透過rbenv 明明是裝 ruby 3.0.0 但我輸入 ruby -v 卻出現ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19] 可能也是胡亂抓藥的後遺症 因為我對mac的系統本身還不太熟 如果有大大有點空閒時間可以幫我看看 非常感激 =============== 以下這大串: Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. current directory: /Library/Ruby/Gems/2.6.0/gems/nio4r-2.5.7/ext/nio4r /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210306-936-1vp5f2q.rb extconf.rb checking for unistd.h... *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME) /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in `with_werror' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in `block in have_header' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in `have_header' from extconf.rb:15:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/nio4r-2.5.7/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/nio4r-2.5.7 for inspection. Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/nio4r-2.5.7/gem_make.out ============ 另外這是目前 vi .bash_profile 打開的內容 但我查到怎麼打開 但不知道怎麼編輯..... 我只會開了編輯模式 但不知道怎麼存檔離開 Orz... 話說我還從-bath 換去了 -zsh 真的是胡亂抓藥 懇請大神救救我 eval "$(rbenv init -)" export PATH="$HOME/.rbenv/shims:$PATH" eval "$(rbenv init -)" export PATH="$HOME/.rbenv/shims:$PATH" eval "$(rbenv init -)" export PATH="$HOME/.rbenv/shims:$PATH" eval "$(rbenv init -)" export PATH="$HOME/.rbenv/shims:$PATH" # Setting PATH for Python 3.7 # The original version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}" export PATH export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rvm init -)" export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 219.68.48.50 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Ruby/M.1615023775.A.DE5.html ※ 編輯: funnykids (219.68.48.50 臺灣), 03/06/2021 17:51:33

03/09 20:14, 3年前 , 1F
先看是用哪個shell,再來條他的設定,執行echo $SHELL
03/09 20:14, 1F

03/09 20:15, 3年前 , 2F

03/09 20:16, 3年前 , 3F
再按照 rbenv 說明裡面對應的設定位置
03/09 20:16, 3F

03/18 07:51, 3年前 , 4F
rbenv global 3.0.0
03/18 07:51, 4F

03/23 10:37, 3年前 , 5F
03/23 10:37, 5F

03/25 12:05, 3年前 , 6F
感謝 應該是Xcode問題
03/25 12:05, 6F

03/31 01:01, , 7F
高手在民間
03/31 01:01, 7F
文章代碼(AID): #1WGqwVtb (Ruby)
文章代碼(AID): #1WGqwVtb (Ruby)