Ruby Gems suddenly stopped working on ubuntu 12.04 - ruby

After a couple of days of not doing pretty much anything on the ubuntu box, I decided to try out some ruby stuff. For this, I wanted to fire up pry. Unfortunately, I was presented with
Sorry, you can't use Pry without Readline or a compatible library.
Please gem install rb-readline or recompile Ruby --with-readline.
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
`require': libreadline.so.5: cannot open shared object file: No such
file or directory -
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-linux/readline.so
(LoadError)
Being quite new to linux in general, I figured I'd just do as it said, and install this rb-readline. The installation passes just fine, but doesnt seem to do anything at all. If I do gem list p, the package just doesn't appear.
So yeah, I just don't know what to do to get it working again, and the only thing I managed to find by searching was related to an installation without rbenv and had something to do with sudo etc.
Any ideas?

Without understanding the problem and following the advice in option 2 of the message:
Sorry, you can't use Pry without Readline or a compatible library.
Possible solutions:
* Rebuild Ruby with Readline support using `--with-readline`
* Use the rb-readline gem, which is a pure-Ruby port of Readline <==== Option 2
* Use the pry-coolline gem, a pure-ruby alternative to Readline
I added the gem into the Gemfile (as follows), bundled and pry was then available.
group :development, :test do
gem 'pry'
gem 'rb-readline'
end

I had this problem too. I am using rbenv and reinstalling ruby via
rbenv install -f 2.2.3
did fixed it for me. Of course you'd put in your respective version. -f forces the installation even though you already have that specific version installed. use rbenv global to find out what version you have installed and set.

I have some problem. But I don't want to add gem 'rb-readline'. So try it...
$ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib

Do a sudo apt-get install libreadline-dev, seems like you're missing the readline shared library that pry is wanting. If it worked before, not sure why the library isn't there anymore.

I ended up doing rbenv uninstall, followed by rbenv install and re-installing all the gems, and got it back to working. Still no idea what caused it in the first place, but it works now.

Related

`require': cannot load such file -- oauth

