Search code examples
ruby-on-railsrubyruby-on-rails-4bundlernitrousio

Uninstalled old version of rails and now no longer have rails executable


Working in Nitrous.IO, my rails app was acting strange. So I checked and I was using rails version 0.9.5 instead of version 4.0.1! I decided to do a gem uninstall rails --version 0.9.5. Everything is good, except it also removed the rails executable! How do I get that back? Seems like version 4.0.1 is there, but I can't run the rails command. Should I just uninstall and reinstall rails?

UPDATE: Tried gem install rails even though I already had rails 4.0.1 installed:

action@creativebox-45198:~$ gem install rails                                                                                                                                      
Successfully installed rails-4.0.1                                                                                                                                                 
1 gem installed                                                                                                                                                                    
action@creativebox-45198:~$ rails -v                                                                                                                                               
-bash: rails: command not found

Solution

  • This issue has been resolved through Nitrous support channels. Somehow the file /home/action/.rvm/gems/ruby-2.0.0-p247/bin/rails was missing, and gem install rails did not add it. Manually adding this file with the following contents solved the issue.

    #!/usr/bin/env ruby_noexec_wrapper
    #
    # This file was generated by RubyGems.
    #
    # The application 'railties' is installed as part of a gem, and
    # this file is here to facilitate running it.
    #
    
    require 'rubygems'
    
    version = ">= 0"
    
    if ARGV.first
      str = ARGV.first
      str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
      if str =~ /\A_(.*)_\z/
        version = $1
        ARGV.shift
      end
    end
    
    gem 'railties', version
    load Gem.bin_path('railties', 'rails', version)