作者funnykids (公子小白-痴)
看板Ruby
标题[问题] 安装rails问题
时间Sat Mar 6 17:42:52 2021
各位大能好
我在输入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://webptt.com/cn.aspx?n=bbs/Ruby/M.1615023775.A.DE5.html
※ 编辑: funnykids (219.68.48.50 台湾), 03/06/2021 17:51:33
1F:推 will6w: 先看是用哪个shell,再来条他的设定,执行echo $SHELL 03/09 20:14
3F:→ will6w: 再按照 rbenv 说明里面对应的设定位置 03/09 20:16
4F:推 tonytonyjan: rbenv global 3.0.0 03/18 07:51
6F:→ funnykids: 感谢 应该是Xcode问题 03/25 12:05
7F:→ diabolica: 高手在民间 03/31 01:01