I was happily using Emacs's evernote-mode until stupidly removed OS X system ruby (I'm on Yosemite). Then I tried installing one via RVM (first tried 2.0 then 1.9), got all necessary gems, yet thing is still broken. Throws this message:
$HOME/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- oauth (LoadError)
from $HOME/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from $HOME/.rvm/rubies/ruby-1.9.3-p551/bin/enclient.rb:40:in `<main>'
Please help me to fix that
upd: I don't see the point of reinstalling system ruby (as people suggested) and then having it conflicting with those that I want to use via RVM. Ruby developers advise to use RVM. I symlinked my default Ruby to /usr/bin/ruby.
I seems that specific script uses something I don't have. I remember having hard time figuring out all dependencies and gems and installing them the first time I used that script and after hours of investigating it finally worked. But this time I got stuck.
I tried to run the script outside of Emacs and it runs with no errors (maybe that's not enough to find what's broken)
I tried to run irb and require modules one by one. It says => true until reaches require 'oauth/consumer'. I guess that's what's missing maybe? I run gem install oauth_consumer. It installed few gems, and now says => true for oauth/consumer in irb, the script though still doesn't work
i removed systems ruby once. i just had to go to the trash and put back everything i deleted and it worked for me. don't know how you "removed" your system ruby. besides, if you installed one with RVM then you have to tell RVM to choose and use/set a default ruby. because RVM won't install ruby 1.9.1 (rather a higher version which i think you did). So you have to set to that version.
Like this:
$ rvm --default use 2.1.5
don't forget to install oauth as well. Hope it helps.

How to install/use Ruby Shoes (without Hackety Hack)?

SOLUTION:
You have the same problem, you have to compile Shoes (https://github.com/shoes/shoes/wiki/Building-Shoes-on-Linux)
if rake doesn't work, try to install ruby 1.9.2 through rvm.
I recently started to learn Ruby, and i came across this library.
I tried to install it using the .run file provided by the official site, but it seems like it's broken. If i run it, it tells me:
./shoes-3.1.0.run: 1: eval: ./shoes: not found
And yes, after extracting the file, i found a folder which didnt contain it.
The only runnable thing i find is HacketyHack, which worked, but I prefer to use my own editor.
Since I have just started to learn Ruby, I'm not comfortable with playing with the .rb files to get it working outside of HH. I also tried to install it via apt-get, but after running 'shoes', all i get is:
no such file to load -- rubygems
Compiling from source code didn't work for me. Is there anything else I can try, or am I doing something terribly wrong?
The problem seems to be your ruby version. ruby in the apt repositories is version 1.8.7 which is quite old. Try apt-get install ruby1.9.1
If that doesn't work, I would recommend using rvm. Install, then simply rvm install ruby-2.0.0 which is the latest version, then rvm use 2.0.0. If shoes doesn't work under any of these versions, it's probably a bug in shoes.

fubar'd a ruby installation on ubuntu, need helping purging it for reinstall

i originally followed these steps to get a RoR environmentgoing: https://help.ubuntu.com/community/RubyOnRails
that worked. then i put 1.9.2 on here. then i decided i want the original setup, did a "whereis ruby" and deleted those directories manually.
that fubar'd my ruby installation. i can't use the repository to what i originally had. how can i purge ruby from completely and start fresh?
right now the specific error is this:
/usr/lib/ruby/1.8/rubygems.rb:11:in `require': no such file to load -- thread (LoadError)
from /usr/lib/ruby/1.8/rubygems.rb:11
from /usr/bin/gem1.8:8:in `require'
from /usr/bin/gem1.8:8
tipu#tipu_ubuntu:~$
You're not giving enough real information to be specific, but this is what I'd try:
Use apt-search to locate Ruby 1.8.7 for your OS version.
Using apt-get, uninstall that version so you're back to what APT thinks is a clean slate.
Again using apt-get, reinstall that version so you're back to what APT thinks is a normal installation.
From that point, I would STOP messing with the system Ruby, and instead use RVM to manage and install any new Ruby and gems installations into RVM's ~/.rvm sandbox.
To follow up on the Tin Man's answer:
I wrote a guide to installing Ruby and Rails on Ubuntu which you may find useful for getting this all peachy again.
Hope it helps!
You need to reinstall libruby1.8. I'm pretty sure that will take care of it. I had exactly the same problem.

Where is the default Gem.dir path set?

This is really odd: I installed ruby 1.9.1 using a "191" suffix so that it will coexist with other versions. e.g. the executables look like ruby191, gem191 and the library directory where all of the vendor/site code lives is /usr/local/lib/ruby191. The version of RubyGems (1.3.1) that is included with ruby 1.9.1 works fine. The installation was performed with:
cd /usr/local/src/ruby-1.9.1-p429
./configure --prefix=/usr/local --program-suffix=191
make
sudo make install
However, when I upgrade my RubyGems installation with sudo gem191 update --system it appears to forget about all of the installed gems. When I checked it out with gem191 environment it is now looking in /usr/local/lib/ruby.
I know I can create a ~/.gemrc and change the location there, but that smells like a hack to me. I have spent a couple of hours trying to figure out where Gem.dir is set in the code, but have been unable to find it. Does anyone know where the default location is set?
Apparently the Gem engine didn't work properly under ruby 1.9.1, but has been fixed under ruby 1.9.2. After installing the latest build, all of my Gem issues have disappeared.
You should definitely use rvm gem for multiple ruby installations on one system.
P.S. You can view your gem installation path by using $ gem{suffix} env.

Why is Phusion Passenger refusing to recognize my updated RubyGems?

I've updated RubyGems everywhere I can possibly think to update it:
The various places I've updated RubyGems http://files.droplr.com/files/14167865/zel8k.Screen%20shot%202010-03-09%20at%2017:24:59.png
but Phusion passenger keeps throwing the same error:
Error Screenshot http://files.droplr.com/files/14167865/zee8W.Screen%20shot%202010-03-09%20at%2017:19:50.png
There is that one freaking place that shows 1.3.1 as the version, despite the file name of 1.3.6. I've obviously borked things up pretty badly here.
That is, I need to update to 1.3.2 or greater and that I currently have 1.3.1.
Any idea how in the world I can get PP to use the correct version of RubyGems and preferably change things so I don't have to face this problem again?
Could this have anything to do with different paths for RubyGems and Ruby environments? These are my environments:
Environment screenshots http://files.droplr.com/files/14167865/zfH6x.Screen%20shot%202010-03-09%20at%2019:07:18.png
First, obtain the value of your PassengerRuby configuration. Then use that Ruby interpreter to run the following script:
http://pastie.org/862871
Like this:
/path-to-your-passenger-ruby-interpreter myscript.rb
and follow the instructions.
That might be of several reasons.
First, verify that you don't have it to explicitly require the rubygem in environment.rb. That is, if you have a line like this:
config.gem "ruby_gems", :version => "1.3.1"
Then you'll have to remove the version from it.
Also, seeing that the rubygems-update gives the incorrect version, you might want to uninstall it.
sudo gem uninstall rubygems-update
Since you have updated it, that gem is not necessary anymore.
I don't think it will help, but I would probably uninstall the macports version of rubygem as well since that might create collisions, even though it doesn't seem like it in this case.
Update:
Since you are using the Ruby from the operating system you don't have to install rubygem through macports at all.
To remove it:
sudo port uninstall rubygems
After that, make sure that you have upgraded the correct rubygem (the binary shows correct, but perhaps there is something missing)
sudo gem update --system
After you've done that. Open up irb (that is, irb and not the rails console) and check the following:
require 'rubygems'
puts Gem::RubyGemsVersion
Also, if you could paste how your apache/nginx configuration looks like, I doubt there is anything wrong in there, but you never know.

Resources