试图在轨道上安装红宝石

时间:2020-05-10 11:20:41

标签: ruby-on-rails

我正在尝试使用gem install rails安装rails,但是当我尝试获得

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

所以我尝试使用sudo gem install rails并得到

ERROR:  Error installing rails:
ERROR: Failed to build gem native extension.

我已经检查了互联网,并说应该安装RVM,但是当我尝试这样做时,它会告诉我:

Error running './configure --prefix=/Users/manhattan/.rvm/rubies/ruby-2.7.0 --with-opt-dir=/usr/local/opt/libyaml:/usr/local/opt/libksba:/usr/local/opt/readline:/usr/local/opt/zlib:/usr/local/opt/openssl@1.1 --disable-install-doc --enable-shared', please read /Users/manhattan/.rvm/log/1589107425_ruby-2.7.0/configure.log There has been an error while running configure. Halting the installation.

有人可以帮我吗?

2 个答案:

答案 0 :(得分:0)

您可以更改您正在使用的目录的权限

# chmod -R 777 DIR_NAME
# cd DIR_NAME
# gem install rails

答案 1 :(得分:0)

在Mac上安装Ruby gems(例如Rails)是造成混乱和沮丧的常见原因。不幸的是,大多数解决方案是不完整,过时的,并且提供了不好的建议。您永远不需要使用sudo或更改权限。

要进行有效的Ruby设置,需要执行5个步骤,我在definitive guide to installing Ruby gems on a Mac中对此进行了详细介绍。它说明了为什么会遇到这些错误,比较了各种解决方案,为什么有些解决方案比其他解决方案好,以及为什么不应该使用sudo

TL; DR:使用经过实践检验且可靠的自动化脚本,它将为您完成所有设置:https://github.com/monfresh/laptop