I am on a Mac, using Lion. I am configuring my system for Ruby on Rails development but I ran into some issues. Instead of using brew or other shortcuts I want to configure Ruby on Rails from source. So, here is what I did.
Installed Ruby 2.0
Downloaded the source from the Ruby website
Compiled it by running the following code:
./configure --prefix=/Users/user/Applications/ruby2
make
make install
And made sure the $PATH file is updated to point to /Users/user/Applications/ruby2/bin
So, I am able to call ruby -v or if I do which ruby it does point to my custom compiled version of Ruby.
Installed Node.js
Downloaded the source from the main website
Compiled it by running the following code:
./configure --prefix=/Users/user/Applications/nodejs
make
make install
And made sure the $PATH file is updated to point to /Users/user/Applications/nodejs/bin
So, I am able to call node -v or if I do which node it does point to my custom compiled version of Ruby.
I also did the same steps for openssl and it is also accessible from the console or if I do which openssl it points to /Users/user/Application/openssl/bin
But still when I execute gem install rails I still get the following error:
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
Any idea why?
System Specs
Mac Lion 10.8.4
OpenSSL 1.0.1e 11 Feb 2013
ruby 2.0.0p291
Nodejs v0.10.15
I managed to solve the problem by doing the following. The main problem was the step I followed to compile openssl itself.
Since I am on a 64 bit machine, I had to configure openssl by running the following command first
./configure --prefix=/Users/user/Applications/openssl darwin64-x86_64-cc
./make
./make install
And recompile ruby as such
./configure --prefix=/Users/user/Applications/ruby2 --with-openssl-dir=/Users/user/Applications/openssl
./make
./make install
Note: Even though while compiling ruby it might say... the option --with-openssl-dir is not valid or does not exist, ignore that.
I had very bad time with this ERROR.
Finally i done with it. There is only Once solution either you are with RVM or without RVM.
Make sure you have installed OpenSSL first BEFORE installing ruby.
First you should find where Ruby is:
whereis ruby
will list all the places where it exists on your system, then you can remove all them explicitly. Or you can use something like this:
rm -rf /usr/local/lib/ruby
rm -rf /usr/lib/ruby
rm -f /usr/local/bin/ruby
rm -f /usr/bin/ruby
rm -f /usr/local/bin/irb
rm -f /usr/bin/irb
rm -f /usr/local/bin/gem
rm -f /usr/bin/gem
THEN
sudo apt-get install zlib1g zlib1g-dev build-essential openssl libssl-dev libmysqlclient18 libmysqlclient-dev libyaml-dev curl git-core python-software-properties libpq-dev nodejs
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
tar -xvzf ruby-2.0.0-p247.tar.gz
cd ruby-2.0.0-p247/
./configure --prefix=/usr/local
make
make install
I hope this help you.
Related
I am trying to install RVM on my Ubuntu machine.
I have used curl to get RVM, but some RVM commands (install, requirements) throw this apt-get error:
There has been error while updating 'apt-get', please give it some time and try again later.
For 404 errors check your sources configured in:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list
type rvm | head -1 returns
rvm is a function
-bash: type: write error: Broken pipe
which gem
/usr/bin/gem
I have checked the "Run command as a login shell" option
Steps followed from this tutorial:
sudo apt-get install curl
curl -L get.rvm.io | bash -s stable --auto
. ~/.bash_profile
rvm requirements - doesn't work properly
I have also looked at the official RVM documentation, but it seems to be very similar.
Any ideas?
UPDATE: I managed to do it. I disabled all the third party ppa URLs and it installed smoothly.
There are some important packages your system needs before install rvm. Run at the terminal:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev \
curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev \
sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake \
libtool bison subversion nodejs
Then install rvm with:
curl -L https://get.rvm.io | bash -s stable --ruby
Now you need to put a setting in your .bashrc to add rvm to PATH for scripting. Run:
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
Open a new terminal and test rvm.
run
sudo apt-get update
sudo apt-get install build-essential
and then try again.
Hye Guys!!
I got the solution. Actually error is because the information we need for installation is not available at sever define for software & update. I change it to from my local "Server from India" (In my case) to "Main Server".
It's working perfectly for me now :)
I was having the same problem with my install, and then I fully read the details that terminal left once the install was finished.
Try using source /usr/local/rvm/scripts/rvm
Once I did that, the function type rvm | head -1 returned rvm is a function
In my Case i fixed the error by:
rvmsudo rvm install 1.9.3
rvm --default 1.9.3
rvmsudo rvm remove 1.9.3
rvm install 1.9.3
Source
Try disabling repository which appear at 404 sudo apt-get update or viewing logs rvm. The fact is that when you install rvm is trying to update a list of your packages and if you have 404 to go to bed =)
\curl -L https://get.rvm.io | bash -s stable --ruby .
paste this in your terminal window.I used this.It worked for me.for RVM for ruby
\curl -L https://get.rvm.io | bash -s stable --rails .
Use these to install RVM with ruby on rails
For people that know nothing about Linux or are newbies to Linux (like me) those are steps how to solve this (explanation, that was given above, was not that clear for me :) ).
Go to Package Manager, tab Settings, Preferences
In the opened window you'll see Other Software tab or something like that with links to servers. In my case one of these (it's mentioned in the error log that was produced by rvm) was causing errors and was not available (404 errors). I just unchecked it.
run rmv dependencies only when you closed Package Manager, or you'll get error saying that something is locked at the moment.
And everything now is installed successfully! :)
The most common symptom of this problem occurs (as seth2810 hinted at) with non-zero exit codes from an apt-get update command, which rvm requirements expects. You should run this command yourself (with sudo) and check for any problems.
If you have 404s in the output, check that the package sources for the bad URLs are still correct/current. You can remove package sources more easily with sudo apt-get install software-properties-common, followed by sudo add-apt-repository --remove {URL_OF_PROBLEM_PACKAGE_SOURCE} for each failed url.
If you have something hinting at packages with 'unmet dependencies', try sudo apt-get -f install. This command attempts to fix incomplete installs by fetching missing packages and works most of the time. Otherwise... by this point you probably have a more specific error to google for anyway!
I am using osx 10.8.2 installed ruby 2.0 and....
got this when trying to run "sudo gem install rails"
$ sudo gem install rails
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
I had ruby 1.9.x and rails 3.2.x working alright before
You have to install OpenSSL first and recompile ruby again:
RVM:
rvm pkg install openssl
rvm reinstall ruby-2.0.0-p0 --with-gcc=gcc-4.7 --with-openssl-dir=$rvm_path/usr
If you're using RVM please follow:
$ brew install automake
$ rvm pkg install openssl
$ rvm requirements run
$ rvm reinstall all --force
$ gem install rails
It worked for me.
I had very bad time with this ERROR.
Finally i done with it. There is only Once solution either you are with RVM or without RVM.
Make sure you have installed OpenSSL first BEFORE installing ruby.
RVM
Uninstall rvm
rvm implode
or
rm -rf ~/.rvm
Don’t forget to remove the script calls in your .bashrc and/or .bash_profile (or whatever shell you’re using).
sudo apt-get install zlib1g zlib1g-dev build-essential openssl libssl-dev libmysqlclient18 libmysqlclient-dev libyaml-dev curl git-core python-software-properties libpq-dev nodejs
Then install RVM, post ruby.
OR
rvm pkg install openssl
rvm reinstall ruby-2.0.0-p0 --with-gcc=gcc-4.7 --with-openssl-dir=$rvm_path/usr
WITHOUT RVM
First you should find where Ruby is:
whereis ruby
will list all the places where it exists on your system, then you can remove all them explicitly. Or you can use something like this:
rm -rf /usr/local/lib/ruby
rm -rf /usr/lib/ruby
rm -f /usr/local/bin/ruby
rm -f /usr/bin/ruby
rm -f /usr/local/bin/irb
rm -f /usr/bin/irb
rm -f /usr/local/bin/gem
rm -f /usr/bin/gem
THEN
sudo apt-get install zlib1g zlib1g-dev build-essential openssl libssl-dev libmysqlclient18 libmysqlclient-dev libyaml-dev curl git-core python-software-properties libpq-dev nodejs
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
tar -xvzf ruby-2.0.0-p247.tar.gz
cd ruby-2.0.0-p247/
./configure --prefix=/usr/local
make
make install
I hope this help you.
I fix this error for ruby 2.1.2 as follow.
rvm pkg install openssl
rvm reinstall ruby-2.1.2 --with-openssl-dir=$rvm_path/usr
On OSX, with rbenv and homebrew, the following worked for me:
brew install openssl
CONFIGURE_OPTS=--with-openssl-dir=$(brew --prefix openssl) rbenv install whatever-ruby-version
This worked for me which is similar to some of the other answers already posted.
rvm pkg install openssl
rvm reinstall all --force
When installing ruby 2.0, it is possible that rubygems 2.0 installation did not complete ok, because of openssl.
Make sure you provide a valid path to the openssl config file; you could:
find . -type f -name "openssl.cnf"
path is usually $HOME/.rvm/usr or $HOME/.rvm/usr/ssl
Then
[sudo] rvm reinstall ruby-2.0.0-p0 --with-openssl-dir=[openssl.cnf path] --verify-downloads 1
Make sure rubygems installation complete successfully.
Might be a better way to fix that path without reinstalling, but this should do it.
Make sure to check out this page on the rvm site: https://rvm.io/packages/openssl/
Running
rvm requirements run
gave me:
Missing required packages: autoconf, automake, libtool, pkg-config, apple-gcc42, readline, libxml2, libxslt, libksba, openssl, sqlite
after brew install autoconf automake ...
I was able to rvm reinstall 2.0.0 without openssl errors
I had the same problem with the same OS version. I use rvm and followed the steps in this command:
$ rvm requirements
Following those instructions, I ran:
$ brew update
$ brew tap homebrew/dupes
$ brew install bash curl git
$ brew install autoconf automake apple-gcc42 libtool pkg-config openssl readline libyaml sqlite libxml2 libxslt libksba
I had the same problem earlier, tried all of the snippets about and none of them worked out. After looking around for a bit the following worked for me:
$ rvm remove 2.0.0 # get rid of unsuccessful installation
$ rvm get head --autolibs=3 # get the latest RVM and build required libs
$ rvm requirements # just in case, install all other required stuff
$ rvm install ruby-2.0.0
$ rvm --default use ruby-2.0.0
What does rvm get head --autolibs=3 do exactly? I'm guess it automatically downloads dependencies, but I was hoping for a clear answer.
I encountered the same openssl error on Fedora when trying to use gem install <package>. It seems you need to install additional packages with yum/dnf
sudo dnf install rubygems rubygem-bundler ruby-devel mariadb-devel
After running the above command, gem install <package> should now work.
just went through the same problem. Takes a bit time but, upgrading openssl with
brew upgrade openssl#1.1
worked for me. Version might be different in the future, type brew install openssl to see which version you can upgrade to. I hope it helps.
If you have libssl1.1, your problem may be that these older versions of ruby (2.4 is the cutoff) are only compatible with libssl1.0.
For debian/ubuntu, please ensure that apt-get install libssl1.0-dev succeeds.
If you are using ruby-install, it will take the same openssl argument as rvm:
ruby-install ruby-2.0.0-p247 -- --with-openssl-dir=/usr/local/opt/openssl
I didn't know that installing ruby is such a pain
After lot of trouble with curl certificate, I installed the rvm using the methods mentioned in the rvm site also with lot of help from stackoverflow questions.
Now I am trying to install rails using the gems command
gem install rails
but I always get this error
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
I did follow every thing mentioned here https://rvm.beginrescueend.com/packages/zlib/
and also as a mentioned in a stackoverflow post
I did install all the tools as required by the requirements
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel
But still I get this error. When I looked at the build log for ruby under
/usr/local/rvm/log/ruby-1.9.3-p125/configure.log
I see this error
[2012-04-07 01:13:44] ./configure --prefix=/usr/local/rvm/rubies/ruby-1.9.3-p125 --enable-shared --disable-install-doc --with-zlib --with-opt-dir=/usr/local/rvm/usr --with-libyaml
configure: WARNING: unrecognized options: --with-zlib, --with-libyaml
Is the rvm broken ? or is there a problem while building the ruby src.
Note: I am running fedora 14
RVM causes more problems than it solves (IMHO). Better tools are ruby-build and rb-env. Newer tools that look very good too are ruby-install and chruby.
Here are my notes from my recent Red Hat Enterprise Linux (RHEL) installation of Ruby, which I believe is pretty similar to Fedora. Perhaps these notes can be of some help to you. Ask me questions if you like.
Install zlib
yum install zlib zlib-devel
Install YAML
export k=yaml v=0.1.4
wget http://pyyaml.org/download/libyaml/$k-$v.tar.gz
tar zxvf $k-$v.tar.gz
cd $k-$v
./configure
make && make install
Install X11 if you want X or headless browsing for testing
yum install
xorg-x11-fonts-misc
xorg-x11-fonts-truetype
xorg-x11-server-Xorg
xorg-x11-server-Xvfb
Install libraries
yum install
gdbm gdbm-devel
ncurses ncurses-devel
openssl openssl-devel
readline readline-devel
tk tk-devel
libjpeg libjpeg-devel
libpng libpng-devel
libxml2 libxml2-devel
libxslt libxslt-devel
zlib zlib-devel
Install ruby-build
cd /opt
git clone git://github.com/sstephenson/ruby-build.git
cd ruby-build/
./install.sh
Install Ruby
export k=ruby v=1.9.3-p125
wget http://ftp.ruby-lang.org/pub/ruby/1.9/$k-$v.tar.gz
tar zxvf $k-$v.tar.gz
cd $k-$v
# Either onfigure with defaults...
./configure
# Or configure with custom locations...
./configure --prefix=/opt/$k/$v --enable-shared --with-opt-dir=/opt/yaml/current
make && make check && make install
Environment
Edit /etc/environment to add this:
RUBYOPT='-r rubygems -r psych'
If you put Ruby in a custom directory, also merge this with your existing path:
PATH=/opt/ruby/1.9.3-p125/bin (or wherever you put it)
Load environment:
source /etc/environment
Verify gem runs and you see the intial set of gems:
gem list
Gem update:
gem update --system
I installed ruby-1.9.3-p0 on my Ubuntu 11.10 wubi and then rubygems to get Rails set up.
This is my code:
sudo ruby setup.rb
I got this error:
"/usr/local/lib/ruby/1.9.1/yaml.rb:56:in'<top(required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby."
I installed libyaml and reinstalled Ruby but still it doesn't work.
The information changed and I have no idea what's wrong with it.
You must install the paquage libyaml-dev before installing ruby, if not you can still use extconf.rb for the missing library. So for this problem you can do (from the ruby install folder) :
cd ext/psych
ruby extconf.rb
make
make install
Extconf.rb is usefull for adding a library after have installed ruby.
Do the following:
you must have "curl" installed :sudo apt-get install curl
Go To this link RVM
Copy the command in the quick install box and Paste it in your command prompt
Type echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
Type ~/.bashrc
Type the following code:
sudo apt-get install build-essential libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
Type: rvm install 1.9.3-p0
Type: rvm use 1.9.3-p0
Type: gem install rails
Have fun :)
Ok, after a failed attempt at installing RoR on my Ubuntu 11.10 box, I combined the tips from this page and from this resource: http://www.thegeekwork.com/how-to-install-ruby-on-rails-in-ubuntu-11-10/
This is the breakdown, step-by-step of what I just did to make this work (sorry if I didn't format this so great, I was just trying to keep it neat):
1) Fresh install of Ubuntu 11.10
2) me#Box:~$ sudo apt-get install curl
3) me#Box:~$ sudo apt-get install git
4) me#Box:~$ sudo apt-get update
5) me#Box:~$ sudo apt-get dist-update
6) me#Box:~$ sudo shutdown -r now
7) me#Box:~$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
8) me#Box:~$ gedit ~/.bashrc
9) add the following line to the end (and save the file)
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
10) me#Box:~$ source ~/.bashrc
11) me#Box:~$ type rvm | head -1
After executing above command you should be getting this output -
rvm is a function
You’ve successfully installed the RVM. Next, you are supposed to install additional dependencies. To find out those programs type -
12) me#Box:~$ rvm requirements
After the above command, install the additional packages recommended by RVM -
13) me#Box:~$ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
14) me#Box:~$ rvm install 1.9.2
(#14 takes a little while)
15) me#Box:~$ rvm use 1.9.2
(This selects the version you want to use)
(If you aren’t sure about the ruby version currently being used, then type -
ruby -v)
16) me#Box:~$ gem install rails
(this will take a little while...)
17) Make a sample application as a test...
me#Box:~$ rails new test_app
me#Box:~$ cd test_app
me#Box:~/test_app$ rails server
AND THAT"S WHERE THIS THING DIDN"T WORK. ARRRRRRRRRrrrrrrrrrrrrrgh.
So,
18) in your application folder ("test_app"), open Gemfile and uncomment "therubyracer" line
19) me#Box:~/test_app$ bundle install
20) me#Box:~/test_app$ rails server
Done, and done.
I don't understand why it set 0.0.0.0:3000 as the host address (I thought it would be 127.0.0.1), but quite frankly, that's not bothering me right now -- I got it to work (so far). Time to get going with some Rails! :D
I hope this helps anyone else who is looking to make this work! :)
Note: I realize that #13 repeats some of the things I already installed, but I don't care, I'm just doing what the thing says. :/
Note2: Holy learning curve on just posting an answer! I wasn't sure what was considered "code" and apparently the prompt is considered code. Makes sense now :)
Note3: This is my first "Answer" on StackOverflow! :D
If you are compiling ruby you might need libyaml-dev
Debian (and Ubuntu, etc.) packages that contain the files needed to install some other program from source usually end in -dev, e.g. libyaml-dev, so try installing that. Or just use rvm, it will actually install this for you.
Compling yaml from its source will make it work. I am running the same config as yours. I followed this http://collectiveidea.com/blog/archives/2011/10/31/install-ruby-193-with-libyaml-on-centos/. It definitely works.
How can I uninstall Ruby 1.9.2dev (2010-07-02) [i486-linux]
on ubuntu?
Need to reinstall - please help
Run the following command from your terminal:
sudo apt-get purge ruby
Usually works well for me.
(caution: this can delete essential system files related to GRUB and other components)
This command should do the trick (provided that you installed it using a dpkg-based packet manager):
aptitude purge ruby
At first find out where ruby is?
then
rm -rf /usr/local/lib/ruby
rm -rf /usr/lib/ruby
rm -f /usr/local/bin/ruby
rm -f /usr/bin/ruby
rm -f /usr/local/bin/irb
rm -f /usr/bin/irb
rm -f /usr/local/bin/gem
rm -f /usr/bin/gem
I have tried many include sudo apt-get purge ruby , sudo apt-get remove ruby and sudo aptitude purge ruby, both with and without '*' at the end. But none of them worked, it may be I've installed more than one version of ruby.
Finally, when I tried sudo apt-get purge ruby1.9(with the version), then it works.
Run the following command on the terminal:
sudo apt-get autoremove ruby
Here is what sudo apt-get purge ruby* removed relating to GRUB for me:
grub-pc
grub-gfxpayload-lists
grub2-common
grub-pc-bin
grub-common
On Lubuntu, I just tried apt-get purge ruby* and as well as removing ruby, it looks like this command tried to remove various things to do with GRUB, which is a bit worrying for next time I want to reboot my computer. I can't yet say if any damage has really been done.
If you used rbenv to install it, you can use
rbenv versions
to see which versions you have installed.
Then, use the uninstall command:
rbenv uninstall [-f|--force] <version>
for example:
rbenv uninstall 2.4.0 # Uninstall Ruby 2.4.0
If you installed Rails, it will be removed, too.
Why you are removing old version of the ruby?
rvm install 2.4.2 // version of ruby u need to insatll
rvm use 2.4.2 --default // set ruby version you want use by default
Using rvm you can install multiple ruby version in the system
Please follow below steps install ruby using rvm
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.4.2
rvm use 2.4.2 --default
ruby -v
The installation step will change for different Ubuntu version
For more info,
https://gorails.com/setup/ubuntu/14.04
You can use sudo apt remove ruby
Uninstall the make install software when make uninstall invalid.
make install will create file '.installed.list'
Choose to clean up the files described in .installed.list (need to be careful if you have multiple versions)
Case: ruby2.4 switch to ruby2.3, thinking directly delete all ruby software, and then re-make install 2.3, see: Ruby # Installation Guide
make install -> .installed.list
see .installed.list file, delete all install files.
rm -rf /usr/local/include/ruby-*
rm -rf /usr/local/lib/ruby
rm /usr/local/bin/erb /usr/local/bin/gem /usr/local/bin/irb /usr/local/bin/rdoc /usr/local/bin/ri /usr/local/bin/ruby
rm /usr/local/share/man/man1/erb.1 /usr/local/share/man/man1/irb.1 /usr/local/share/man/man1/ri.1 /usr/local/share/man/man1/ruby.1
rm /usr/local/lib/libruby-static.a
rm -rf /usr/local/lib/pkgconfig/ruby-*
which ruby
pkg-config --list-all|grep ruby