rails rbenv: rails: command not found
After installing a gem via the command line in a ruby version you have to execute rbenv rehash
as described in the docs here and here
For example:
$ rbenv install 2.2.0
$ gem install bundler
$ rbenv rehash
$ gem install rails
$ rbenv rehash
new version of rails installed, rails command not recognized
At a high level, rbenv intercepts Ruby commands using shim executables injected into your PATH, determines which Ruby version has been specified by your application, and passes your commands along to the correct Ruby installation.
When you run a command like ruby or rake, your operating system searches through a list of directories to find an executable file with that name. This list of directories lives in an environment variable called PATH, with each directory in the list separated by a colon:
/usr/local/bin:/usr/bin:/bin
Once rbenv has determined which version of Ruby your application has specified, it passes the command along to the corresponding Ruby installation.
Each Ruby version is installed into its own directory under ~/.rbenv/versions. For example, you might have these versions installed:
~/.rbenv/versions/1.8.7-p371/
So, for each ruby version you must install two gems:
gem install bundler
gem install rails
About how to fix rbenv
you can read in this question.
rbenv: bundler: command not found
I fixed it by running the command gem install bundler
in the root directory of the rails app.
rbenv: ruby: command not found
The complaint you get comes from rbenv. The fact that it's complaining shows that rbenv is set up and working.
Figure out what version of Ruby is needed to run the project. Either the project comes with a .ruby-version file in the root, or someone on the project will know and recommend that version to use.
If the version is not specified in a .ruby-version file, create the .ruby-version file in the project directory.
type
ruby -v
while in that directory. Is it OK? Then you have the version of Ruby installed that matches what your .ruby-version is asking for.If the last command was not OK, then type
rbenv install
.
Now that Ruby is installed, you need to run your program. I'm assuming it comes with a Rakefile.
install the bundler tool:
gem install bundler
.install the dependancies of the project:
bundle install
run your project using the exact versions of libraries it specifies:
bundle exec rails server
rbenv: command not found
rbenv and rvm are both tools to manage ruby versions. They behave slightly different. rbenv does need you to rehash its 'shims' for you to pick up the current binaries. rvm does it a bit different. As you are using rvm, just omit the rbenv part.
rvm will pickup the correct ruby version from .ruby-version
file and (if you want to have one) the gemset from .ruby-gemset
As you pasted the output of ruby -v
and the path, everything looks to be working for you. You are all set and ready to go! :-) Just omit rbenv stuff.
Related Topics
When to Use Struct Instead of Hash in Ruby
Installing Ruby 1.9.1 on Ubuntu
Ruby: Is There an Opposite of Include? for Ruby Arrays
When We Import CSV Data, How Eliminate "Invalid Byte Sequence in Utf-8"
Cannot Access Local Sinatra Server from Another Computer on Same Network
Ruby Convert Array into Function Arguments
If String Is Empty Then Return Some Default Value
Find or Create Record Through Factory_Girl Association
Should I Define a Main Method in My Ruby Scripts
How to Convert a JSON Formatted Key Value Pair to Ruby Hash with Symbol as Key
Ruby - Can't Modify Frozen String (Typeerror)
Can't Install Ffi -V '1.9.18' on MACos Catalina
How to Check the Gem Version in Ruby at Runtime
How Much Performance Do You Get Out a Heroku Dynos/Workers