Sublime Text 2 中的 RubyTest
我正在尝试让 RubyTest 在 Sublime Text 2 中工作。我遵循查看 Github Readme 上的说明并收到以下错误。有谁知道我该如何解决这个问题?
/bin/sh: rspec: command not found
I am trying to get RubyTest to work in Sublime Text 2. I followed the Instruction on the Github Readme and get the following error. Does anyone know how I could fix this?
/bin/sh: rspec: command not found
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
要使其正常工作,您只需更改 sb2 中 RubyTest 包中的一项设置。
如果你使用的是rvm,你的rspec gem是通过rvm安装的,并且在/bin/sh中找不到
,所以你需要为Sublime Text 2设置RubyTest包来自动检查你的rvm环境变量。
要更改的内容:
1) 在 Sublime Text 2 中,转到首选项|浏览包。这将打开您的包目录。
2)打开“RubyTest”目录并查找文件“RubyTest.sublime-settings”。
3) 找到显示以下内容的行:
并将其更改为:
保存更改。
4)就是这样。现在应该可以了。
祝你好运
To get this to work you only need to change one setting in the RubyTest package in sb2.
If you are using rvm, your rspec gem is installed through rvm and is not found in /bin/sh
So you need to set the RubyTest package for Sublime Text 2 to automatically check for your rvm environment variables.
What to change:
1) In Sublime Text 2, go to Preferences|Browse Packages. This will open up your packages directory.
2) Open the 'RubyTest' directory and look for the file 'RubyTest.sublime-settings'.
3) find the line that says:
and change it to:
save the change.
4) That's it. It should now work.
Good Luck
这对我有用:
如果您使用 RVM,请从项目文件夹中使用命令行打开项目:
然后,它将挂钩 ruby 版本和 gems。
This worked for me:
If you're using RVM, open a project with command line from the project's folder:
Then, it'll hook the ruby version and gems.
这很可能是由于使用 RVM 造成的。 的输出是什么
命令行上
?另外值得注意的是,仅仅因为您已将 rspec-rails 包含在 Gemfile 中,并不意味着“rspec”是您的系统知道的可执行程序。
您可以编辑 RubyTest.sublime.settings 以引用 rspec 可执行文件的特定路径,它应该可以工作。
不幸的是,这会产生与某个特定版本的 Ruby 相关的令人讨厌的副作用。如果您使用 RVM 在版本之间切换,则必须更新 sublime.settings。
解决方法之一是从命令行运行 Sublime。
This is most likely due to using RVM. What is the output of
on your command line?
Also of note, just because you've included rspec-rails in a Gemfile, does not mean that 'rspec' is an executable program that your system knows about.
You can edit the RubyTest.sublime.settings to refer to your particular path to the rspec executable and it should work.
Unfortunately, this has the nasty side effect of being tied to one particular version of Ruby. If you're using RVM to switch between versions, you'll have to update your sublime.settings.
One work around, is to run Sublime from the command line.
使用 RubyTest 插件运行 Sublime Text 2(2165)。 Ruby 和 Gems 使用 rbenv (0.3.0) 进行管理。
第一次尝试使用 RubyTest 出现以下错误:
/bin/sh: rspec: command not find
从我运行的命令行
哪个 rspec
它没有返回任何结果。
经过一番挖掘,我发现
bundle install
不会将可执行文件放入您的 $PATH 中。有时垫片未拾取替代可执行路径
为了在应用程序外部使用可执行文件,我必须删除gem由bundler安装,然后手动安装。
gem uninstall rspec
gem install rspec
后跟
rbenv rehash
(注意,您需要运行bundle< /code> 在你的应用程序中,以便它更新 gem 的位置)
这必须对我在 rbenv 控制下的每个版本的 ruby 执行。
现在,当我运行
which rspec
时,它会在路径中找到,并且 RubyTest 能够毫无问题地获取它。
fwiw,我也必须对黄瓜重复这些步骤。要使用 RubyTests 的所有功能,ruby、cucumber 和 rspec 可执行文件需要位于您的 $PATH 中(对于 rbenv,它是
~/.rbenv/shims/
)。Running Sublime Text 2(2165) with RubyTest plugin. Ruby and Gems managed with rbenv (0.3.0).
First attempt to use RubyTest gave the following error:
/bin/sh: rspec: command not found
From the command line I ran
which rspec
and it returned no results.
After some digging, I read that
bundle install
does not put the executables in your $PATH.Alternative executable paths not picked up by shims sometimes
In order to use the executible outside the app, I had to delete the gem installed by bundler and then install it manually.
gem uninstall rspec
gem install rspec
followed by
rbenv rehash
(Note you will need to runbundle
inside your app so it updates the location of the gem)This had to be performed for each version of ruby I have under rbenv control.
Now when I run
which rspec
it is found in the path and RubyTest is able to grab it without any problems.
fwiw, I had to repeat the steps for cucumber as well. To use all of RubyTests' features, ruby, cucumber and rspec executables need to be in your $PATH (for rbenv it is
~/.rbenv/shims/
).尝试将路径更改为
usr/local/bin/
我写了一篇关于 Sublime Text Build Scripts 的文章,它应该向您展示如何执行此操作。
http://wesbos.com/sublime-text-build-scripts/
Try change the path to
usr/local/bin/
I wrote a post on Sublime Text Build Scripts which should show you how to do this.
http://wesbos.com/sublime-text-build-scripts/
对我来说同样的问题。对于 rspec 1.3.2,我刚刚修复它的方法是编辑插件文件夹中的 RubyTest.sublime.settings 文件,将“ruby_rspec_exec”键从: 更改
为
:这实际上取决于 rspec 可执行文件的位置。 ..
Same issue for me. With rspec 1.3.2 what I just did to fix it is to edit the RubyTest.sublime.settings file in the plugin folder, changing the "ruby_rspec_exec" key from:
to
It really depends on the location where you have your rspec executable file...
通过从存储库克隆安装 RubyTest 后,我遇到了同样的问题。我只是使用 Package Control 在 Sublime 中卸载并重新安装了该包,然后一切正常。
I had the same problem after installing RubyTest by cloning from the repo. I simply uninstalled and reinstalled the package inside Sublime using Package Control, then everything worked fine.
您可以在此处查看此问题的摘要:https://github .com/maltize/sublime-text-2-ruby-tests/issues/36
本质上,Jim 所说的是正确的,您正在运行 RVM 或其他一些与您的 PATH 类似的 ruby 虚拟机管理器。按照此问题的指示,我执行了以下操作:
在我的项目中安装二进制文件
将路径添加到我的 .bashrc 并获取它
从命令行打开 sublime 项目(以便 PATH 在 Sublime Text 2 中可用)
You can see a summary of this issue here: https://github.com/maltize/sublime-text-2-ruby-tests/issues/36
Essentially, what Jim said was correct, you're running RVM or some other ruby vm manager that similarly monkeys with your PATH. Following the directions from this issue I did the following:
Install the binaries in my project
Add the path to my .bashrc and source it
Open the sublime project from the command line (so that PATH is available in Sublime Text 2)
以下步骤对我有用(我遇到了与OP相同的错误):
通过包控制管理器安装RubyTest插件。
注意* 如果您没有安装包管理器 - 我强烈推荐它来管理 sublime 插件 - 更多信息此处.
请务必将此处的代码添加到您的 RubyTest.sublime-settings 文件中。
该文件可以在(从菜单中)找到:
Preferences ->套餐设置-> Ruby测试->设置用户
保存文件,关闭 Sublime 并从项目文件夹中的终端重新启动 Sublime(因此 PATH 在 Sublime 中可用):
subl .
The following steps worked for me (I encountered the same error as OP):
Install the RubyTest plugin through the package control manager.
Note* If you don't have the package manager installed - I highly recommend it for managing sublime plugins - more info here.
Be sure to add the code here to your RubyTest.sublime-settings file.
This file can be found at (from the menu):
Preferences -> Package settings -> RubyTest -> Settings User
Save file, close Sublime and restart Sublime from the terminal in your project's folder using (so PATH is available in Sublime):
subl .
不,您不需要更改路径,从命令行运行 sublime 等。
如果您使用的是 RVM,则只需执行以下操作:
转到 Sublime Text 2,转到
偏好->套餐设置-> RubyTests
并选择 settings-user 或 settings-default (取决于您使用的内容)并将 line: 更改
为
等等 - 将 bundle exec 添加到所有命令
No, you don't need to change paths, run sublime from command line etc.
If you are using RVM, you only have to do this:
Go to Sublime Text 2, go to
preferances-> package settings -> RubyTests
and pick settings-user or settings-default (depending what you are using) and change line:
to
And so forth - add bundle exec to all commands
我花了很多时间来解决同样的问题!我无法使用 Michael Hartl“Ruby on Rails 教程”在 Sublime Text 2 中运行 rspec。它一直说:
我终于意识到RubyTest包(https://github.com /maltize/sublime-text-2-ruby-tests)在错误的地方寻找我的 RVM!
在我的 Mac 上,RubyTest 的路径是
/Library/Application Support/Sublime Text 2/Packages/Ruby Test
首先,为了让 RubyTest 寻找 RVM,我将 RubyTest.sublime-settings 中的参数从
然后我深入研究了 run_ruby_test.py 的 Python 代码: https://github.com/maltize/sublime-text -2-ruby-tests/blob/master/run_ruby_test.py
在 BaseRubyTask 类中的第 151 行,它的 RVM 路径错误:
我将其更改为完整路径正确路径:
rvm_cmd = os.path.expanduser('/usr/local/rvm/bin/rvm-auto-ruby')
如果这不是您的路径,请输入
$ which rvm-auto-ruby
并替换它。保存 run_ruby_test.py 后,我进入终端,cd 到我的 Rails 应用程序目录,然后运行 spork
最后,我在 Sublime Text 2 中打开 static_pages_spec.rb 。现在所有测试都可以通过它进行!
I spent many hours struggling with this same problem! I could not get rspec to run within Sublime Text 2, using the Michael Hartl "Ruby on Rails Tutorial." It kept saying:
I finally realized that the RubyTest package (https://github.com/maltize/sublime-text-2-ruby-tests) was looking in the WRONG PLACE for my RVM!
On my Mac, the path for RubyTest is
/Library/Application Support/Sublime Text 2/Packages/Ruby Test
First, to make RubyTest seek the RVM, I changed the parameter in RubyTest.sublime-settings from
Then I dug into the Python code of run_ruby_test.py: https://github.com/maltize/sublime-text-2-ruby-tests/blob/master/run_ruby_test.py
At line 151, inside class BaseRubyTask, it had the wrong path for my RVM:
I changed it to the full correct path:
rvm_cmd = os.path.expanduser('/usr/local/rvm/bin/rvm-auto-ruby')
If this is not your path, find the correct path by typing
$ which rvm-auto-ruby
and substitute that instead.After saving run_ruby_test.py, I went to Terminal, cd to my Rails application directory, and ran
spork
Finally, I opened static_pages_spec.rb in Sublime Text 2. Now all the tests work from it!
我正在使用 rbenv 并发现将以下内容添加到我的 .bashrc 中就可以了
I'm using rbenv and found that adding the following to my .bashrc did the trick