Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 465
chijoy Avatar asked Jun 24 '17 00:06

chijoy


3 Answers

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 :)

like image 154
Vlad Rose Avatar answered Nov 02 '22 23:11

Vlad Rose


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##
like image 30
widjajayd Avatar answered Nov 03 '22 01:11

widjajayd


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. :)

like image 20
chijoy Avatar answered Nov 03 '22 01:11

chijoy