no such file to load -- readline - ruby-on-rails

I am getting the following error:
$script/console
Loading development environment (Rails 2.2.2)
/opt/ruby-enterprise-1.8.6-20080709/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)
Where can i get the file and what directory should it go in?
Thanks!

The readline module is normally part of the Ruby package itself.
Did you manually build your Ruby install? If so, you want to make sure libreadline and its headers are installed, and build again.
On Debian/Ubuntu:
apt-get install libreadline-dev
Or on RHEL/CentOS, try
yum install readline-devel
Update:
You are using a very old release of Ubuntu. If you want to keep using it, open /etc/apt/sources.list in a text editor, and change all occurrences of archive.ubuntu.com to old-releases.ubuntu.com. Then, run apt-get update and try the above again.
I urge you to consider updating your installation, though. Ubuntu 7.10 hasn't seen security updates in quite a while, and using it in production is not recommended. Even if it's not a production machine, there's a good chance you'll run into further problems because of old versions of certain libraries/dependencies.

You need to install the ncurses and readline libraries.
On Ubunutu you could do
sudo apt-get install libreadline5-dev libncurses5-dev
and then you will have to recompile readline which comes with your ruby source
cd <ruby-src-dir>/ext/readline
ruby extconf.rb
make
sudo make install
If you are using RVM you could simply do
rvm package install readline
EDIT:
On newer RVM versions, this last command is
rvm pkg install readline

Add the following line to your Gemfile and run bundle update
gem 'rb-readline'
credits to similar question/answer at install ruby 1.9.3 using rvm on ubuntu

This easiest way to get relief from this problem,
just add to your Gemfile:
gem 'rb-readline'
And then run bundle install

Run the command
rvm requirements
It shows the requirements and dependencies. Install those and reinstall the ruby on rvm
rvm remove 1.9.2
rvm install 1.9.2
It works!
EDIT
If you can't find the requirements option update your rvm.
rvm update --head # older rvm
or use rvm upgrade

Maybe this is a bullshit answer, but I ran into this problem today after upgrading postgres from 9.5.3 to 9.6, along with which homebrew upgraded readline from 6.something to 7. I ended up rolling back my postgres to 9.5.3 and that resolved the issue.

Related

Trying to set up Ruby Rails on Mac

