why all of my Gem commands are suddenly not working? - ruby-on-rails

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)

Related

Rails + Big Sur + pg and Spring conflict?

Once I upgraded to Big Sur, I immediately got the following error in Ruby on Rails when launching the server:
$ rails s
/Users/carsoncole/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/x86_64-darwin19/stringio.bundle: warning: already initialized constant StringIO::VERSION
You've tried to invoke Spring when it's already loaded (i.e. the Spring constant is defined).
This is probably because you generated binstubs with Spring 1.0, and you now have a Spring version > 1.0 on your system. To solve this, upgrade your bundle to the latest Spring version and then run `bundle exec spring binstub --all` to regenerate your binstubs. This is a one-time step necessary to upgrade from 1.0 to 1.1.
Here's the backtrace:
/Users/carsoncole/.rvm/gems/ruby-2.7.1/gems/bootsnap 1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/Users/carsoncole/.rvm/gems/ruby-2.7.1/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/Users/carsoncole/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:318:in `block in load'
/Users/carsoncole/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
/Users/carsoncole/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:318:in `load'
/Users/carsoncole/.rvm/gems/ruby-2.7.1/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<main>'
/Users/carsoncole/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Users/carsoncole/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Users/carsoncole/scout_activity/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
I followed the directions given above but to no avail. Any thoughts?
If I create a new Rails app, the server starts up fine. Using Rails 6.0.3.4 and Ruby 2.7.3
One difference between the new app and my existing app is the new app did not use 'pg'. When I added 'pg' (pg-1.2.3) to the new app, the same error occurs.
[UPDATE] I think the issue may be related to Homebrew. I'm now reinstalling.
I found a solution, although I can’t pinpoint exactly why it worked.
I reinstalled Homebrew, and Posgresql (with HB). I also updated Xcode and the command line libraries. In the process of reinstalling homebrew and Xcode, I believe a number of libraries were updated/installed which I suspect was the issue.
Works fine now.

SystemStackError upon creating new rails app, can't update rubygems, gives argumenterror

I've been working on this all night. I created a new rails app and tried to install some gems and got "bundler 2 only works with rubygems 2.5". I tried to update --system but got back argument error. I then tried to create another app (I'm not sure if this happened the first time I was busy texting) and it gave "gemfile fileutils" a lot until it said
'''Traceback (most recent call last):
8888: from /home/vagrant/.rbenv/versions/2.5.3/bin/rails:26:in `<main>'
8887: from /home/vagrant/.rbenv/versions/2.5.3/bin/rails:26:in `load'
8886: from /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/railties-5.2.3/exe/rails:10:in `<top (required)>'
8885: from /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:73:in `require'
8884: from /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:73:in `require'
8883: from /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/railties-5.2.3/lib/rails/cli.rb:18:in `<top (required)>'
8882: from /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/railties-5.2.3/lib/rails/command.rb:46:in `invoke'
8881: from /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/railties-5.2.3/lib/rails/command/base.rb:65:in `perform'
... 8876 levels...
4: from /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/shell.rb:60:in `say_status'
3: from /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/shell/basic.rb:110:in `say_status'
2: from /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/shell/basic.rb:390:in `quiet?'
1: from /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/core_ext/hash_with_indifferent_access.rb:20:in `[]'
/home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/core_ext/hash_with_indifferent_access.rb:74:in `convert_key': stack level too deep (SystemStackError)'''
I've tried everything a beginner could from trying to install rubygems every way I could, reinstalled rails, made sure everything was up to date but no luck. I've been working at this for just under 2.5 hours googling and what not so I'm sure there are smaller things I forgot about that I've tried.

Rails returns error when I try to create a new project

