I'm following this guide to get started with Ruby on Rails.
I ran ruby new <projectName>
When I do rails server I get
Traceback (most recent call last):
2: from bin/rails:2:in `<main>'
1: from bin/rails:2:in `load'
<projectName>/bin/spring:7:in `<top (required)>': undefined method `specs' for nil:NilClass (NoMethodError)
No searching on SO has revealed anything so far.
I think it could be related to the build process.
When I run bundle install, it goes through the process before seeming to stall out
Fetching sassc 2.4.0
Installing sassc 2.4.0 with native extensions
Killed
I only get this if bundle install didn't run to completion. If you skipped that step or interrupted it the Gemfile.lock isn't properly generated.
The line is:
Bundler.locked_gems.specs.find { ... }
Where Bundler.locked_gems returns nil in the case of a missing .lock file.
This should be better communicated with a proper error message.
Related
I am upgrading my rails app from 5.1.4 to 5.2.0. I am getting the following error. I would appreciate any help debugging this. I have not put the entire stack trace below, please let me know if you need it.
I have paper_trail version 12.1.0 installed. Its odd though, I had been using ruby version 2.5.1 with rails version 5.1.4 and it never gave me errors. This error started only after I upgraded to rails 5.2.0
redd#tanya:~/galaxy$ rails s
[DEPRECATED] Bootsnap's `autoload_paths_cache:` option is deprecated and will be removed. If you use Zeitwerk this option is useless, and if you are still using the classic autoloader upgrading is recommended.
[DEPRECATED] Bootsnap's `disable_trace:` option is deprecated and will be removed. If you use Ruby 2.5 or newer this option is useless, if not upgrading is recommended.
DEPRECATION WARNING: The factory_girl gem is deprecated. Please upgrade to factory_bot. See https://github.com/thoughtbot/factory_bot/blob/v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md for further instructions. (called from <main> at /home/redd/galaxy/config/application.rb:9)
=> Booting Puma
=> Rails 5.2.7 application starting in development
=> Run `rails server -h` for more startup options
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activerecord-5.2.7/lib/active_record/type.rb:27: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activerecord-5.2.7/lib/active_record/type/adapter_specific_registry.rb:9: warning: The called method `add_modifier' is defined here
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-5.2.7/lib/active_model/type/integer.rb:13: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-5.2.7/lib/active_model/type/value.rb:8: warning: The called method `initialize' is defined here
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activerecord-5.2.7/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb:12: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-5.2.7/lib/active_model/type/value.rb:8: warning: The called method `initialize' is defined here
Exiting
Traceback (most recent call last):
120: from bin/rails:3:in `<main>'
119: from bin/rails:3:in `load'
....
8: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-5.2.7/lib/active_support/dependencies.rb:661:in `new_constants_in'
7: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-5.2.7/lib/active_support/dependencies.rb:476:in `block in load_file'
6: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
5: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
4: from /home/redd/galaxy/app/models/users/user.rb:1:in `<main>'
3: from /home/redd/galaxy/app/models/users/user.rb:2:in `<class:User>'
2: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:131:in `method_missing_with_attr_encrypted'
1: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted.rb:306:in `method_missing'
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activerecord-5.2.7/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has_paper_trail' for #<Class:0x000055c56bb2be30> (NoMethodError)
Did you mean? has_attached_file
Get the full stack trace (not the shortened version you listed above)
Find the lines containing /home/redd/galaxy/config/initializers
Insert the following code at the top of these files:
# Loading `User` below would fail
# if `User.has_paper_trail` is not loaded already
require "paper_trail/frameworks/active_record"
When I attempt to run sudo update_rubygems or sudo gem update --system I get similar errors:
Installing RubyGems 3.2.3
Traceback (most recent call last):
4: from setup.rb:23:in `<main>'
3: from setup.rb:23:in `require'
2: from /var/lib/gems/2.5.0/gems/rubygems-update-3.2.3/lib/rubygems.rb:1348:in `<top (required)>'
1: from /var/lib/gems/2.5.0/gems/rubygems-update-3.2.3/lib/rubygems.rb:1348:in `require'
/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:43:in `<top (required)>': uninitialized constant Gem::BasicSpecification (NameError)
I've tried reinstalling RubyGems 3.2.3 from source using ruby setup.rb and I get essentially the same error.
Traceback (most recent call last):
4: from setup.rb:23:in `<main>'
3: from setup.rb:23:in `require'
2: from /home/izaguirrejoe/Downloads/rubygems-3.2.3/lib/rubygems.rb:1348:in `<top (required)>'
1: from /home/izaguirrejoe/Downloads/rubygems-3.2.3/lib/rubygems.rb:1348:in `require'
/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:43:in `<top (required)>': uninitialized constant Gem::BasicSpecification (NameError)
One clue: I'm a noob and I ran sudo apt-get autoremove and it removed a bunch of Ruby-looking stuff. Maybe that was it? I did that, updated Vim to the newest version and installed YouCompleteMe, and now my existing rails app is not working. New rails apps work just fine, but I'd like to be able to update RubyGems. I'm on the verge of just reinstalling Debian and starting over, this is frustrating.
Another clue: hours of research has revealed that I may have two versions of Ruby installed. When I run which -a ruby I get
/usr/bin/ruby
/bin/ruby
I started receiving the following every time i wanted to write any gem command:
Traceback (most recent call last):
8: from C:/Ruby25-x64/bin/gem:9:in `<main>'
7: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
6: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
5: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/gem_runner.rb:86:in `<top (required)>'
4: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems.rb:1140:in `load_plugins'
3: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems.rb:556:in `find_latest_files'
2: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1156:in `latest_specs'
1: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1173:in `_latest_specs'
C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1173:in `sort_by': comparison of Array with String failed (ArgumentError)
I solved the issue. I was actually learning ruby on rails and to cope with the course i started a new rails application with MySQL and started a rails server in the root of the project however it didn't worked because it wasn't able to locate the gem. One of the solutions i found online was to edit the MySQL .gemspec file however it made things worst and suddenly no gem command was running anymore. I solved the issue by uninstalling ruby and then installing it again and also installing the gems again (including rails)
I resorted to upgrading Ruby from 2.3.0 to 2.3.1 because of a really weird error I was getting and not being able to even come close to finding more info around google/SO.
Now after trying to figure this out I am getting this error whenever I try to run the project, or run bundle or rails in bash
/usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require': cannot load such file -- bundler (LoadError)
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.0/exe/bundle:10:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.1/bin/bundle:23:in `load'
from /usr/local/rvm/gems/ruby-2.3.1/bin/bundle:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
I have already tried reinstalling Ruby, RVM, bundler, but the error persists. I cannot find much info on that specific error around the web so I hope someone can help me troubleshoot this through here. Let me know if there are any specific logs I can provide and I will happily add more info.
EDIT:
I just noticed the path is ...ruby-2.3.1/lib/ruby/ 2.3.0 ... (the difference of 2.3.1 and 2.3.0)
When I upgraded to 2.3.1 I uninstalled previous versions. Could that be an issue since the error comes from a path that refers to a non-existing version of ruby?
Not sure why all this happened and what was wrong with the bundler, but what ended up fixing it for me was this command:
gem update --system
This question already has answers here:
rails error method_missing': undefined method `this' for Gem::Specification
(3 answers)
Closed 6 years ago.
I’m using Ruby 2.3 with Rails 4.2.7. I'm trying to install Capistrano on my system but am getting a baffling error when I try and check the version using “cap —version”. Does anyone know what the error means and what I have done wrong when installing my gem? Below is the output of installing the gem and then running the command …
root#ubuntumachine:/home/rails/networkproject# gem install capistrano
Successfully installed capistrano-3.6.1
Parsing documentation for capistrano-3.6.1
Done installing documentation for capistrano after 1 seconds
1 gem installed
root#ubuntumachine:/home/rails/networkproject# cap --version
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/specification.rb:2158:in `method_missing': undefined method `this' for #<Gem::Specification:0xa16c74 capistrano-3.6.1> (NoMethodError)
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/specification.rb:1057:in `find_active_stub_by_path'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:64:in `require'
from /usr/local/rvm/gems/ruby-2.3.0/gems/capistrano-3.6.1/bin/cap:2:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.0/bin/cap:23:in `load'
from /usr/local/rvm/gems/ruby-2.3.0/bin/cap:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
I ran into something like this a couple of months ago, but the problem was intermittent.
For an immediate/temporary fix, try running gem pristine --all.
For a permanent solution, make sure you're running the latest version of RubyGems by running gem update --system.