0

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?

AlbertMunichMar
  • 1,680
  • 5
  • 25
  • 49
  • 2
    `gem install rails`? – Tom Lord Jul 18 '18 at 08:47
  • 2
    Rails is a gem. Gems are installed within a ruby version. If you've downloaded a brand new ruby version, you won't have any gems. Rails is not yet installed. – Tom Lord Jul 18 '18 at 08:48
  • *" why is rbenv local not working"* -- I don't know ... Can you give us a hint? Maybe an error message, or a description of the behaviour? – Tom Lord Jul 18 '18 at 09:00
  • gem install rails was the answer. 2 question, I run the command rbenv local in the folder, and nothing happens: ~/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] – AlbertMunichMar Jul 18 '18 at 09:09

1 Answers1

1

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.

Community
  • 1
  • 1
Leo
  • 1,673
  • 1
  • 13
  • 15
  • I read the other question. in my .zshrc i have: export RBENV_VERSION=2.3.5, that's why rbenv local does not work. is it wrong to have the ruby version in the ENV variables? i also have:export RBENV_VERSION=2.3.5 # use rbenv rehash export ALBERT=8 export PATH="$HOME/.rbenv/bin:$PATH:./node_modules/.bin" – AlbertMunichMar Jul 18 '18 at 09:47
  • 1
    `is it wrong to have the ruby version in the ENV variables?` No, env variable easy change. So, that is not a problem. – Leo Jul 18 '18 at 09:59