Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 689 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
rbenv not changing ruby version

#11
for fish shell user

set --universal fish_user_paths $fish_user_paths ~/.rbenv/shims/
Reply

#12
In my case changing the `~/.zshenv` did not work. I had to make the changes inside `~/.zshrc`.

I just added:

# Include rbenv for ZSH
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

at the top of `~/.zshrc`, restarted the shell and logged out.

Check if it worked:

➜ ~ rbenv install 2.4.0
➜ ~ rbenv global 2.4.0
➜ ~ rbenv global
2.4.0
➜ ~ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]

Reply

#13
Make sure the last line of your `.bash_profile` is:

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Reply

#14
run:

rbenv init

After I ran that, when i set my local rbenv version:

rbenv local 2.4.0

then my `ruby -v` and my `rbenv local` versions coincided.

Note: You might also want to exit the directory you're in and then go back into it, i've noticed that was necessary for me in order to get things to work.
Reply

#15
If you are using **bash**, go to

~/.bash_profile

and add the following line (if it's not already there)

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

If you are using Zsh, go to

~/.zshrc

and add the same line of code, at the end of the .zshrc file.

Then simply restart your terminal and it should be fine now.
Reply

#16
The accepted answer suggests to add the following:

export PATH="$HOME/.rbenv/bin:$PATH"

This will not work on Mac OSX, which the OP references. In fact, if you install rbenv via `brew install rbenv`, which is really the only installation method in Mac OSX, since `curl -fsSL

[To see links please register here]

| bash` will FAIL in OSX, then the rbenv executable will be installed in:

$ which rbenv
/usr/local/bin/rbenv

However, even in OSX, the rbenv root will remain in the $HOME directory:

~ viggy$ rbenv root
/Users/viggy/.rbenv

What does this mean? It means when you install rubies, they will install in the given home directory under .rbenv:

$ rbenv install 2.6.0
$ ls ~/.rbenv/versions
2.6.0

Now the brew installation did some work that you would have to perform manually in Linux. For example, in Linux, you would have to install ruby-build manually as a plugin:

$ mkdir -p "$(rvbenv root)/plugins"
$ git clone

[To see links please register here]

"(rbenv root)"/plugins/ruby-build

This is already done with the homebrew installation. There is one important step that must be done in the homebrew installation, as in the Linux installation. You must add the rbenv shims to your path. In order to do that, when your shell starts, you have to evaluate the following command (which will in turn add the rbenv shims to the beginning of your $PATH):

$ vim ~/.bash_profile
eval "$(rbenv init -)"
$ source ~/.bash_profile

Now when you run `echo $PATH`, you will see the rbenv shims:

$ echo $PATH
/Users/viggy/.rbenv/shims:

Now check your ruby version and it will reflect the rbenv ruby installed:

ruby -v
ruby 2.6.0p0
Reply

#17
Check that PATH contains `$HOME/.rbenv/shims` and `$HOME/.rbenv/bin`

$ env | grep PATH

Also check that you have the following in your ~/.bash_profile if using bash or ~/.zshenv if using zsh

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

NOTE:
Make sure it's the last setting in your ~/.bash_profile . I ran into an issue where I installed a program that updated my .bash_profile and reset PATH.

Finally, make sure your `$HOME` folder doesn't have a `.ruby-version` file that you may have created by accident if you were to have done `$ rbenv local <ruby-version>` in your `$HOME` folder. Doing `$ rbenv global <ruby-version>` modifies the `$HOME/.rbenv/version` file, and the existence of a `.ruby-version` file in the `$HOME` folder would override the version set by `$HOME/.rbenv/version`.


From the docs:

> Choosing the Ruby Version
When you execute a shim, rbenv determines which Ruby version to use by reading it from the following sources, in this order:

> The RBENV_VERSION environment variable, if specified. You can use the rbenv shell command to set this environment variable in your current shell session.

> The first .ruby-version file found by searching the directory of the script you are executing and each of its parent directories until reaching the root of your filesystem.

> The first .ruby-version file found by searching the current working directory and each of its parent directories until reaching the root of your filesystem. You can modify the .ruby-version file in the current working directory with the rbenv local command.

> The global ~/.rbenv/version file. You can modify this file using the rbenv global command. If the global version file is not present, rbenv assumes you want to use the "system" Ruby—i.e. whatever version would be run if rbenv weren't in your path.
Reply

#18
First step is to find out which ruby is being called:
```
$ which ruby
```

Your system says:
```
/usr/bin/ruby
```

This is NOT the shim used by rbenv, which (on MacOS) should look like:
```
/Users/<username>/.rbenv/shims/ruby
```

The shim is actually a script that acts like a redirect to the version of ruby you set.

I recommend that for trouble shooting you unset the project specific "local" version, and the shell specific "shell" version and just test using the "global" version setting which is determined in a plain text file in ~/.rbenv/version which will just be the version number "1.9.3" in your case.
```
$ rbenv global 1.9.3
$ rbenv local --unset
$ rbenv shell --unset
```

You can do `ls -laG` in the root of your project folder (not the home folder) to make sure there is no longer a ".ruby-version" file there.

You can use `rbenv versions` to identify which version rbenv is set to use (and the location and name of the file that is setting that):
```
$ rbenv versions
```

NONE OF THAT MATTERS until you set the path correctly.

Use this to make sure your *MacOS will obey you:
```
$ rbenv init -
```

Followed by:
```
$ which ruby
```

To make sure it looks like:
```
/Users/<username>/.rbenv/shims/ruby
```

Then run this to add the line to your profile so it runs each time you open a new terminal window:
```
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
```

There are other ways to modify the path, feel free to substitute any of them instead of running the rbenv init.

NOTE: reinstall Rails with:
```
$ gem install rails
```

If you were trying to run Ruby on Rails, then you need to have this all working first, then install the rails gem again. A previous install of Rails will use a hard coded path to the wrong ruby and several other things will be in the wrong place, so just install the gem again.

P. S. If your MacOS won't obey you (*mentioned above) then you may have to find another way to modify your path, but that's unlikely to be a problem because "Macs just work" ;)
Reply

#19
All the other answers here give good advice for various situations, but there is an easier way.

The rbenv docs point us to the rbenv-doctor diagnostic tool that will quickly verify all these potential pitfalls on your system:

curl -fsSL

[To see links please register here]

| bash

When all is well, you'll see this:

$ curl -fsSL

[To see links please register here]

| bash <aws:hd-pmp-developer>
Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20201005)
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK

Now, if we break one of those expectations (e.g. remove rbenv-install), the tool will point us directly to the problem, with a link to how to fix it:


$ mv /usr/local/bin/rbenv-install rbenv-install-GONE

$ curl -fsSL

[To see links please register here]

| bash
Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK

===> Checking `rbenv install' support: not found <===
Unless you plan to add Ruby versions manually, you should install ruby-build.
Please refer to

[To see links please register here]


Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
Reply

#20
I fixed this by adding the following to my `~/.bash_profile`:

#PATH for rbenv
export PATH="$HOME/.rbenv/shims:$PATH"

This is what is documented at

[To see links please register here]

.

From what I can tell there **isn't** `~/.rbenv/bin` directory, which was mentioned in the post by @rodowi.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through