下面是我需要做的。

要运行规范,需要安装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上的任何东西,我需要捆绑安装在原子?谁能告诉我如何使用原子或者在原子中运行任何东西?


当前回答

如果你已经单独安装了ruby,并且使用rbenv/rvm安装了ruby,那么你的指针可能指向不同的版本。

try

gem env home

and

ruby -v

两者应该指向相同的版本。检查您是否使用rbenv/rvm安装了ruby,如果是,请删除您单独安装的ruby版本。

为了让gem工作,您必须调用rbenv,

rbenv shell <ruby version> 

and

rbenv global <ruby version>

我不确定RVM是如何工作的。 如果有用请告诉我。

其他回答

通常建议使用rbenv或rvm之类的版本管理器。否则,安装的Gems将作为根用户供其他用户使用。

如果你知道你在做什么,你可以使用sudo gem install。

尝试1到2个

1 - $ gem install cocoapods
2 - $ sudo gem install cocoapods

如果它不工作,然后导出GEM_HOME:

export GEM_HOME="$HOME/.gem"

再试一次:

gem install cocoapods

记住,官方医生说你可以使用sudo (https://guides.cocoapods.org/using/getting-started.html#getting-started)。

我使用参数——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宝石卸载cocoapods为我工作。

只需导出GEM_HOME:

export GEM_HOME="$HOME/.gem"

然后试试:

gem install cocoapods