下面是我需要做的。

要运行规范,需要安装RSpec。首先,在项目的根目录下运行gem install bundler。然后,运行bundle install。要运行单个spec文件,可以运行如下命令:要一次运行所有规格,请运行bundle exec rspec。

所以,我在终端中输入gem安装捆绑器,并得到错误:

您没有/Library/Ruby/Gems/2.3.0目录的写权限。

这是在atom的项目文件中

source "https://rubygems.org"
gem "rspec", "~> 3.2.0"

我的问题是:

似乎终端给我的响应,因为我不应该改变ruby上的任何东西,我需要捆绑安装在原子?谁能告诉我如何使用原子或者在原子中运行任何东西?


当前回答

我使用参数——user-install运行以下命令:

gem install name_of_gem --user-install

Edit

There was one gem I still could not install (it required the Ruby.h headers of the Ruby development kit or something), then I tried the different version managers, but somehow that still did not really work as it was stated in the documentations how to just install and switch (it did just not switch the versions). Then I removed all the installed version managers and installed afterwards with brew install ruby the latest version and did set the PATH variable, too. (It will be mentioned after the installation of ruby from brew), which worked.

其他回答

如果您不想运行sudo,请使用自制程序安装ruby

brew install ruby
export GEM_HOME="$HOME/.gem"
gem install rails

您可能希望添加export GEM_HOME="$HOME/ "。“宝石”送给你~/。Bash_profile或.zshrc(如果使用ZSH)

注意:RubyGems保留旧版本的宝石,所以在更新后可以自由地做一些清理工作:

gem cleanup

在尝试了之前的方法后,我在《Big Sur》中发现了这种方法:

sudo gem install -n /usr/local/bin cocoapods

在M1 MacBook Air上测试(假设安装了Homebrew)

下面是上面的答案,我们可以运行:

brew install chruby ruby-install

安装最新的稳定ruby:

ruby-install ruby

然后运行以下命令获取版本号:

chruby

在你的~/。zshrc中:

export PATH=/opt/homebrew/bin:$PATH
source /opt/homebrew/opt/chruby/share/chruby/chruby.sh
source /opt/homebrew/opt/chruby/share/chruby/auto.sh
chruby 3.1.2

“3.1.2”是运行chruby时得到的输出。一定要在最后加上这一行。

每次安装新gem时,请记住重新启动终端。

我使用下面的命令删除了这些目录

sudo rm -rf \
  /Library/Ruby/Gems/2.6.0/{build_info,cache,doc,extensions,gems} \
  /Library/Ruby/Gems/2.6.0/specifications/*.gemspec \
  /Library/Ruby/Site

然后安装可可豆荚使用sudo宝石安装cocoapods 这对我很有效。谢谢

适用于Mac OS 12及以上版本,也适用于Mac OS 13 Xcode 14及以上版本

首先你打电话

出口GEM_HOME = " $ HOME / .gem” 在那之后 Gem安装cocoapods

家它帮助你☺️