Search code examples
ruby-on-railsrubyruby-on-rails-5bundlergemfile

Rails command not available after installing with gemfile


I installed rails via a Gemfile and bundle install:

Gemfile

source "https://rubygems.org"

gem "rails",  "5.0.6"

the gem appears to have successfully installed according to success message. However it is still not available from the command line even after a restart.

$ rails
The program 'rails' is currently not installed. You can install it by typing:
sudo apt install ruby-railties
You will have to enable the component called 'universe'

I am using rbenv (required) and have a number of utilities in /.rbenv/shims/ (gem, rake, bundle, etc.) but not rails... so I don't know where it got installed.

gem env returns:

GEM PATHS:
 - /home/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
 - /home/user/.gem/ruby/2.5.0

but I don't see those packages there. I'm guessing it needs to be on the path, but I don't know where it is. The solution needs to work while installing with a bash script.


Solution

  • So, I was running rbenv rehash and setting the environment variable. However, the new env variables were not available until after a restart. Using the full path to /.rbenv/shims/rake solved the problem.