下面是我需要做的。

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


当前回答

博士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.

其他回答

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

宝石安装快车道-NV

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

sudo gem install fastlane -NV

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

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安装命令再次工作。

应该使用不同的ruby安装。为此我使用rbenv。

# install your version of ruby
$ rbenv install 2.0.0-p247

# modify .ruby_version on current directory
$ rbenv local 2.0.0-p247

# proceed installing gems
$ gem install bundler

免责声明:我不喜欢红宝石。这对我来说很有效,如果你是一个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是如何工作的。 如果有用请告诉我。

有同样的错误,因为我在安装ruby后忘记运行以下程序:

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