ruby pry whereami command not working - ruby

I'm working with pry 0.10.1 java and pry-nav 0.2.4 on jruby 1.7.12 (1.9.3p392). In the middle of an rspec step after invoking binding.pry, I type the pry command:
whereami
All I get is
ArgumentError: Symbol or String expected, but NilClass given.
from /Users/yc98js1/.rbenv/versions/jruby-1.7.18/lib/ruby/gems/shared/gems/coderay-1.1.0/lib/coderay/helpers/plugin.rb:215:in `validate_id'
whereamI going wrong? [pun intended]

Seems like the error was thrown by the coderay gem. Could be a collision of this gem with another.
It might be unrelated but its hiding the error. try uninstalling coderay first and running the code again.

Related

How to properly emulate `eval_gemfile` for `gem install -g`?

When using eval_gemfile in Gemfile Bundler works. But gem install -g fails with
ERROR: While executing gem ... (NoMethodError)
undefined method `eval_gemfile' for #<Gem::RequestSet::GemDependencyAPI:0x000000000268a388>
Using eval File.read(...) works but I'm worried about any implications that I need to watch for.
It seems like the only reason to use eval_gemfile is readability and nicer syntax error reporting:
https://github.com/rubygems/bundler/commit/c6100f6bd246a8259f159285967f075b592e80c9
wrt the #untaint call, it appears to be some remains of 1.8.7 test suite requirements. I tested it working without #untaint on 2.5.5 so I wouldn't bother to add this call:
https://github.com/rubygems/bundler/pull/4770#discussion-diff-71091844

What's byebug's version of pry's whereami?

In Ruby, we have a gem called byebug and a gem called pry.
In pry, you can type whereami to see where you are, when you are in a binding.pry session.
How do you do the same thing in byebug?
Something similar to whereami in byebug is list https://fleeblewidget.co.uk/2014/05/byebug-cheatsheet/
you can also type help when in a byebug session to get the list of commands

How to fix "uninitialized constant Gem::GEM_PRELUDE_SUCKAGE" in RubyGems tasks

My RubyGems isn't working, throwing an error which goes as follows, triggering (nearly) on any Gem task:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems.rb:1081:in `<top (required)>': uninitialized constant Gem::GEM_PRELUDE_SUCKAGE (NameError)
from <internal:gem_prelude>:1:in `require'
from <internal:gem_prelude>:1:in `<compiled>'
I'm new to Ruby / RubyGems / installing Ruby and all I know is that an uninitialized constant is essentially a undefined variable. It could also be possible that it's something with Ruby itself, although the ->Gem:GEM<-_PRELUDE_SUCKAGE points me to RubyGems.
In a nutshell, I installed a bunch of Ruby things (think RVM, rbenv, etc.) to develop Ruby on Rails, as I thought it would be a good way to learn Ruby.
Well, after going through a long and tedious process to upgrade Ruby to 2.6.3, then downgrade to 2.5.5 and then 2.4.0, then back up to 2.5.5 and solving downgrade issues, RubyGems throws the error. I settled on 2.5.5 because 2.6.3 caused errors and 2.4.0 was too early of a version.
It's causing all sorts of errors, like HAML not compiling and Rails not making a controller. I really don't know what's happening.
If I run gem install [gem name], it throws the error. Running rails generate controller [name] index (for those not familiar to Rails this creates, well, a controller) it throws the error. Doing anything really with the gem command causes the error, except for gem server.
If I upgrade back up to the latest Ruby version, I fear that my gem command will go all wonky again and I'll have to go through another day of troubleshooting versions. How do I fix this, or at least get rid of the message so I can create things again?
I had this happen to me just today. It seems, somehow, my ruby version had been corrupted. When I ran rvm list version 2.5.1 was listed as 'broken'. I had to uninstall 2.5.1 fully (using sudo even in my case) to get to a clean slate.
Then, when attempting to reinstall, rvm was giving me all kinds of grief after a new gpg key which I initialy couldn't get to install properly (hint).
After a clean wipe of ruby 2.5.1, updating rvm to latest version and reinstalling, I got this error: Error running 'env GEM_HOME=/ruby-2.5.1#global GEM_PATH= /Users/user/.rvm/rubies/ruby-2.5.1/bin/ruby -d /Users/user/.rvm/src/rubygems-3.0.8/setup.rb --no-document',.
It appears that an update to MacOSX deprecated a version of OpenSSL which causes some issues. I ended up following this thread and ran rvm gemset create global --default and then bundle install to get passed the Gem errors.
Honestly, rails is supposed to be easier than this. I wish docker was easier to reason about sometimes. These are the kinds of issues docker supposedly promises to fix eh?

Ruby 1.9.2-p290 through rbenv produces warning from psych-1.2.1: VERSION and LIBYAML_VERSION

When I running ruby I get the following warnings:
~/.gem/gems/psych-1.2.1/lib/psych.rb:93: warning: already initialized constant VERSION
~/.gem/gems/psych-1.2.1/lib/psych.rb:96: warning: already initialized constant LIBYAML_VERSION
I've tried googling around but can seem to find a solution which makes me think it's specific to my system. Is there a way to fix this?
This problem seems to originate in psych being called by bundler in Bundler.setup. The work-around I used:
gem 'psych'
In my code before
Bundler.setup
There are two ways.
->First
add gem 'psych'
in your Gemfile file and then run
bundle install
-> Second
gem uninstall psych
at console

gem-install of mongoid throws an uninitialized constant in Ruby, works in irb

I am writing a script with Ruby/MongoDB that stores Tweets. After I gem-installed mongoid, this first-steps code throws an error:
require 'rubygems'
require 'mongo'
require 'mongoid'
Mongoid.database = Mongo::Connection.new('localhost').db('db')
# snippet from http://rujmah.posterous.com/using-mongoid-without-rails
NB. This is no Rails app, but a Terminal script.
The error I get is:
./mongoid.rb:10: uninitialized constant Mongoid (NameError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
from mongoid.rb:3
It works in irb and I'm running ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0].
What am I doing wrong?
Edit August 2012
Somehow I got it to work. Alas, nearly a year on, I really can’t remember how. I will try to do better next time.
I hit the same issue while trying to get Bullet gem to work. The solution for me was to simply move gem 'mongoid', github: 'mongoid/mongoid' as the first line of the Gemfile. I find it really odd but that was how I got rid of that error.
I am using Ruby 2.1.0 and Rails 4.0.0

Resources