I had a RoR app working fun under Fedora14, I upgraded to Fedora16 and now it's a broken mess.
This is due to a change in the rails used, with Fedora 14 running on 2.x and now Fedora 15/16 running 3.x
I have rvm installed, previously I didn't have the rails gem installed, so it would fall back to the system(?). So I've installed the gem for rails 2.3.8, it shows up when I do a gem list however the app is still a broken mess.
Anyone have any sort of clue here, what I should check, do, smash?
So I added this, to my config/enviroment.rb
config.gem "rails", :version => "~> 2.3.8"
and when I start I now get this error (this was all on one line).
Error message:
NOTE: Gem.source_index is deprecated, use Specification.
It will be removed on or after 2011-11-01. Gem.source_index called from /var/work_sites/mysite/vendor/rails/railties/lib/rails/gem_dependency.rb:106.
NOTE: Gem::SourceIndex#search is deprecated with no replacement.
It will be removed on or after 2011-11-01. Gem::SourceIndex#search called from /var/work_sites/mysite/vendor/rails/railties/lib/rails/gem_dependency.rb:106.
Missing these required gems: rails ~> 2.3.8 You're running: ruby 1.8.7.357 at /usr/bin/ruby rubygems 1.8.11 at /usr/lib/ruby/gems/1.8, /home/nick/.gem/ruby/1.8 Run `rake gems:install` to install the missing gems.
however
$ gem list
*** LOCAL GEMS ***
...
rails (2.3.8)
....
so I try anyway;
$ rake gems:install
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
Missing these required gems:
rails ~> 2.3.8
You're running:
ruby 1.8.7.352 at /home/nick/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
rubygems 1.8.10 at /home/nick/.rvm/gems/ruby-1.8.7-p352, /home/nick/.rvm/gems/ruby-1.8.7-p352#global
Run `rake gems:install` to install the missing gems.
ARGHH!
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/nick/.rvm/gems/ruby-1.8.7-p352
- RUBY EXECUTABLE: /home/nick/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
- EXECUTABLE DIRECTORY: /home/nick/.rvm/gems/ruby-1.8.7-p352/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/nick/.rvm/gems/ruby-1.8.7-p352
- /home/nick/.rvm/gems/ruby-1.8.7-p352#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
If the application is "reasonable sized" (mileage may vary), use this opportunity to upgrade to rails 3. Rails 4 will be out this spring and you will find no better time than now to do the upgrade. I would do v3.0.11 initially and go to 3.1.x if it goes well.
Face it, you don't want to do this again soon. At this point you will also find that whatever problems you encounter have usually be met and fixed by others and findable on the net, thru SO, etc.
These will help:
http://railscasts.com/episodes/225-upgrading-to-rails-3-part-1
http://ryanbigg.com/2010/11/the-rails-3-upgrade/
http://www.railsupgradehandbook.com/ ($12)
Ruby and Rails are changing very rapidly and keeping somewhat current is really important, not justa 'nice-to-have'. At this point gems's are more in line with rails 3
While you are at it you should install ruby 1.9.3 It's quite likely you will have few issues with that unless the code has complex ruby. Ruby 2.0 will be out soon after all.
As others advise rvm is the key to managing ruby versions. Once you have it installed you can switch ruby versions with command as simple as rvm use 1.9.2 and you can create a .rvrmc file in the root of project to set the ruby version for that project.
Once of the things you need to do other than install a gem is put itin your environment file(s) - rails 2 or in your Gemfile and Bundle - rails 3
Related
I have a similar problem to: Invalid spec cache file
but it does not have an answer.
Our rails app recently upgraded from ruby 2.1.2 to 2.1.5
When I downloaded this onto my laptop (desktop working fine) it required be to rvm install 2.1.5, then create a new gemset for 2.1.5
I tried to run bundle and bundler isn't installed so I tried gem install bundler and it responded with the following error message:
ERROR: While executing gem ... (Gem::Exception)
Invalid spec cache file in /my_dir/.gem/specs/api.rubygems.org%443/latest_specs.4.8
On checking that directory, I find that there is a specs.4.8 file but not a latest_specs.4.8 file
Things I tried:
I deleted and re-created the gemset, same problem.
I ran gem update
I blew away /my_dir/.gem/specs and reran gem update
I ran gem update --system
I reinstalled ruby 2.1.5 and did it all again...
When I changed the ruby-version back to 2.1.2 and used rvm use 2.1.2; bundle it didn't have a problem (but then bundler already exists in that gemset).
Gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [x86_64-darwin10.0]
- INSTALLATION DIRECTORY: /my_dir/.rvm/gems/ruby-2.1.5
- RUBY EXECUTABLE: /my_dir/.rvm/rubies/ruby-2.1.5/bin/ruby
- EXECUTABLE DIRECTORY: /my_dir/.rvm/gems/ruby-2.1.5/bin
- SPEC CACHE DIRECTORY: /my_dor/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /my_dir/.rvm/gems/ruby-2.1.5
- /my_dir/.rvm/gems/ruby-2.1.5#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
Try this:
gem sources --clear-all
gem sources --update
If that doesn't work, see my longer answer here: Corrupted ruby gem system
Eventually I gave up and reinstalled ruby 2.1.5 and deleted the gemset.
Then it turned out I could install without bothering to first create a gemset.
Just rvm use 2.1.5 then gem install bundler then bundle
So: no idea what went wrong (and would still encourage others to answer for an explanation), but this is what worked for me.
When I tries to install rails:
root#li44-48:/# gem install rails
Successfully installed rails-3.2.1
1 gem installed
Installing ri documentation for rails-3.2.1...
Installing RDoc documentation for rails-3.2.1...
But when I do:
root#li44-48:/# rails
-bash: rails: command not found
I checked gem env and it displays:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [i686-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.9.1
- /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Also the folder root#li44-48:/usr/lib/ruby/gems/1.9.1/gems/rails-3.2.1# is empty.
Any ideas on how to fix this?
I had the same issue after switching to an older version of Rails (3.2.16) from 4.0.2.
In my case it looks like railties need to be uninstalled as well - not just the rails gem.
Here's what I've done:
gem uninstall rails # choose to remove all
gem uninstall railties # choose to remove all
gem install rails -v 3.2.16
This happened to me after I uninstalled an old version of rails, and it asked me if I wanted to remove the binary too (which I did).
The newer rails binary is hidden under
/var/lib/gems/1.9.1/gems/railties-3.2.13/bin/rails
(on Ubuntu)
So I just created the symlink (not sure if this has negative side affects but it seems to work):
sudo ln -s /var/lib/gems/1.9.1/gems/railties-3.2.13/bin/rails /usr/local/bin
In an effort of rage quit, I:
removed ruby
removed gem
and recompiled both from source, and now gem install rails is fully working again.
I had the same issue and ended up using the RVM installer. This post http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/ shows you how and why use this tool.
check that rvm is a function type rvm | head -1
Try installing with:
sudo gem install rails
If you are running RVM you may not have it configured properly.
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!
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
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.