chijoy
chijoy

Reputation: 81

can't find gem railties (>= 0.a) (Gem::GemNotFoundException)

I've seen a few other issues for this, tried their recommendations, none of them worked for me.

I've been using Rails for about a year, just started a new Rails project, and suddenly having issues. I uninstalled and tried reinstalling all of Ruby and Rails. Ruby is fine, but not Rails.

When I enter rails s, I get the can't find gem railties. My current Ruby version is ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin15], even though I've been trying to set ruby 2.3.0 through rbenv.

If I try rails -v to see what version I'm running, I get the same error. I'm using Mac OS X El Capitan version 10.11.6.

Upvotes: 5

Views: 21925

Answers (4)

Vlad Rose
Vlad Rose

Reputation: 189

rvm osx-ssl-certs
rvm cleanup all
rvm reset

It works for me! Maybe some commands useless, I just retell the history of my shell :)

Upvotes: 12

Akash Jain
Akash Jain

Reputation: 493

This solution worked for me while i have been using Ubuntu 16.04.

Make sure that rvm(Ruby version manager) is accessible to your terminal, by simply execute command

 $ rvm -v

Now run following commands=>

$ rvm gemset list

Output of above command will be


gemsets for ruby-2.5.3 (found in /home/rails/.rvm/gems/ruby-2.5.3)

=>(default)

carserv

global


Now set correct gemset instead of default. in my project it is carserv. For that use following command

$ rvm gemset use carserv

It's time to start your rails server.

$ rails server

I hope this process will help you. :)

Upvotes: 0

chijoy
chijoy

Reputation: 81

For some reason, I can get it to work using bundle exec rails s. It's not ideal, but, if that's what it takes I'll just keep using bundle exec rails s.

UPDATE: This no longer works, it was only temporary. I had rbenv installed, and no matter what version I tried to set as local or global, it didn't set. Turned out, that my path was messed up, and it was hitting usr/local/bin first rather than hitting .rbenv first. Someone was able to help me offline. :)

Upvotes: 1

widjajayd
widjajayd

Reputation: 6253

Below is some step by step to install rails with RBENV, probably you can follow along, what command that probably you missed

  1. rbenv versions

    • check your rbenv version
    • if you think you need to upgrade you can use command below
    • brew upgrade rbenv ruby-build
  2. rbenv install -l

    • check list of ruby that can be installed with rbenv
  3. rbenv install 2.3.1

    • this is sample to install ruby version 2.3.1
    • ruby will be copied to /Users/%your_user_name%/.rbenv/versions/2.3.1
    • this is just sample version, use the latest / stable from command number 2
  4. rbenv rehash

    • this command will apply new ruby version that you just install
    • after you install / reinstall ruby with rbenv don't forget to run this command
    • this is important one, that most of developers forget to apply
  5. rbenv global 2.3.1

    • set global ruby to version 2.3.1
  6. rbenv local 2.2.2

    • after you set global (with version 2.3.1) in case you want specific folder with version 2.2.2 you can set local folder with this command
  7. gem install bundler

    • within your active ruby this will install bundler software for specific version
    • again after you run this do not forget to run ##rbenv rehash##
  8. gem install rails##

    • this will install rails (latest)
    • although there are no Gemfile this will install rails
    • if you like to install specific version you can use Gemfile and run command number 7 (below)
  9. bundle install

    • this will install rails including all dependency
    • again if you not sure / some command not work please try ##rbenv rehash##

Upvotes: 4

Related Questions