下面是我需要做的。

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


当前回答

这在Mac上很管用

sudo chown -R $(whoami) $(brew -prefix)/*

其他回答

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

这在Mac上很管用

sudo chown -R $(whoami) $(brew -prefix)/*

为了解决这个问题,我跑了

brew reinstall ruby

是谁向我展示了这条信息

= = >警告 = = > ruby 默认情况下,gem安装的二进制文件将被放置到: / opt /组装/ lib / ruby /珠宝/ 3.1.0 / bin 您可能希望将此添加到PATH中。 Ruby是只有酒桶的,这意味着它没有符号链接到/opt/homebrew, 因为macOS已经提供了这个软件,并且正在安装另一个版本 并行会引起各种各样的麻烦。 如果你需要在PATH中先有ruby,运行: echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.profile . PATH

所以我把这两行加到~/中。bashrc文件(

export PATH="/opt/homebrew/opt/ruby/bin:$PATH"
export PATH="/opt/homebrew/lib/ruby/gems/3.1.0/bin:$PATH"

然后我打开了一个新的终端。应用程序窗口和运行我的gem安装命令再次工作。

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

在我的例子中,这个问题与ruby访问有关,ruby路径在我的系统中是如何混乱的。

下面的步骤帮助我解决了这个问题

打开终端 使用自制程序安装ruby

安装ruby

[用于重新安装]brew重装ruby

使用下面的命令检查ruby的路径 这红宝石 它应该安装在下面的路径 /usr/bin/ruby 将ruby路径更改为用户路径

检查您的系统使用了哪个shell

echo $0

-zsh

对于zshrc

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >>~/.zshrc . bin:$PATH

在bash

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >>~/~/.bashrc . bin:$PATH

退出并重新启动终端 用步骤5改变路径后 再次检查ruby的路径(执行步骤3 -请确保路径如下所示)

/usr/local/opt/ruby/bin/ruby

[如果您不退出并启动终端,将显示步骤4路径]

这一步可能并不适用于所有人,如果你安装了正确的Cocoapods版本,可以跳过第10和11步

检查安装的pod的版本

豆荚,版本

使用下面的命令卸载特定版本的Cocoapods

如果安装的版本是1.11.0

卸载cocoapods 1.11.0

安装特定版本的Cocoapods 安装cocoapods 1.11.0 将路径更改为Project目录cd {Project目录的路径} 在项目目录中安装捆绑程序

包安装

执行pod安装

正在安装

请小心使用sudo !!!!!!只有当你知道你在做什么!!!!!!!!!!!!

在安装macOS Catalina后,我也遇到了同样的问题。我尝试下命令和它的工作。

sudo gem update