0

I'm working on a project in ruby 2.1.10. it should be using rails 4.0.13.

I'm using rbenv.

I've installed everything, I believe. I ran bundle install for the project. eventually I got it to run.

However, now I get:

turlingdrome$ rails
Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

turlingdrome$ gem install rails -v 4.0.13
Successfully installed rails-4.0.13
Parsing documentation for rails-4.0.13
Done installing documentation for rails after 1 seconds
1 gem installed

turlingdrome$ which rails
/Users/brianp/.rbenv/shims/rails

turlingdrome$ rails -v
Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

turlingdrome$ ruby -v
ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-darwin16.0]

in case it matters, I'm on a mac running 10.12.6

ETA from comment:

turlingdrome$ bundle exec rails -v
Rails 4.0.13

so, bundle exec lets me run rails. rbenv exec rails seems to work too.

So, the problem seems to be in the shim!

Brian Postow
  • 11,709
  • 17
  • 81
  • 125
  • Have you [configured rbenv to not use sudo](https://stackoverflow.com/questions/28890719/how-to-install-a-gem-globally-without-sudo-using-rbenv)? You could also try putting rails in the gemfile, running bundle, then `bundle exec rails` – max pleaner Sep 26 '17 at 21:54
  • I'm pretty sure it's not using sudo. and rails is already in the Gemfile. it installed the first time. rails just doesn't seem to KNOW it. – Brian Postow Sep 26 '17 at 21:59
  • AH! it appears that my problem may have been a remnant of a previous use of rvm? When try in a new shell, it seems to work. – Brian Postow Sep 26 '17 at 22:09
  • It said type "sudo gem install rails" and you typed "gem install rails" instead. – Mark Thomas Sep 26 '17 at 23:42
  • yep. because I had seen other things saying I didn't need sudo... – Brian Postow Sep 27 '17 at 14:43

1 Answers1

1

Rehash the shims:

rbenv rehash

Now you should be able to run only rails without bundle exec or rbenv exec.

Babar Al-Amin
  • 3,939
  • 1
  • 16
  • 20