Rails Rbenv: Rails: Command Not Found

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

  1. The complaint you get comes from rbenv. The fact that it's complaining shows that rbenv is set up and working.

  2. 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.

  3. If the version is not specified in a .ruby-version file, create the .ruby-version file in the project directory.

  4. 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.

  5. 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.

  1. install the bundler tool: gem install bundler.

  2. install the dependancies of the project: bundle install

  3. 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



Leave a reply



Submit