Am trying to set up rails on mac using rbenv and Homebrew.
Currently getting the following message when attempting to 'gem install rails':
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
username-mbp:projects username$ gem install rails
Any ideas??
If you are using rbenv, you should not use sudo to install gems. rbenv very helpfully installs your gems under your home directory in a way that allows you to use different gems for each installed Ruby version. When you change versions of Ruby you will really appreciate this.
To see the current version of Ruby, use rbenv local. For me this prints:
2.2.2
To see all the Ruby versions on your system of which rbenv is aware:
rbenv versions
rbenv stores the version specifier in a file called .ruby-version. This allows you to use different versions of Ruby for different projects, each version having its own set of gems.
When you try to install rails and get the Gem::FilePermissionError, it means that rbenv is not active, or you are deliberately installing into the "system" Ruby. There is nothing wrong with this per se, but you are not taking advantage of rbenv.
I recommend installing Rails again, using rbenv local to ensure that you are adding the gems to the correct path. You'll know this is working when
gem env gemdir
produces something like:
/Users/username/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
See https://github.com/sstephenson/rbenv#installation for more info.
This probably means that you used sudoat some point, which means that you run a command that allows you (as a permitted user to execute a command as the superuser or another user) See here: http://linux.about.com/od/commands/l/blcmdl8_sudo.htm.
Can you please paste the commands you used for installing rbenv, ruby, gem, brew, etc.? Also please paste the output of brew doctorto see if environment is correctly configured for Homebrew. Also, please paste the OSX version and rbenv versionsif rbenv is installed.
The steps for installing ruby on rails on OSX are:
Install Homebrew by:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`` (as seen here: http://brew.sh/). Run brew doctor and brew updateto see if everything is fine.
Install ruby: OS X comes with Ruby installed (Mavericks/Yosemite even gets version 2.0.0, previously it was only 1.8.7).
Install rbenv: it can be done either by GitHub Checkout or Brew. You probably should use brew. Run brew install rbenv ruby-build(this will also install ruby-build -https://github.com/sstephenson/ruby-build#readme-). You can also use this command brew install rbenv ruby-build rbenv-gem-rehash. Then echo 'eval "$(rbenv init -)"' >> ~/.bash_profile (to enable shims and autocompletion). You should problably run this too: echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile. Close terminal and open it again. Install the preferred version of ruby (if you want): rbenv install 2.0.0-p353.
Install Bundler: gem install bundler.
Install SQLite: gem install sqlite3
Install Rails: gem install rails.
So, the error you are having is due to permissions (you can understand about them here: http://www.tutorialspoint.com/unix/unix-file-permission.htm). Many people suggest fixing the issue with sudo or chown (http://www.cyberciti.biz/faq/how-to-use-chmod-and-chown-command/). I don't recommend that as it messes with system configuration. It will be better that you run:
rbenv install 2.1.2
rbenv global 2.1.2
gem update --system
When I run with this error like a year ago, what I did was uninstall everything and start again... but, probably that'll take too long.
These links might help you:
ruby for mac, ruby rbenv, rbenv githube, rubies and gems, question on stack
Use sudo:
sudo gem install rails
This guide helped me a lot: Setup Ruby On Rails on
Mac OS X 10.10 Yosemite

Trying to install ruby and ruby on rails 4 on Ubuntu?

So I'm following this guide at http://railsapps.github.io/installrubyonrails-ubuntu.html
and I install RVM without a hitch. However, when I check for the version of ruby that I installed via:
ruby -v
I got the following:
The program 'ruby' can be found in the following packages:
* ruby1.8
* ruby1.9.1
Try: sudo apt-get install <selected package>
I tried to install ruby manually through RVM:
rvm install ruby
However, it merely told me that ruby had already been installed.
Has anyone encountered this same issue?
TIA
you can try with these urls these may help you for installing rvm and ruby installation and rails installation
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
This may help you
After installing rvm, if you installed it as root, try
source /etc/profile.d/rvm.sh
If you installed as user, try
source ~/.rvm/scripts/rvm
I've definitely been there. I created a script to help me install ruby on remote machines. This was made for new EC2 instances, but maybe it will work.
https://github.com/jubrad/install_ruby
If you do want to use it you'll likely have to remove rvm and your rubies first.
-https://rvm.io/rubies/removing
-sudo apt-get remove rvm
best of luck.

I can't install rails on OSX 10.7.5

Whenever I run
sudo gem install rails
I get the following output:
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
RVM version: rvm 1.18.14
and Ruby is 2.0.0p0
you need to reinstall your rubies:
rvm get head --autolibs=3
rvm pkg remove
rvm reinstall all --force
the new autolibs supporrt will take care of updating dependencies and including them in ruby
Do you have Homebrew installed on your system? If so, try
brew install openssl
in the command line.
hmm, you have rvm but why you need sudo?I thought rvm is in sandbox mode . Anyway, the error just means it can't find ssl path. First, make sure you have openssl installed. If not then you need to install it(brew, macport etc) or rvm pkg install openssl and let rvm manage its path(you have rvm already). After that, you will need to reinstall ruby. RVM guide is here
You don't use sudo. sudo is ONLY used for doing a multi-user install, and only then during the initial installation, and adding your user to the rvm group (if the installer did not do it for you which usually indicates you did the install wrong in the first place)
I figured it out!
So First I removed everything to do with RVM as suggested in some of the answers. Rebooted. Installed the latest Version of Xcode and the command line tools from Xcode (Xcode-prefereces-downloads). Then rebooted again, and finally used RailsInstaller. Once I used that rails was back on and all is good in the world. Thanks for the help everyone.

cannot load such file -- openssl (LoadError)

In OS X in rvm how do I check if openssl is configured properly?
I get the cannot load such file -- openssl (LoadError)
And I have tried everything in Rails 3 - no such file to load -- openssl with no success.
Check what rubies are installed:
rvm list
Then make sure to use one of the installed rubies:
rvm use 1.9.3-p327
And test if openssl is available:
ruby -ropenssl -e "puts :OK"
It will print OK if openssl is enabled, otherwise you will get exception
In case of exception =>
UPDATE:
new version of rvm has improved automation support:
rvm get stable
rvm autolibs enable
rvm reinstall all --force
OLD:
run:
rvm requirements run force
rvm pkg remove
Followed by:
rvm reinstall all --force
This instruction is not OSX specific, it will work on all platforms, although on OSX it will work best with HomeBrew, when it's not installed only list of required software will be shown and you need to install it manually.
Many years later, the solution is changed because of brew upgrading, this works now:
# pull full brew git repo
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow
# generate new brew tap repo
brew tap-new $USER/old-openssl
# extract openssl 1.0.2t forumlar to $USER/old-openssl
brew extract --version=1.0.2t openssl $USER/old-openssl
# install old openssl from $USER/old-openssl repo
brew install openssl#1.0.2t
# reinstall ruby
rvm reinstall 2.3.4 --with-openssl-dir=`brew --prefix openssl#1.0.2t`
Try this.
rvm install ruby-2.0.0-preview1 --with-openssl-dir=$HOME/.rvm/usr --verify-downloads 1
This help me :
https://gist.github.com/Irio/1496746
$ rvm pkg install openssl
$ rvm remove 1.9.3
$ rvm install 1.9.3 --with-openssl-dir=$rvm_path/usr
I uninstalled everything (rvm, rails, ruby, etc) on my macbook.
Installed homebrew
Installed rvm
Ran rvm requirements run force
Ran rvm install rails
rails new sample_app
cd sample_app
Note: source 'https://rubygems.org' is present in Gemfile, openssl is required!
bundle install and it worked!
No need to specify: --with-openssl-dir=$HOME/.rvm/usr
To resolve this, install openssl (preferably using brew).
Update Xcode to the latest version and enable command line installations using it.
Reinstall rvm using
rvm reinstall all
Note that rvm reinstall all --force
will delete all your previous installations of binaries/pkgs done using rvm.
Assuming ruby is already installed, do the following:
rvm cleanup all
rvm reinstall all --force
I got the same error, and the error was fixed by opening new terminal session.
I am using frum ruby version manager.
gem install openssl
worked for me, but nothing has declared depending on the openssl, its weired
Following command solved my issue
note 2.3.4 is the ruby version I am using, change as per your requirements
rvm reinstall 2.3.4 --with-openssl-dir=$rvm_path/usr
Make sure that $rvm_path is properly set, with command echo $rvm_path. If this path is empty, check if your home folder has .rvm folder.
In this case use
rvm reinstall 2.3.4 --with-openssl-dir=~/.rvm/usr

ROR Installation "no such file to load"

I'm new to Ruby on Rails. I'm trying to install rails on an ubuntu linux platform. I've already installed RVM and ruby. When I type
gem install rails --version 3.0.0
I get this error:
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
Please help me install rails and learn a bit about the command line while I'm at it.
looks like you dont have ZLib installed. try gem install zlib and also apt-get install zlib zlib-dev if you dont have the system library installed
you need both the .so c-extension files (apt-get)
and the ruby interface to them (gem )
also this may be the same thing as in Antother Stackoverflow Question
I guess you need zlib package to install rails.
try
rvm pkg install zlib
after that
sudo apt-get install zlib1g
and then the development package. not sure why but you need it.
sudo apt-get install zlib1g-dev
then remove the current version of ruby because you didn't have zlib when ruby was compiled. type
rvm remove 1.9.2
(replace 1.9.2 with your version)
and then install it again with
rvm install 1.9.2
(again your version here)
That's basically it. I had the same error and it worked for me, hope it helps you too.
This has happened to me a few times. The answers near the bottom should fix it, but unfortunately you will need to remove and then recompile ruby :(
I have never gotten it to work without totally removing ruby.
http://ubuntuforums.org/showthread.php?t=1494997

Resources