Ruby   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – Ruby on Rails:/ bin / sh:rspec:command not found大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在通过Michael Hartl的RoR教程,当试图运行Spork和Guard时,我坚持第3章.当试图运行测试我得到:

/ bin / sh:rspec:command not found

是的,我看了周围的答案,但我看不到RubyTest.sublime.setTings文件在哪里,所以我不知道如何编辑它.任何人都可以帮助我解决我的错误?

这是我的用户fodler中的Rubytest.sublime.setTings文件

{
  "erb_verify_command": "bundle exec erb -xT - {file_name} | ruby -c","ruby_verify_command": "bundle exec ruby -c {file_name}","run_ruby_unit_command": "bundle exec ruby -Itest {relative_path}","run_single_ruby_unit_command": "bundle exec ruby -Itest {relative_path} -n     '{test_name}'","run_cucumber_command": "bundle exec cucumber {relative_path}","run_single_cucumber_command": "bundle exec cucumber {relative_path} -l{line_number}","run_rspec_command": "bundle exec rspec {relative_path}","run_single_rspec_command": "bundle exec rspec {relative_path} -l{line_number}","ruby_unit_folder": "test","ruby_cucumber_folder": "features","ruby_rspec_folder": "spec","ruby_use_scratch" : false,"save_on_run": false,"ignored_directories": [".git","vendor","tmp"],"hide_panel": false,"before_callBACk": "","after_callBACk": ""
}

解决方法

升华插件正在尝试使用sHell / bin / sh运行命令rspec.但是,由于RVM没有加载到sHell的环境中,所以找不到该命令.

因此,rspec可执行文件所在的文件夹不在sHell的搜索路径(PATH环境变量)中. RVM安装任何可执行的命令,与宝石一起放在以下位置:“/home/your-user/.rvm/gems/ruby-1.9.3-p194@myproject/bin/”(实际路径取决于您的gemset,ruby版本,并且您的操作系统存储用户主目录的位置)

简单的解决方案

如上所述here …您@R_807_9381@,只需从包含RVM的sHell环境(即:您的项目目录)执行升华即可解决PATH问题.但是,这需要您每次从命令行执行文本编辑器,并且保护sHell的环境.

cd ~/src/my-ruby-project
subl .

经过多次实验,我发现了一种方法来强制RubyTest插件使用正确的RVM控制环境执行rspec(支持Bundler).

与Bundler支持

以下是我的〜/ .config / sublime-text-2 / Packages / RubyTest / RubyTest.sublime-setTings文件的内容:

{
  "erb_verify_command": "~/.rvm/bin/rvm-auto-ruby $(~/.rvm/bin/rvm gemdir | sed -e 's/@.*//' -e 's/$/@global/' )/bin/bundle exec erb -xT - {file_name} | ~/.rvm/bin/rvm-auto-ruby -c","ruby_verify_command": "~/.rvm/bin/rvm-auto-ruby -c {file_name}","run_ruby_unit_command": "~/.rvm/bin/rvm-auto-ruby -Itest {relative_path}","run_single_ruby_unit_command": "~/.rvm/bin/rvm-auto-ruby -Itest {relative_path} -n '{test_name}'","run_cucumber_command": "~/.rvm/bin/rvm-auto-ruby $(~/.rvm/bin/rvm gemdir | sed -e 's/@.*//' -e 's/$/@global/' )/bin/bundle exec cucumber {relative_path}","run_single_cucumber_command": "~/.rvm/bin/rvm-auto-ruby $(~/.rvm/bin/rvm gemdir | sed -e 's/@.*//' -e 's/$/@global/' )/bin/bundle exec cucumber {relative_path} -l{line_number}","run_rspec_command": "~/.rvm/bin/rvm-auto-ruby $(~/.rvm/bin/rvm gemdir | sed -e 's/@.*//' -e 's/$/@global/' )/bin/bundle exec rspec {relative_path}","run_single_rspec_command": "~/.rvm/bin/rvm-auto-ruby $(~/.rvm/bin/rvm gemdir | sed -e 's/@.*//' -e 's/$/@global/' )/bin/bundle exec rspec {relative_path} -l{line_number}","after_callBACk": ""
}

只要您在全局gemset中有捆绑器,并且将RVM安装到您的家庭目录(只要〜/ .rvm无法正确评估),或者如果bundler或rvm-auto-ruby位于某处其他).

如果您使用gemsets,您还应该在项目的.rvmrc文件中添加如下所示的行:

rvm use ruby-1.9.3-p327@your_project_gemset_name

没有Bundler支持

这假设你将黄瓜和rspec安装到您当前的红宝石的@global gemset中:

{
  "erb_verify_command": "~/.rvm/bin/rvm-exec $(~/.rvm/bin/rvm current) 1>/dev/null erb -xT - {file_name} | ~/.rvm/bin/rvm-auto-ruby -c","run_cucumber_command": "~/.rvm/bin/rvm-auto-ruby $(~/.rvm/bin/rvm gemdir | sed -e 's/@.*//' -e 's/$/@global/' )/bin/cucumber {relative_path}","run_single_cucumber_command": "~/.rvm/bin/rvm-auto-ruby $(~/.rvm/bin/rvm gemdir | sed -e 's/@.*//' -e 's/$/@global/' )/bin/cucumber {relative_path} -l{line_number}","run_rspec_command": "~/.rvm/bin/rvm-auto-ruby $(~/.rvm/bin/rvm gemdir | sed -e 's/@.*//' -e 's/$/@global/' )/bin/rspec {relative_path}","run_single_rspec_command": "~/.rvm/bin/rvm-auto-ruby $(~/.rvm/bin/rvm gemdir | sed -e 's/@.*//' -e 's/$/@global/' )/bin/rspec {relative_path} -l{line_number}","after_callBACk": ""
}

大佬总结

以上是大佬教程为你收集整理的ruby-on-rails – Ruby on Rails:/ bin / sh:rspec:command not found全部内容,希望文章能够帮你解决ruby-on-rails – Ruby on Rails:/ bin / sh:rspec:command not found所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。