can't get "rails console" to work on ubuntu 11.10 - ruby-on-rails-3

I want to use rails console and I'm using ubuntun 11.10 currently I have found the issue
error is something :
completion.rb:9:in `require': no such file to load -- readline (LoadError)
and I found a way to solve it:
http://blog.jasonmeridth.com/2010/11/25/readline-error-with-rvm-and-rails-3.html
but seems in ubuntu 11.10 the libreadline5-dev is missed and it is replaced with version 6
I installed version 6 and also I get the version 5 from
https://launchpad.net/ubuntu/oneiric/i386/libreadline-gplv2-dev/5.2-9ubuntu1
but yet if I try to run following code :
ruby extconf.rb
I'll get following lines :
checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... no
checking for readline() in -ledit... no
checking for editline/readline.h... no
the "no"s part is my problem , so how can I solve this problem?

Ubuntu 11.10 uses newer readline library which not in sync with the readline package offered by rvm
To solve this (assuming you use single-user installation of rvm) do:
1) ensure you have installed ubuntus readline and editline dev packages
sudo apt-get install libreadline6 libreadline6-dev
2) configure ruby's readline extension to use the systems libs, not rvm's packages
rvm pkg uninstall readline
cd ~/.rvm/src/ruby-1.9.2-p290/ext/readline
ruby extconf.rb --with-editline-dir=/usr/ --with-readline-dir=/usr/
make
make install
3) go to your project and start up the rails console
Tip: You can call
rvm requirements
to see what ubuntu packages should be installed to use rvm ruby

You have to install the readline development packages before compiling ruby. Just run
sudo apt-get install libreadline6-dev
Alternative (as suggested in the article you linked) you can use RVM to get the appropriate readline sources by running
rvm package install readline
Edit: Once you've installed the readline packages from source, you can install your rubies like this
rvm install 1.9.3 --with-readline-dir="$rvm_path/usr"
If you alredy have installd a specific ruby, just use reinstall instead on install.

Related

YAML safe loading is not available

When I want to install compass with gem install compass, I occurred with this error:
YAML safe loading is not available.
Please upgrade psych to a version that supports safe loading (>= 2.0).
what The cause of this error and how can I solve the problem?
It sounds like the psych gem needs to be updated. Try running gem install psych and then gem update psych.
Suggested by looking at the psych readme file here: https://github.com/ruby/psych/blob/master/README.md
EDIT: you might also have to update your version of ruby. This depends on how you have installed ruby, but #ewerx has one suggestion in their answer.
To resolve this I first upgraded Ruby from 2.0.x to 2.4.2 (https://gorails.com/setup/osx/10.12-sierra):
rbenv install 2.4.2;
rbenv global 2.4.2
Then updated gems:
sudo gem update --system;
gem update
It may be sufficient to just update gems.
The following part of the post on https://gorails.com/setup/osx/10.12-sierra solved my issue.
We will be setting up a Ruby on Rails development environment on macOS 10.12 Sierra.
Older versions of OS X are mostly compatible so follow along as far as you can and then Google search for any problems you run into. There are plenty of people who have documented solutions for them.
Installing Homebrew
First, we need to install Homebrew. Homebrew allows us to install and compile software packages easily from source.
Homebrew comes with a very simple install script. When it asks you to install XCode CommandLine Tools, say yes.
Open Terminal and run the following command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Ruby
Choose the version of Ruby you want to install:
Now that we have Homebrew installed, we can use it to install Ruby.
We're going to use rbenv to install and manage our Ruby versions.
To do this, run the following commands in your Terminal:
brew install rbenv ruby-build
Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
Install Ruby
rbenv install 2.5.1
rbenv global 2.5.1
ruby -v

install ruby on Rails in mac 10.6.8

Hi every one I try to install the last version on ruby on rails and I have several problem when run this command
\curl -L https://get.rvm.io | bash -s stable --ruby
The version of my mac is 10.6.8
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.6/i386/ruby-2.0.0-p0.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Installing requirements for osx, might require sudo password.
Skipping `brew update` make sure your formulas are up to date.
RVM autolibs is now configured with mode '2' => 'check and stop if missing',
please run `rvm autolibs enable` to let RVM do its job or run and read `rvm autolibs [help]`
or visit https://rvm.io/rvm/autolibs for more information.
Missing required packages: autoconf, automake, libtool, pkg-config, libyaml, readline, libxslt, libksba, openssl, sqlite.
RVM autolibs is now configured with mode '2' => 'check and stop if missing',
please run `rvm autolibs enable` to let RVM do its job or run and read `rvm autolibs [help]`
or visit https://rvm.io/rvm/autolibs for more information.
There were package installation errors, make sure to read the log.
Check Homebrew requirements https://github.com/mxcl/homebrew/wiki/Installation
On OSX 10.6 instead of command line tools install:
https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.6.pkg
download this application and install it, and run again the line to install ruby, but I obtain the same error.
Any idea!
This was a known issue with rvm (see: https://github.com/wayneeseguin/rvm/issues/1671).
The issue was resolved. Install rvm separately from ruby, then try
rvm install 2.0.0 --autolibs=4
to install 2.0.0.

How do I install same version of ruby as different names with rvm?

After I installed a version of ruby with rvm, I noticed that some minor configuration issue on installation process. So I wanted to try to install with another configuration options, but I don't want to spoil the installed ruby at all.
So I just to attempt to backup the installed ruby before rvm reinstall.
(cd .rvm/rubies && mv ruby-1.9.3-p194 ruby-1.9.3-p194.org)
In my case, reinstallation fixed the issue, I didn't rollback ruby. So, I don't know this can work.
Are there any clean or correct way? Just for future references.
you can install named rubies:
rvm install 1.9.3-test1 [options]
and after it worked set it as default:
rvm use 1.9.3-test1 --default
or reinstall the original 1.9.3, named rubies are useful especially for testing compilation flags or patched rubies:
rvm install 1.9.3-performance --patch falcon
You can also have different gemsets with the same version using
rvm create gemset projectname

Installing newer version but still older version active

I needed some features from a newer version so I installed 1.9.3 . However after the installation when I write "ruby --version" it still gives me back 1.8.7.
Any idea how to update it?
I used rvm install ruby-1.9.3-p0 to install it, and this worked on other machines, just not on this one
there is a shortcut for your needs:
rvm use 1.9.3-p0 --install --default
where:
--install will install this ruby if it is not yet installed
--default will set this ruby default so it will be loaded when you open new shell

install ruby 1.9.3 using rvm on ubuntu [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Ruby 1.9.2 and Rails 3 cannot open rails console
I have already installed rvm and ruby 1.9.2, both working properly. Using rvm version 1.10.2. I previously installed the rvm packages readline/zlib, but now I'm having big troubles with readline now. I'm trying to install ruby 1.9.3 in rvm, but I always end up having readline not found.
I tried to follow different solutions:
rvm remove 1.9.3
rvm pkg install readline
rvm install 1.9.3 --with-readline-dir=$rvm_path/usr/ \
--with-zlib-dir=$rvm_path/usr/
rvm use 1.9.3
rvmsudo gem install bundler
bundle install (all gems installed fine)
rails c / rails s
.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/completion.rb:9:in `require': \
cannot load such file -- readline (LoadError)
I have libreadline-dev (version 6, the current one) installed (everything needed by those packages pretty much)
I also tried the following:
.rvm/src/ruby-1.9.3-p0/ext/readline]$ ruby extconf.rb
checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... no
checking for readline() in -ledit... no
checking for editline/readline.h... no
.rvm/src/ruby-1.9.3-p0/ext/readline]$ ruby extconf.rb \
--with-readline-dir=/home/claudiocontin/.rvm/usr/
checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... no
checking for readline() in -ledit... no
checking for editline/readline.h... no
.rvm/src/ruby-1.9.3-p0/ext/readline]$ ruby extconf.rb \
--with-readline-lib=/home/claudiocontin/.rvm/usr/
checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... no
checking for readline() in -ledit... no
checking for editline/readline.h... no
Makefile is not generated of course ...
apt-get install libreadline-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libreadline-dev is already the newest version.
Ideas?
I tried to do rvm pkg readline, install ubuntu pkgs etc without any success. What worked for me:
gem install rb-readline
And add the following line to your Gemfile:
gem 'rb-readline'
What I ended up doing is remove all the libreadline from rvm usr/lib/ path.
Installed libreadline5-dev package (.deb in this case) downloaded manually, because the new ubuntu distro has only libreadline6-dev as candidate.
went to rvm ruby 1.9.3 src and:
ruby extconf.rb --with-editline-dir=/usr/ --with-readline-dir=/usr/
make
sudo make install
Now works like a charm.
Very painful stuff :)
edit:
also keep in mind that readline uses also libeditline-dev now, you can disable manually when configure ruby readline , passing: --disable-libedit
ruby extconf --disable-libedit
I've always found getting RVM to play nicely with packages to be a bit of voodoo. A lot of times, it's about catching a dependency - I put together a script that I've had luck with in past, try this:
sudo apt-get install zlib1g-dev libssl-dev libsqlite3-dev libmysqlclient-dev imagemagick librmagick-ruby libxml2-dev libxslt1-dev build-essential openssl libreadline6 libreadline6-dev zlib1g libyaml-dev libsqlite3-0 sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison libpq-dev libpq5 libmysql-ruby libmysqlclient-dev
rvm pkg install autoconf
rvm pkg install zlib
rvm pkg install readline
rvm pkg install openssl
rvm pkg install iconv
rvm install 1.9.3
rvm use 1.9.3 --default