I can’t get rubymine to run my tests even though they work fine on the command line. The problems seem to have started after upgrading some gems. When I hit ctrl+shft+F10 I get this:
/Users/williamjeffries/.rbenv/shims/bundle exec /Users/williamjeffries/.rbenv/versions/2.2.3/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/williamjeffries/code/myr-admin/bin/spring rspec /Users/williamjeffries/code/myr-admin/spec/controllers/orders_controller_spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter --example "OrdersController a single order a credit card order captured order"
Testing started at 6:08 PM ...
/Users/williamjeffries/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.13.1/lib/bundler/definition.rb:181:in `rescue in specs': Your bundle is locked to rake (12.0.0), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of rake (12.0.0) has removed it. You'll need to update your bundle to a different version of rake (12.0.0) that hasn't been removed in order to install. (Bundler::GemNotFound)
from /Users/williamjeffries/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.13.1/lib/bundler/definition.rb:175:in `specs'
from /Users/williamjeffries/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.13.1/lib/bundler/definition.rb:235:in `specs_for'
from /Users/williamjeffries/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.13.1/lib/bundler/definition.rb:224:in `requested_specs'
from /Users/williamjeffries/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:118:in `block in definition_method'
from /Users/williamjeffries/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.13.1/lib/bundler/runtime.rb:19:in `setup'
from /Users/williamjeffries/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.13.1/lib/bundler.rb:99:in `setup'
from /Users/williamjeffries/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.13.1/lib/bundler/setup.rb:20:in `<top (required)>'
from /Users/williamjeffries/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/williamjeffries/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
Process finished with exit code 1
It seems to think I don’t have rake 12.0.0 but a gem list rake reveals that I do:
$ gem list rake
*** LOCAL GEMS ***
rake (12.0.0, 11.2.2, 10.4.2)
I double checked and at time of posting, 12.0.0 is in fact both a valid version and the most recent stable build for rake: https://github.com/ruby/rake/releases
Any ideas why this might be failing and how to get RubyMine to run my tests successfully again?
The solution was to restart RubyMine.
Related
I get the following error when trying to do anything with Ruby, specifically ruby gems:
/usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/2.4.0/yaml.rb:5:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `require': incompatible library version - /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.so (LoadError)
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:34:in `require'
from /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.rb:16:in `rescue in <top (required)>'
from /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.rb:13:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/2.4.0/yaml.rb:6:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems.rb:729:in `load_yaml'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:349:in `load_file'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:202:in `initialize'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:79:in `new'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:79:in `do_configuration'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:44:in `run'
from /usr/local/rvm/rubies/ruby-2.4.5/bin/gem:21:in `<main>'
I believe the line of note is this one:
LoadError: incompatible library version - /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.so
I get this from gem install puppet, gem update, etc. I tried uninstalling and reinstalling libyaml, and same with Ruby. The error happened after I did bundle uninstall puppet to get it to stop pointing to the 6.3.0 gem and point to the 4.10.2 executable. I need Ruby to be able to use Rspec to test the modules. Does anyone know how I can fix this?
Without steps to reproduce the broken system it is hard to say what happened, but I can say in general how you can set this up correctly to use a specific version of Puppet.
Does this help? In the worst case, you can probably uninstall RVM and reinstall it.
Before I continue, let me note that Puppet 4.10.2 and 4.10.3 have both been removed from Rubygems. (Although I was able to install it with PDK.)
For the remainder I assume 4.10.4 instead (just to distinguish it from latest 4.10).
The recommended approach is to use Puppet Development Kit (pdk). If you download and install PDK, you probably just need to do these steps:
pdk convert
rm Gemfile.lock
PUPPET_GEM_VERSION=4.10.4 bundle update # If that version isn't already in PDK.
pdk test unit --puppet-version 4.10.4
If you don't want to go down the PDK path, you can try these alternatives:
Hardcode the version of Puppet you want in Gemfile.
gem 'puppet', '4.10.4'
Or:
gem 'puppet', '~> 4.10' # latest 4.10
Then update your bundle:
rm -f Gemfile.lock
bundle update
Or, you can implement the PUPPET_GEM_VERSION feature by adding this code (this is what I do, for what it's worth):
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion
else
gem 'puppet'
end
And then:
rm -f Gemfile.lock
PUPPET_GEM_VERSION='~> 4.10' bundle update
Now you can run your unit tests against a specific version of Puppet per normal:
bundle exec rake spec
Or however you set it up.
I'm using chruby to manage my Ruby versions, and Bundler's binstubs to avoid having to type "bundle exec". I'm running into issues I don't totally understand. Here's what I get when I try to run the test suite in our (Rails 4, Ruby 2.2.2) application:
$ rspec
/Users/duncanmalashock/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- simplecov (LoadError)
from /Users/duncanmalashock/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/duncanmalashock/ruby_projects/platform/spec/spec_helper.rb:3:in `<top (required)>'
from /Users/duncanmalashock/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/duncanmalashock/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/duncanmalashock/ruby_projects/platform/spec/controllers/admin/admin_controller_spec.rb:1:in `<top (required)>'
from /Users/duncanmalashock/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `load'
from /Users/duncanmalashock/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `block in load_spec_files'
from /Users/duncanmalashock/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `each'
from /Users/duncanmalashock/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
from /Users/duncanmalashock/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:102:in `setup'
from /Users/duncanmalashock/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:88:in `run'
from /Users/duncanmalashock/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:73:in `run'
from /Users/duncanmalashock/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:41:in `invoke'
from /Users/duncanmalashock/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/exe/rspec:4:in `<top (required)>'
from /Users/duncanmalashock/.gem/ruby/2.2.2/bin/rspec:23:in `load'
from /Users/duncanmalashock/.gem/ruby/2.2.2/bin/rspec:23:in `<main>'
When I run $ bundle exec rspec, the suite runs correctly. I've been looking into postmodern's gem_home, and have installed it, but it's not giving me the results I'm looking for. I'm using zsh on OSX Yosemite.
in .zshrc:
source /usr/local/share/chruby/chruby.sh
source '/usr/local/share/chruby/auto.sh'
source /usr/local/share/gem_home/gem_home.sh
export PATH=./.bundle/bin:$PATH
alias b='bundle install --path .bundle/gems --binstubs .bundle/bin'
Just install the simplecov gem in your system (simply do: gem install simplecov) and run your test again. It will work.
But, it's a better practice to use bundle exec to run the rake or rspec commands. Because that way, you would ensure that the command is running in the context of your Gemfile.
You can add these aliases to your .zshrc file:
alias ber="bundle exec rspec"
alias be="bundle exec"
And, then run your rspec tests like this:
ber
or,
be rspec
Your problem is that bundler has installed simplecov local to the project and you are trying to run the system global rspec. That is going to look for simplecov in the system ruby library location. Using a Ruby language version manager is not going to change this behaviour. It will just use the versioned ruby's library location instead.
If you wish your versioned Ruby to use rspec and simplecov together then you need to install simplecov in your versioned ruby using whatever tool equivalent to gem that is provided.
I am not sure why you find running bundle exec of great import. One can always create an alias in .bashrc or .bash_profile. I have two for bundle exec, one is be and the other bexec. I also have aliases for bundle exec rails (brails) and bundle exec rake (break). In practice I find that these are really little different than running the customary commands.
I'm trying to play around with serverspec, however it seems I have some weird gem error that I cannot pinpoint.
$ rake spec
/usr/bin/ruby -I/usr/lib/ruby/gems/1.8/gems/rspec-support-3.0.2/lib:/usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib -S /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/exe/rspec spec/localhost/httpd_spec.rb
/home/mikolajewskim/puppet-master/spec/spec_helper.rb:1:in `require': no such file to load -- serverspec (LoadError)
from /home/mikolajewskim/puppet-master/spec/spec_helper.rb:1
from /home/mikolajewskim/puppet-master/spec/localhost/httpd_spec.rb:1:in `require'
from /home/mikolajewskim/puppet-master/spec/localhost/httpd_spec.rb:1
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `load'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `load_spec_files'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `each'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `load_spec_files'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:97:in `setup'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:85:in `run'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:70:in `run'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:38:in `invoke'
from /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/exe/rspec:4
/usr/bin/ruby -I/usr/lib/ruby/gems/1.8/gems/rspec-support-3.0.2/lib:/usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/lib -S /usr/lib/ruby/gems/1.8/gems/rspec-core-3.0.2/exe/rspec spec/localhost/httpd_spec.rb failed
Still, when I look at the list of gems, serverspec is there (1.9.0). I've also checked it's existance in gems directory. I'm running a system version of ruby 1.8.7 and I do not have multiple ruby installations.
I'm not really sure where to go from here. Thanks in advance for any help.
What helped was:
1) Upgrading ruby package on the system (still 1.8.7).
2) Upgrading rubygems.
3) Removing all gems.
4) Installing serverspec and rake again.
I'm trying to work through the Ruby course from TestFirst.org. It requires you to navigate to the folder containing the exercise, run rake, and then correct any errors in the source code it uncovers. When I run rake in the folder for the first exercise it gives this error:
rake aborted!
Could not find rspec (~> 2) amongst [diff-lcs-1.2.5, rspec-3.0.0, rspec-core-3.0.0,
rspec- expectations-3.0.0, rspec-mocks-3.0.1, rspec-support-3.0.0]
/home/jayson/Desktop/learn_ruby/Rakefile:2:in `<top (required)>'
(See full trace by running task with --trace)
Does this means it will only work with an old version of rspec or something else? Running rake with --trace gives me:
rake aborted!
Could not find rspec (~> 2) amongst [diff-lcs-1.2.5, rspec-3.0.0,
rspec-core-3.0.0, rspec-expectations-3.0.0, rspec-mocks-3.0.1, rspec-support-3.0.0]
/usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs'
/usr/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
/usr/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
/home/jayson/Desktop/learn_ruby/Rakefile:2:in `<top (required)>'
/usr/lib/ruby/vendor_ruby/rake/rake_module.rb:25:in `load'
/usr/lib/ruby/vendor_ruby/rake/rake_module.rb:25:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:589:in `raw_load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:89:in `block in load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:160:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:88:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:72:in `block in run'
/usr/lib/ruby/vendor_ruby/rake/application.rb:160:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:70:in `run'
/usr/bin/rake:27:in `<main>'
How do I get the rake command to work properly? I'm using Terminal in Ubuntu 14.04, with Ruby 1.9.3, RubyGems 1,8.23, and Rspec 3.0.0. Thanks in advance.
I had the same problem, and sudo gem install -v '<3.0.0' rspec did work, but only after I uninstalled the newer version with gem uninstall rspec.
Without that uninstall first, only the later version remains active and the problem will continue.
hope this help.
gem install rspec -v 2.9.0
It happen because:
Could not find rspec (~> 2)
while rspec version installed on your machine is: rspec-3.0.0
Source: RubyGems
this is probably a stupid question but I can't seem to find the answer.
I'd like to contribute to kaminari, so I forked the repo, bundle'd it, and now I would like to run the specs to ensure all's green. But I can't seem to make it work :
bin/rake spec
/Users/Ksoltysiak/.rbenv/versions/1.9.3-p125/bin/ruby -S rspec spec/config/config_spec.rb spec/helpers/action_view_extension_spec.rb spec/helpers/helpers_spec.rb spec/helpers/sinatra_helpers_spec.rb spec/helpers/tags_spec.rb spec/models/active_record/active_record_relation_methods_spec.rb spec/models/active_record/default_per_page_spec.rb spec/models/active_record/scopes_spec.rb spec/models/array_spec.rb spec/models/data_mapper/data_mapper_spec.rb spec/models/mongo_mapper/mongo_mapper_spec.rb spec/models/mongoid/mongoid_spec.rb spec/requests/users_spec.rb
warning: no framework detected.
would you check out if your Gemfile appropriately configured?
---- e.g. ----
when Rails:
gem 'kaminari'
when Sinatra/Padrino:
gem 'kaminari', :require => 'kaminari/sinatra'
when Grape:
gem 'kaminari', :require => 'kaminari/grape'
/Users/Ksoltysiak/Documents/Repositories/kaminari/spec/models/array_spec.rb:3:in `<top (required)>': uninitialized constant Kaminari::PaginatableArray (NameError)
from /Users/Ksoltysiak/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `load'
from /Users/Ksoltysiak/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'
from /Users/Ksoltysiak/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `map'
from /Users/Ksoltysiak/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `load_spec_files'
from /Users/Ksoltysiak/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/command_line.rb:22:in `run'
from /Users/Ksoltysiak/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:69:in `run'
from /Users/Ksoltysiak/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:10:in `block in autorun'
rake aborted!
/Users/Ksoltysiak/.rbenv/versions/1.9.3-p125/bin/ruby -S rspec spec/config/config_spec.rb spec/helpers/action_view_extension_spec.rb spec/helpers/helpers_spec.rb spec/helpers/sinatra_helpers_spec.rb spec/helpers/tags_spec.rb spec/models/active_record/active_record_relation_methods_spec.rb spec/models/active_record/default_per_page_spec.rb spec/models/active_record/scopes_spec.rb spec/models/array_spec.rb spec/models/data_mapper/data_mapper_spec.rb spec/models/mongo_mapper/mongo_mapper_spec.rb spec/models/mongoid/mongoid_spec.rb spec/requests/users_spec.rb failed
I tried to bypass bundler, but then I got gems issues with versions and stuff. So what am I missing here ? I don't find anything on the wiki or the issues, or even here about this.
Thanks for your time!
I recently made series of changes on Kaminari tests. https://github.com/amatsuda/kaminari/compare/b61db76...1f8389ae
As a result of this big refactoring, now the tests can be run separately per each ORM library, for example like this:
BUNDLE_GEMFILE=gemfiles/active_record_32.gemfile bundle exec rake spec
To run all tests at once, you should invoke spec:all task:
bundle exec rake spec:all
I'm aware that this is a bit unusual. At least it apparently needs to be documented. I'll do so till the next stable release.
Or if you have any better solution, please tell me.