下面是我需要做的。

要运行规范,需要安装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后忘记运行以下程序:

~ /来源。ZSHRC -或其他~/…Rc文件,具体取决于您的终端

其他回答

正如@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

全部完成!

我正在使用下面的命令来安装fastlane,但没有工作

宝石安装快车道-NV

所以使用sudo安装宝石对我来说很有用,就像

sudo gem install fastlane -NV

在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时,请记住重新启动终端。

mac解决方案。执行命令

sudo gem update    

然后按提示输入你的Mac密码

博士TL;

在一些情况下,我通过关闭终端会话并在重新尝试失败的命令之前打开一个新的会话来解决这类错误。

长解释

在一些SOs(如MacOS)中,已经预先安装了ruby的系统级版本。如果您正在使用版本管理器,例如rbenv或asdf,它们通过处理当前会话的环境来工作,以便相关命令指向版本管理器安装的二进制文件。

When installing a new binary, the version manager installs it in a special location, usually somewhere under the user's home directory. It then configures everything in your PATH so that you get the freshly installed binaries when you issue a command, instead of the ones that came with your system. However, if you don't restart the session (there are other ways of getting your environment updated, but that's the easiest one) you don't get the new configuration and you will be using the original installation.