AlbertMunichMar
AlbertMunichMar

Reputation: 1856

new version of rails installed, rails command not recognized

I want to do a new rails app. I installed ruby 2.4.4 because I cloned a project.

I used to set the new version for the project

rbenv shell 2.4.4

because rbenv local was not working

Now that I am using ruby 2.4.4

  system
  2.3.4
  2.3.5
* 2.4.4 (set by RBENV_VERSION environment variable)

I get following error message:

rbenv: rails: command not found

The `rails' command exists in these Ruby versions:
  2.3.4
  2.3.5

1) how can I fix this? 2) why is rbenv local not working?

What happens when running rbenv local 2.4.4

 ~/Local_Documents/CodingArea/personal_projects/zaina-project/zaina_deal_room/zaina-dealroom   setup  ruby -v
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin16]
 ~/Local_Documents/CodingArea/personal_projects/zaina-project/zaina_deal_room/zaina-dealroom   setup  rbenv local 2.4.4
 ~/Local_Documents/CodingArea/personal_projects/zaina-project/zaina_deal_room/zaina-dealroom   setup  ruby -v
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin16]

basically it happens nothing. Ruby version 2.3.5 is still selected. I expect to see version 2.4.4 as selected, after running rbenv local 2.4.4. I guess it's something with my ENV, that the version that I have written in a file, takes preferences, but I don't know how to fix this.

in my .zshrc I have:

export RBENV_VERSION=2.3.5 # use rbenv rehash
export ALBERT=8
export PATH="$HOME/.rbenv/bin:$PATH:./node_modules/.bin"

Is it wrong to have the ruby version there? is my PATH correct? So, rbenv local 2.4.4 will never be applied because of export RBENV_VERSION right?

Upvotes: 0

Views: 4198

Answers (1)

Leo
Leo

Reputation: 1773

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.

Upvotes: 1

Related Questions