I am having problems with conflicting versions of Ruby that I have installed. I had 1.8.6 and then installed 1.8.7 and it has caused problems. I get the following error when trying to run my ruby on rails app:
/usr/local/lib/ruby/1.8/i686-linux/rbconfig.rb:7: ruby lib version (1.8.6) doesn't match executable version (1.8.7) (RuntimeError)
I would like to remove 1.8.7 somehow and just use 1.8.6 but have no idea how to go about doing this.
Ran into this same issue and thought I'ld share my findings. There was a 1.8.7 ruby version installed by an rpm (centos 6.3), and I compiled 1.9.3 from sources and put it in a directory /opt/upnxt/ruby. I changed my environment to:
export PATH=/opt/upnxt/ruby/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
export LD_LIBRARY_PATH=/opt/upnxt/ruby/lib64
export RUBYPATH=/opt/upnxt/ruby/bin
export RUBY_HOME=/opt/upnxt/ruby
export RUBYLIB=/opt/upnxt/ruby/lib64/ruby/1.9.1:/opt/upnxt/ruby/lib64/ruby/1.9.1/x86_64-linux
export GEM_HOME=/opt/upnxt/ruby/lib64/ruby/1.9.1
export GEM_PATH=/opt/upnxt/ruby/lib64/ruby/1.9.1:/opt/upnxt/ruby/lib64/ruby/gems/1.9.1
and then when running:
$ ruby /opt/upnxt/ruby/bin/gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-linux]
- INSTALLATION DIRECTORY: /opt/upnxt/ruby/lib64/ruby/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /opt/upnxt/ruby/lib64/ruby/1.9.1/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /opt/upnxt/ruby/lib64/ruby/1.9.1
- /opt/upnxt/ruby/lib64/ruby/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
When running without the 'ruby' command in front, I would get:
$ /opt/upnxt/ruby/bin/gem environment
/opt/upnxt/ruby/lib64/ruby/1.9.1/x86_64-linux/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)
from /opt/upnxt/ruby/lib64/ruby/1.9.1/rubygems.rb:31:in `require'
from /opt/upnxt/ruby/lib64/ruby/1.9.1/rubygems.rb:31
from /opt/upnxt/ruby/bin/gem:8:in `require'
from /opt/upnxt/ruby/bin/gem:8
because of the default #!/usr/bin/ruby as stated earlier. I guess that's why one should use "#!/bin/env ruby" as a shebang instead (or "#!/usr/bin/env ruby")
If someone can tell me how to change the "RUBY EXECUTABLE" from the "gem environment" output so I won't need to specify it on the commandline, I would be grateful
cheers,
Gerrit
Yes, setting the path:
export PATH=yourrubypath/bin:$PATH
should do it.
I recommend you install rvm, that way you can run different ruby versions and manage gem sets in a very easy way
The installation instructions are here. However it basically reduces to:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Then you can install a newer ruby from source (it will compile it!):
$ rvm install 1.9.1 ; rvm 1.9.1
$ ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux]
$ which ruby
/home/you/.rvm/ruby-1.9.1-p243/bin/ruby
You can go back to the "system" one doing:
$ rvm system
Just change your $PATH to point to the version you want.
I install ruby from the tarball (and not from the distribuition package). This way I can have several different versions working at the same time, I have just to update the $PATH in the session that I want to use a different version.
Your easiest path and future proof too would be using rvm. Download the version of ruby you want with rvm and make it the default.
Installation: http://rvm.beginrescueend.com/rvm/install/
Making it default:
rvm 1.8.6 --default
The whole process would take not more than 15 minutes. Everything is clearly explained in this. Your environment will be set before you finish watching this podcast:
http://railscasts.com/episodes/200-rails-3-beta-and-rvm
Related
Please see below the print out from gem env. It appears as the INSTALLATION DIRECTORY, USER INSTALLATION DIRECTORY and GEM PATHS are screwed up. I attempted to install ruby version 2.3.0 for another project and switch over to that. I uninstalled ruby version 2.3.0 and switch back to ruby version 2.3.1. I noticed these RubyGems environment variables got screwed up some how :( Everywhere you see '2.3.0', I think it's wrong.
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /Users/matthewsmith/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/matthewsmith/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /Users/matthewsmith/.rbenv/versions/2.3.1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/matthewsmith/.rbenv/versions/2.3.1/bin
- SPEC CACHE DIRECTORY: /Users/matthewsmith/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/matthewsmith/.rbenv/versions/2.3.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /Users/matthewsmith/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
- /Users/matthewsmith/.gem/ruby/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/matthewsmith/.rbenv/versions/2.3.1/bin
- /Users/matthewsmith/.rbenv/libexec
- /Users/matthewsmith/.rbenv/plugins/ruby-build/bin
- /Users/matthewsmith/.nvm/versions/node/v4.5.0/bin
- /Users/matthewsmith/.rbenv/shims
- /Users/matthewsmith/.rbenv/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
if there are multiple versions installed, project dependent version must be set as default.
To handle multiple projects with different dependencies, gemset can be used. RVM support gemset. Alternatives are available for rbenv also.
Nothing is wrong. I can see that you are using rbenv, and that your global ruby version is 2.3.1
If you run in your terminal:
gem env home
It will return something like:
/Users/matthewsmith/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
Apparently this line of code above tells that you have global rbenv version 2.3.1, and within li/ruby/gems folder you also have installed ruby version 2.3.0
In this folder .rbenv/versions/ will be all ruby versions you will about to install, or they are already installed.
When I install different ruby version let's say 2.3.0 I would do like this:
rbenv install 2.3.0 # install ruby version 2.3.0 using rbenv
rbenv local 2.3.0 # set ruby 2.3.0 to local project. It writes that version to a .ruby-version in your current directory
ruby -v # check your version to confirm that is 2.3.0 for a local project
gem install bundler
bundle install
Other options for installing ruby version are: SHELL and GLOBAL
rbenv shell 2.3.0 # Will temporarily change your Ruby version on your current shell. This sets the RBENV_VERSION environment variable in your terminal session.
rbenv global 2.3.1 # This will also change your Ruby version, but only the one you are using whenever no other version is specified, e.g. via a .ruby-version file or RBENV_VERSION variable.
NOTE! You don't need sudo to install gems. Typically, the Ruby versions will be installed and writeable by your user. No extra privileges are required to install gems.
reference
I hope it helps
I have installed ruby on rails following the 310 railcasts on railcast.com. Now I was able to run and create a new rails and run it using rail s. The issue comes as soon has I close the terminal and restarted it i get the following error
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Here ruby version
ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux]
if i do rails -v i get following
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
whereis rails
rails:
gem environment gives me this
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-10-12 patchlevel 286) [i686-linux]
- INSTALLATION DIRECTORY: /home/john/.rvm/gems/ruby-1.9.3-p286
- RUBY EXECUTABLE: /home/john/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
- EXECUTABLE DIRECTORY: /home/john/.rvm/gems/ruby-1.9.3-p286/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/john/.rvm/gems/ruby-1.9.3-p286
- /home/john/.rvm/gems/ruby-1.9.3-p286#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I also believe the answer his the path and seem to the same has this questions Installed Rails but the rails command says it's not installed. But i do not know how to place the path. Any help would be appreciated
try to type rvm -v, if an error occurs, you have a problem with your rvm installation, if so try to source your shell configuration file ie if you are using bash on a mac : "source ~/.profile"
I am using Mac OSX, and in my .bashrc which is under my home directory.
There is a line :
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
By the way, you should tell the rvm to use 1.9.3 of ruby by the command rvm use 1.9.3
Your problem could be the thing that rvm switches between your ruby versions and when you restart the terminal it is not the old ruby version that you were using before exiting. So one solution can be. You create ".rvmrc" file in your rails application folder and inside you put just one line:
rvm use 1.x.x
where 1.x.x is the ruby version that you will use. Once you have gem rails in this version it will always work for you. This file simply tells which ruby shell be used when you work in your aplication direcotry
#user1022209 your solution will also work if the problem is with the ruby version but the point is that you always have to set ruby when your enter your folder and this can somethimes be anoying. I think that the best way to set default ruby version is using .rvmrc file.
3 lines of writing:
vim .rvmrc #creates new file, after which you have to press "i" for Insert mode
rvm use 1.x.x #contains only this line inside after which you press "ESC" and you type
:wq or :wq!
Finally press Enter and you are
done forever :)
Hope it will solve your problem
gem install rails
Do not sudo or apt-get when installing Rails with an installation of Ruby that was compiled from source. You may need to remove the Rails package first since you have already attempted to install it using the apt-get package manager.
apt-get remove --purge rails
apt-get clean
Having some real difficulty setting up my RoR envirionment in Ubuntu 10.10
Installed RVM with ruby 1.9.2
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
and i have ruby gems setup
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i686-linux]
- INSTALLATION DIRECTORY: /home/toast/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /home/toast/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /home/toast/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/toast/.rvm/gems/ruby-1.9.2-p180
- /home/toast/.rvm/gems/ruby-1.9.2-p180#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Now when it came to installing Rails i had all sorts of difficulties but now it seems to install:
$ sudo gem install rails
Successfully installed rails-3.0.7
1 gem installed
Installing ri documentation for rails-3.0.7...
Installing RDoc documentation for rails-3.0.7...
yet rails commands fail and rails -v results in
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
I'm out of ideas on this one!
many thanks
You've installed Rails under root user (sudo), and then you are trying to use it under local user. As far as it installed to root user you haven't got rails command in your local user PATH.
What you can do
Add its Path manualy
Install it via local user
Use RVM
I prefer to use RVM.
As far as you are using RVM, you don't need to use sudo. But when you need it you can use rvmsudo, but not in this case. Just
gem install rails
You don't have to use sudo with RVM.
If you type rvm info, you will see what ruby you use and where are your gems stored.
With sudo, you are probably using system's ruby from Ubuntu package.
Jus try gem install rails.
As others have said you need to install rails from gem via
gem install rails
The other somewhat tricky thing is that when you change into the rails app directory you need to make sure the dependencies are met for that app by doing:
bundle install
I've gone into a bit more detail on getting Rails 3 set up under Ubuntu at http://blog.dcxn.com/2011/06/21/rolling-with-rails-3-on-ubuntu-11-04/
Good luck!
Running Snow Leopard.
Tried uninstalling, and re-installing.
Still getting the same error whenever I run a rake task.
mbpro:redmine shereef$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel
174) [i686-darwin10.0.0]
mbpro:redmine shereef$ rails -v
Rails 2.3.4
mbpro:redmine shereef$ which rails
/usr/local/bin/rails
mbpro:redmine shereef$ gem -v
1.3.5
mbpro:redmine shereef$ which gem
/usr/local/bin/gem
mbpro:redmine shereef$ rake -v
(in /Users/shereef/Documents/Code/BetterMeans/redmine)
Missing the Rails
2.3.4 gem. Please gem install -v=2.3.4 rails, update your
RAILS_GEM_VERSION setting in config/environment.rb for the Rails
version you do have installed, or comment out RAILS_GEM_VERSION to
use the latest version installed.
mbpro:redmine shereef$ which rake
/usr/bin/rake
mbpro:redmine shereef$ $PATH
-bash:
/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:
No such file or directory
mbpro:redmine shereef$
On Fedora 12 you need to
$ gem install -v=1.0.1 rack
for the bundled rails to work.
Have you tried running rake:rails:update in your application?
I too had faced a similar issue. Please verify whether rails 2.3.4 is installed properly using the "gem list" command. If more than one copy of rails are present in gem list, remove the unwanted version using "gem uninstall rails" and select the required version.
Whenever I installed a newer version of rack this would happen. Making sure I had v 1.0.1 made it always work.
The solution that worked for me was to remove ruby 1.8.7, reinstall it and use gemsets.
This is the code if you're using rvm and ruby is correctly on it.
rvm remove 1.8.7
rvm package install readline # I'm not sure this is needed...
rvm install 1.8.7 --with-readline-dir=$rvm_path/usr # same here for option
rvm gemset create mine
rvm 1.8.7#mine
rvm use 1.8.7#mine --default # IF you do not want to change rv each terminal
gem install rails -v=2.3.5
I'm not sure but I think that rails was not seen because of the global gemset, but rails is pretty new to me to go deep in the explanation.
Edit:
In the case that there is no need to reinstall ruby, this should be enough, in both cases you'll have to reinstall all your gems.
rvm gemset create mine
rvm 1.8.7#mine
rvm use 1.8.7#mine --default # IF you do not want to change rv each terminal
gem install rails -v=2.3.5
let me know...
Since you have your own copy of ruby in /usr/local, I suspect that somehow rake is still trying to use the builtin os x ruby/gem command.
Try running 'gem env' to make sure your environment is set up correctly. In particular, look at the GEM PATHS: to make sure they are pointed at your /usr/local directory. If they are wrong try setting GEM_HOME and/or GEM_PATH in your environment.
Here is what my output looks like (though I use a ruby install dir in my own how directory via the ruby_switcher.sh tool (http://github.com/relevance/etc)
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0]
- INSTALLATION DIRECTORY: /Users/ashebanow/.gem/ruby/1.8
- RUBY EXECUTABLE: /Users/ashebanow/.ruby_versions/ruby-1.8.7-p174/bin/ruby
- EXECUTABLE DIRECTORY: /Users/ashebanow/.gem/ruby/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /Users/ashebanow/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com/"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com/
I had similar problems, and another gem to keep an eye on is activesupport. I found if I had other versions that differed from my Rails version, it could cause this as well.
I just set up a fresh Mac OS X 10.5 environment for Rails. I installed Ruby 1.8.7, renamed the packaged version of Ruby in /usr/bin, and updated the packaged version of RubyGems from 1.0.1 to 1.3.4. Here's the flow:
$ rails -v
Rails 2.3.4
$ gem -v
1.3.4
$ which gem
/usr/bin/gem
$ whereis gem
/usr/bin/gem
$ which rails
/usr/bin/rails
$ whereis rails
/usr/bin/rails
$ /usr/bin/gem -v
1.3.4
$ /usr/bin/rails -v
Rails 2.3.4
$ rails testapp
...
...
testapp $ script/console
Rails requires RubyGems >= 1.3.2. Please install RubyGems and try again: http://rubygems.rubyforge.org
The thing is I've updated RubyGems and didn't install another version of it. gem list rails displays two versions of Rails (2.3.4 and 1.2.6), though.
How can I fix this so I can use Rails?
One suggestion is to not change the system versions, instead install in /usr/local or use MacPorts.
The guys over at HiveLogic cover Rails, as well as MySQL and other development tools.
Using these techniques i've successfully installed rails into /usr/local Then it's a simple matter of adjusting the path settings in your terminal shell via (export PATH=/usr/local/bin:$PATH)
Have you tried:
sudo gem update --system
That should get you the latest version of rubygems, which is something like 1.3.5.
Rails will tell you the version of RubyGems you have if it's loading an incompatible version. The error message you're getting means it can't load RubyGems at all, so I'm thinking it's a path issue.
What do you get from $: in irb? Is there a rubygems.rb in any of those locations?
Make your life easier and use Macports instead of trying updatre and repalce the core system libraries. :-)
I second that emotion and, if I could, would up-vote the answer from prodigitalson -- MacPorts is your friend... Recommend you run specifically:
$ sudo port install rubygem
$ gem install rails
Key is making your which ruby and your rubygems which gem in synch. and in harmony...both should be in /opt/local/bin/
So Ruby on Rails 2.3.8 working on my MacOS 10.5.8 - and the gem environment no longer lies after the MacPorts install and reports the correct version, 1.8.7.
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.4
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
- INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /opt/local/bin/ruby
- EXECUTABLE DIRECTORY: /opt/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-9
- GEM PATHS:
- /opt/local/lib/ruby/gems/1.8
- /Users/saleram/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
Though the question is rather old, and comments stale, current searchers may find that these instructions:
Installing Rails on Mac OS X 10.6 (SL)
work fine for installing Ruby / Rails 3 on new OS X 10.6 installs, GIVEN that you install a recent version of RubyGems:
http://rubyforge.org/frs/?group_id=126
... particularly, do this in place of typing
sudo update_rubygems
in the first of my links
Had the same problem, here's what I did that solved it:
First, update gem
gem update --system
Navigate to the primary path in gem env, in my case /Library/Ruby/Gems/1.8
cd /Library/Ruby/Gems/1.8
Then, navigate to the gem itself:
cd gems/rubygems-update-1.3.5
Run setup.rb
sudo setup.rb
And that's it.
Have you considered BitNami Rubystack as an alternative? It is a free installer that provides a out-of-the-box Rails environment with MySQL (and a bunch of preconfigured, commonly used third-party libraries and apps). Please note I am one of the contributors to RubyStack, so I am biased. It is free and distributed under the Apache 2.0 open source license