Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rbenv: ruby: command not found

Tags:

I am using rbenv with ruby version 1.9.1-p378 on the local dir.

Command ruby -v gives the following error:

rbenv: ruby: command not found  The `ruby' command exists in these Ruby versions: 2.0.0-p353 

Any clue why this happens? The bundle, rails commands do not work either.

Command rbenv versions :

* 1.9.1-p378 (set by /home/user/Desktop/r1/noko1/.ruby-version) 2.0.0-p353 
like image 246
Lawrence DeSouza Avatar asked Jan 22 '14 06:01

Lawrence DeSouza


People also ask

Does Rbenv install Ruby?

You can install Ruby and Rails with the command line tool rbenv. Using rbenv provides you with a solid environment for developing your Ruby on Rails applications and allows you to switch between Ruby versions, keeping your entire team on the same version.

How do you check if I have Rbenv installed?

You can see if it is using rbenv by typing which ruby and it should print something out with . rbenv/ whatever. If not you need to set rbenv as your current ruby. You can do that like rbenv global 2.1.


2 Answers

  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

like image 167
Mark Bolusmjak Avatar answered Oct 02 '22 13:10

Mark Bolusmjak


Try the following piece of code depending on the current version of rails that you have installed. In my case am using v2.3.3

rbenv global 2.3.3 
like image 40
Thengugi Avatar answered Oct 02 '22 14:10

Thengugi