Rails broke on my system and now whenever I run rails new my_app it gives me a weird Thor error.
joshuahadik -> rails new hello_world
Traceback (most recent call last):
21: from /Users/joshuahadik/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `<main>'
20: from /Users/joshuahadik/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `eval'
19: from /Users/joshuahadik/.rvm/gems/ruby-2.5.3/bin/rails:23:in `<main>'
18: from /Users/joshuahadik/.rvm/gems/ruby-2.5.3/bin/rails:23:in `load'
17: from /Users/joshuahadik/.rvm/gems/ruby-2.5.3/gems/railties-5.2.1/exe/rails:10:in `<top (required)>'
16: from /Users/joshuahadik/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
15: from /Users/joshuahadik/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
14: from /Users/joshuahadik/.rvm/gems/ruby-2.5.3/gems/railties-5.2.1/lib/rails/cli.rb:12:in `<top (required)>'
13: from /Users/joshuahadik/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
12: from /Users/joshuahadik/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
11: from /Users/joshuahadik/.rvm/gems/ruby-2.5.3/gems/railties-5.2.1/lib/rails/command.rb:9:in `<top (required)>'
10: from /Users/joshuahadik/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
9: from /Users/joshuahadik/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
8: from /Users/joshuahadik/.rvm/gems/ruby-2.5.3/gems/thor-0.20.1/lib/thor.rb:2:in `<top (required)>'
7: from /Users/joshuahadik/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
6: from /Users/joshuahadik/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
5: from /Users/joshuahadik/.rvm/gems/ruby-2.5.3/gems/thor-0.20.1/lib/thor/base.rb:4:in `<top (required)>'
4: from /Users/joshuahadik/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
3: from /Users/joshuahadik/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
2: from /Users/joshuahadik/.rvm/gems/ruby-2.5.3/gems/thor-0.20.1/lib/thor/error.rb:1:in `<top (required)>'
1: from /Users/joshuahadik/.rvm/gems/ruby-2.5.3/gems/thor-0.20.1/lib/thor/error.rb:6:in `<class:Thor>'
/Users/joshuahadik/.rvm/gems/ruby-2.5.3/gems/thor-0.20.1/lib/thor/error.rb:12:in `<module:DidYouMean>': uninitialized constant Thor::DidYouMean::SpellChecker (NameError)
I get the same error when I run pretty much any rails command, rails -v, rails s, etc.
So far I've tried a few things, including completely removing every version of ruby with rvm, then reinstalling them, then reinstalling the rails gem. Didn't work.
I really have no idea what's going on or why this is happening. Any help would be greatly appreciate.
UPDATE
Just realized that rails still works within the context of an existing rails project. So if I run rails s in the directory of a previously existing rails project it works just fine.
Thor is a gem that is used by Rails to show various command line messages.
It says you are using thor-0.20.1
I believe that version of Thor was released TODAY. The previous version, Thor-0.20.0 was released over a year ago. 0.20.0 is also the version I'm using.
It's likely that there is a bug in thor-0.20.1
You can try using bundler and your Gemfile to force your app to use thor-0.20.0
I ran into the exact same issue and rails wouldn't accept any command (rails s, rails new app) etc. Using ruby 2.5.3 and rails 5.2.1. It is due to the buggy thor-0.20.1
Therefore, reverted it back to thor-0.20.0 by:
- gem uninstall thor (but do not remove the executables when asked)
- gem install thor -v 0.20.1
It shall allow you to create a new project, however keep in mind that the Gemfile.lock file automatically changes the version to thor-0.20.1 (I don't know why). So be sure to change it back again to the 0.20.0.
A new version of thor has been released.
Just run:
gem update thor
The solution for me is delete the version gem Thor:
$ gem uninstall thor
Select gem to uninstall:
1. thor-0.20.0
2. thor-0.20.1
3. All versions
2
Successfully uninstalled thor-0.20.1

Rails not running after Ruby update (possibly RVM related)

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

Ruby and Rails Error (Psych::SyntaxError) and

After experiencing some issues with my ruby.framework I deleted it and used pacifist to reinstall and that seemed to solve my previous issue. Now I seem to always get this error when using ruby with any command.
/Users/brandoncontreras/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:370:in `parse': (<unknown>): mapping values are not allowed in this context at line 2 column 7 (Psych::SyntaxError)
from /Users/brandoncontreras/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:370:in `parse_stream'
from /Users/brandoncontreras/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:318:in `parse'
from /Users/brandoncontreras/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:245:in `load'
from /Users/brandoncontreras/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/config_file.rb:333:in `load_file'
from /Users/brandoncontreras/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/config_file.rb:198:in `initialize'
from /Users/brandoncontreras/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/gem_runner.rb:74:in `new'
from /Users/brandoncontreras/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/brandoncontreras/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/gem_runner.rb:39:in `run'
from /Users/brandoncontreras/.rvm/rubies/ruby-2.1.3/bin/gem:21:in `<main>'
It only occurred after I tried to set ruby 2.1 as the default ruby version
brandons-mbp:~ brandoncontreras$ ruby -v
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0]
brandons-mbp:~ brandoncontreras$
All other threads had solutions that didn't fix the problem.
I also have xcode installed with a fresh command line developer tools install.
Been trying to set up environment on mac for a 10 days....
EDIT:
tried looking to see what was in my config_file.rb and added puts filename...what am I looking for? and i do not have a credentials file in my .gem folder

Resources