I'm running ruby on rails v2.2.2 and when I run rake gems I get this error.
$ rake gems --trace
- [I] settingslogic
rake aborted!
You have a nil object when you didn't expect it!
The error occured while evaluating nil.dependencies
/vendor/rails/railities/lib/rails/gem_dependency.rb:77:in `dependencies'
I figured out what was going on. There is a bug in the core rake gems function where it assumed there were specifications for the gem and would error out when it didn't exist for that gem.
Here is the ticket for this issue with a working patch
http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1464
Could be a problem with a gem it's trying to load, or your setup of required gems. Check config/environment.rb for any odd-looking config.gem lines, and do an update of all your gems (sudo gem update).
There is a bit more detail here with two alternate workarounds
-add one line to the dependency code in rails
or
-specify gem dependencies before the gem
Related
I'm trying to extract a couple of tasks into a gem, but cannot get the code to load in my Capfile. The code is at: https://github.com/floydj/capistrano-mysql_tables.
In my Gemfile:
gem "capistrano-mysql_tables", github: "floydj/capistrano-mysql_tables"
In my Capfile:
require "capistrano/mysql_tables"
After bundle install, it seems to be good, but running cap -T results in:
(Backtrace restricted to imported tasks)
cap aborted!
LoadError: cannot load such file -- capistrano/mysql_tables
What is wrong with the code in the gem? I've looked at other Capistrano plugins and have tried to imitate them, but it always gives this error and I've run out of things to try. It appears to be some kind of path problem, maybe. Here's what I see with gem contents:
$ bundle exec gem contents capistrano-mysql_tables
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/Gemfile
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/Gemfile.lock
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/LICENSE.txt
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/README.md
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/Rakefile
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/bin/console
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/bin/setup
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/capistrano-mysql_tables.gemspec
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/lib/capistrano-mysql_tables.rb
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/lib/capistrano/mysql_tables.rb
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/lib/capistrano/mysql_tables/version.rb
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/lib/capistrano/tasks/mysql_tables.rake
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/test/capistrano/mysql_tables_test.rb
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/test/test_helper.rb
Update:
After fixing the mistake found by #Alex, it still didn't work. However, I decided to push the gem to RubyGems, and then install via Gemfile in the standard way:
gem "capistrano-mysql_tables"
And after the standard install command, it works fine. But why does it work now? I suppose it has something to do with paths, the contents now list the following:
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/Gemfile
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/Gemfile.lock
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/LICENSE.txt
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/README.md
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/Rakefile
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/bin/console
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/bin/setup
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/capistrano-mysql_tables.gemspec
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/lib/capistrano-mysql_tables.rb
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/lib/capistrano/mysql_tables.rb
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/lib/capistrano/mysql_tables/version.rb
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/lib/capistrano/tasks/mysql_tables.rake
I'm glad I got it working, but would like to know why it failed before? Any ideas?
I've been using the yaml_db gem for a long time to dump the database to yaml and then reload it later if needed. On a fresh project, though, on rake db:load I got the error message:
NoMethodError: undefined method `load_documents' for Psych:Module
Did you mean? load_stream
/Users/user/.rvm/gems/ruby-2.5.0/gems/yaml_db-0.6.0/lib/yaml_db.rb:61:in `load_documents'
I am submitting the solution I finally came up with as an answer, but I'm not really happy with it. If anyone has a better solution or a suggestion of something better than the yaml_db gem for dumping and reloading the database, I'd be happy to listen.
I'm running Rails 5.1.4 on Ruby 2.5.0
The solution I came up with was to put the 'psych' gem in my Gemfile before yaml_db and set it to an earlier release:
gem 'psych', '~> 2.2.1'
gem 'yaml_db'
This issue is caused by load_documents being deprecated in Psych and finally removed in ruby 2.5. There's an open PR on yaml_db that fixes this issue, so hopefully future versions will not require you to use this work-around.
Your current solution is probably the easiest for now (short of downgrading your ruby version, which is probably a worse idea).
I just installed Rails3 Bootstrap Device Cancan in my local machine and ran rake spec but I'm getting all test failures with below error in common:
undefined local variable or method 'postgresql_version' for #<ActiveRecord::ConnectionAdaptors::SQLite3Adaptor:0x489dff8>
I'm not sure why I'm getting this since I followed the instructions on https://github.com/RailsApps/rails3-bootstrap-devise-cancan carefully.
I'm currently running this on Windows 8 and used Bitnami RubyStack to run CMD
I ran into the same problem and this is how I resolved it.
It looks like there is a problem with version 1.1.0 of database_cleaner. See "database_cleaner >= 1.1.0 is broken for SQLite" (https://github.com/gregbell/active_admin/issues/2388). I updated my Gemfile to set
gem 'database_cleaner', '< 1.1.0'
then ran "bundle install" and after it completed, "rake spec" ran cleanly.
Double-check your database.yml. Refer to Configuring Rails Applications, Section 3.12, Configuring a Database.
Did you intend to use sqlite3? Is sqlite3 in your Gemfile? Naturally, SQLite3Adaptor will not respond to postgresql_version! Can you include a few more lines of the stack trace?
I doubt this has anything to do with devise or cancan.
I'm trying to run Redmine on Heroku. Redmine returns a 500 error, presumably because my rake db:migrate fails:
at /app/lib/tasks/email.rake:170
rake aborted!
undefined method `has_key?' for nil:NilClass
The Heroku stack is bamboo-ree-1.8.7. Here's my Gemfile:
source :gemcutter
gem 'i18n', '0.4.2'
gem 'rails', '2.3.11'
gem 'coderay', '0.9.7'
gem 'rack', '1.1.1'
gem 'rake', '0.8.7'
gem 'rubytree'
How do I get heroku rake db:migrate to work?
you should lock your rubytree gem to 0.5.2
try this
gem "rubytree", "0.5.2"
I got this to work by doing two things.
First, I followed some suggestions from http://bayleshanks.com/tips-computer-programming-redmineOnHeroku (specifically I added the suggested line to config/environment.rb and created a blank file called public/plugin_assets/README).
Second, I modified the Gemfile to specify rubytree version 0.6.2, ran bundle install, re-committed the Gemfile.lock into git, and pushed to Heroku.
I'm not sure the earlier steps were necessary, but the database migration finally worked and Redmine is now running.
+1, the above worked for me as well, after satisfying a number of other dependency problems. Ideally, someone should write up a good HOWTO on deploying Heroku, though Ruby/Rails is such a moving target, it would likely only be accurate for a few minutes.
While trying to migrate, I keep getting this error:
rake aborted!
test-unit is not part of the bundle. Add it to Gemfile.
If I'm using RSpec, can I just delete the test folder altogether?
This error means that somewhere inside your project there is a require test-unit without it being specified in the Gemfile.
So you should actually try to find that statement and remove it to fix this error (or add the dependency to the gemfile --but that sounds a bit backwards if you are not using it).
Anyway: you can definitely remove the test folder if you are using rspec.
I believe so. Rspec should only be looking for tests in ../spec/*
Yes you can delete the test folder.
If you want test-unit though (due to other gem dependencies) here's how to install test-unit as a gem:
Add gem to Gemfile
gem 'test-unit'
Check gems
bundle check
Your Gemfile's dependencies could not be satisfied
Install missing gems with bundle install
Install
bundle install
Should be good to go.