下面是我需要做的。

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


当前回答

在用rbenv安装ruby之后,你还需要设置全局ruby。为此,你可以这样做,rbenv全球3.2.1,然后安装绑定器与gem安装绑定器。它会起作用的。

其他回答

我使用参数——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.

我试了一下,效果很好 导出路径= / opt /组装/ opt / ruby / bin: / opt /组装/ lib / ruby /珠宝/ 3.0.0 / bin:美元的道路 出口LDFLAGS = " - l / opt /组装/ opt / ruby / lib” 出口CPPFLAGS = " - i / opt /组装/ opt / ruby /包括” Gem安装ffi

运行这个

$ rbenv init
# Load rbenv automatically by appending
# the following to ~/.zshrc:

eval "$(rbenv init -)"

按照说明,(在我的例子中,添加到~/.zshrc);)


同样重要的是:更改只有在重新启动控制台时才生效。两个选项

输入source <modified file> 关上再打开

正如@idleberg提到的,在Mac OS上,最好安装rbenv,以避免手动安装ruby时出现权限错误。

安装

$ brew update
$ brew install rbenv

在.bashrc文件中添加以下内容:

eval "$(rbenv init -)"

现在,我们可以查看可供安装的ruby版本列表

$ rbenv install -l

以安装2.3.8版本为例

$ rbenv install 2.3.8

现在我们可以全局地使用这个ruby版本

$ rbenv global 2.3.8

最后运行

$ rbenv rehash
$ which ruby
/Users/myuser/.rbenv/shims/ruby
$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-darwin17]

大胆尝试吧

现在安装捆扎器

$ gem install bundler

全部完成!

您需要安装rbenv并在rbenv下维护ruby版本。

编译安装rbenv rbenv init 将eval "$(rbenv init -)"追加到~/.bash_profile rbenv install {stable_version_#}你可以使用rbenv install -L获取版本号 Rbenv global {your_preferred_version_#}命令用于切换到ruby版本 Rbenv shell {your_preferred_version #} 宝石安装{任何你想要的宝石}

详情https://github.com/rbenv/rbenv