I use rvm on my Ubuntu 14.04 machine and each time I start the terminal, the ruby version selected (from ruby -v) is ruby 1.9.3p551 . rvm --default use 2.2.3 lets me use the selected ruby version, but the entire process needs to be redone each time a new session is started.
How can this be resolved?
Check in your gemfile if there is a references to 1.9.3
If not, check this answer and follow the instructions How to set default Ruby version with RVM?
You can use the .ruby-version file.
This file checked by both ruby version managers, like rvm and rbenv.
For example you can place a file .ruby-version with 2.2.3 in the home directory ~/.ruby-version, it is should set the ruby version at 2.2.3 for any new terminal session. Also you can place a file .ruby-version in the project directory, /path/to/the/project/.ruby-version it is should set ruby version for project.
Related
I have been trying to install React Native into my Mac. In the installation docs, it requires Ruby version of 2.7.6 have been to be installed.
I have installed a new Ruby version using rbenv manager and it was successful. But now I cannot switch my machine to new Ruby version. Any help will be highly appreciated.
Thanks!
You have to set the version for the directory where your react project is. You can do this with:
rbenv local 2.7.6
This creates a file called .ruby-version in the directory, which tells rbenv what version of Ruby to use.
This is all visible in the README of rbenv.
You can have a look at this solution
Use the below command to change your ruby version:
rbenv global 3.1.2 # set the default Ruby version for this machine
# or:
rbenv local 3.1.2 # set the Ruby version for this directory
You can find this from rbenv Official Github Repo
I installed Ruby (v2.6.3) and Rails (v5.2.3).
Even completed a training project on this framework.
Then he took up a working project and first of all executed the command bundle install.
All modules were delivered normally, except one "sassc-2.0.1"
Installation fails with this error:
sassc-2.0.1 requires ruby version >= 2.3.3, which is incompatible with the current version, ruby 2.3.1p112
That is, I chose one version, and in fact uses a different version.
I can't understand the reason for this.
But I didn't give up the first time.
I tried to check the ruby version in different ways:
(1) Get ruby version
$> ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
(2) Get path to bin for ruby
$> which ruby
/home/vdenisov/.rvm/rubies/ruby-2.6.3/bin/ruby
(3) Get path to bin for bundle
$> which bundle
/home/vdenisov/.rvm/rubies/ruby-2.6.3/bin/bundle
All these commands give out that the current version of ruby is 2.6.3
However, my friend advised me to do one more check
(4) WTF ???
$> /usr/bin/ruby -v
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
P.S.: before that I programmed in nodejs and there is a version Manager "nvm" - when you run the command "nvm use a.b.c" in the system, always use the nodejs version of "a.b.c" (the same I expected from the "rvm").
/usr/bin/ruby -v gives you the version of ruby installed in your operating system.
It seems that you already run rvm use --default 2.6.3 because your ruby points to rvm location.
Ruby environment manager RVM supports configuration inside following files: .rvmrc, .versions.conf, .ruby-version, Gemfile. More here: https://rvm.io/workflow/projects
Check these files, it's good practice to set ruby version inside .ruby-version or Gemfile.
bundler gem orients on Ruby version, which locked in Gemfile.lock. Just change Ruby version in Gemfile (not .lock). Try 2.3.3 at first. Maybe you need to install it with rvm or rbenv.
I am trying to use a specific version of ruby on a particular project. I looked into the RVM and rbenv packages, but had little success with any of them.
These are the steps I took:
create project directory and navigate to it;
run rbenv install 2.3.1; after navigating to ~/.rbenv/versions I can see a "2.3.1" in there;
running "rbenv local" also echos 2.3.1;
My Gemfile is as follows:
ruby '2.3.1'
source 'https://rubygems.org/' do
gem 'test-kitchen'
gem 'kitchen-terraform'
end
However, when I run bundle install i get the following error:
Your Ruby version is 2.5.1, but your Gemfile specified 2.3.1
Its my first time working with Ruby, so I am struggling a little. I appreciate all help, and can provide more details if required.
If you store the ruby version of your project in .ruby-version and the gemset (i.e. gem list workspace) in .ruby-gemset of your project (which I recommend doing if the specific version is important to you), rvm should pick this up when you cd into your project directory. Sometimes it doesn't however depending on your setup or installation, in which case you can choose them explicitly with:
rvm use `cat .ruby-version`
rvm gemset use `cat .ruby-gemset
which I add to any installation scripts for example. You may need to run gem install bundler before running bundle install the first time you use the new gemset.
Set your default rbenv version like this:
$ rbenv shell jruby-1.7.1
See in: https://github.com/rbenv/rbenv#rbenv-shell
I have installed RVM and it works. I can change the version of ruby and do all of the other things expected with RVM. however, if I close the current terminal window and open a new one, the new terminal window forgets about RVM. Here's an example:
After opening a new terminal window, I do the following:
$ ruby -v
ruby 1.9.3p484
$ source ~/.bash_profile
$ ruby -v
ruby 2.1.0p0
Ruby 2.1.0p0 is set as the default RVM version. it only loads properly after I reload bash_profile.
I am using Ubuntu with the kubuntu window manager. Any ideas??
what is the o/p of $rvm reload and $rvm notes after you open a new terminal.
Also check out $rvm list
This shows the list for ruby installation available with their version and the default currently being used. You can always change this using $rvm use 1.9.3 --default. If you want any specific version to be loaded for an application, edit the .rvmrc file specifying the ruby version to be used.
I installed Ruby and Rails via RVM, but using "gem install something", the console tries to install into /Library/Ruby/Gems/1.8 directory.
Do I still need this Ruby dir?
You are still using the default Ruby. You need to activate RVM for your shell session. See item 2 at the below:
http://beginrescueend.com/rvm/install/
(and no I wouldn't delete the original Ruby dir)
You have to direct your shell to use RVM and the Ruby version. You can do so by issuing the following command:
rvm use *ruby version (example: 1.8.7)*
Or, if you have created a gemset for particular project:
rvm use *ruby version (example: 1.8.7)*#*my_gem_set*