It seems rails server uses different ruby then the one that is set up by rvm.
How to make the rails server command use the same ruby as its set up in the rvm?
When I start the rails server, (write rails server in console) it outputs
ruby 1.8.7 for ruby version.
But when I write
`ruby -v`
to see the ruby version, I get ruby 1.9.3p0 for ruby version.
Also I have installed rvm and when I type
rvm list
it returns that I'm using ruby-1.9.3-p286, so rvm uses different ruby version than the rails server.
I need to be able to start rails server with ruby-1.9.3.
First I have installed ruby 1.8.7 that I installed rvm so I can use ruby-1.9.3.
But it seems that I still can't use it with rails server.
Thanks
When you say "rails server", how are you running the server? Is it through Bundler? Or through a terminal command?
I believe each rvm Ruby version has its own Bundler (which uses the correct Ruby version specified from rvm). If you were to do rvm install ruby-2.x.x, you'll most likely run into ERROR: Gem bundler is not installed, run 'gem install bundler' first. Once you have run bundle exec rails console and are in the console, you can run RUBY_VERSION to see which version you're running.
If you're simply calling rails server, then your PATH might be messed up. You could run which -a rails to see the list of directories your computer searches through for the executables. If you see something like /usr/bin/rails, then this rails server version probably uses the system version of Ruby. I suspect that might be why the rvm Ruby version and Rails Ruby version are different.
the easiest way it to have .rvmrc file in the app directory where you specify which version of ruby you want to use
echo "rvm use 1.9.3" >> .rvmrc
Related
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.
This problem probably has an obvious answer to anyone who has used Ruby on linux for a long time, but I can't really get a good answer via Google.
I'm trying to check out the Rails 5 beta, which requires Ruby 2.2.2 or greater. I've installed the RVM (Ruby Version Manager) and set my ruby version to 2.2.3. Running rvm list in the terminal results in the following output:
rvm rubies
=* ruby-2.2.3 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Okay, great. I have Ruby 2.2.3 installed. Let's try bundle update:
Installing rack 2.0.0.alpha (was 1.6.4)
Gem::InstallError: rack requires Ruby version >= 2.2.2.
Okay, that's weird. What version of ruby do I have? Running ruby -v gives me this:
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
So... do I have 2.2.3 or not? What gives?
Since you are using bundle, I would suggest you to check your Gemfile for ruby version. You can also test it with bundle exec ruby -v
Also try:
rvm use ruby-2.2.3
bundle exec ruby -v
Maybe by setting the default Ruby version on rvm to the one you have (ruby-2.2.3) solves the problem, by doing rvm --default use ruby-2.2.3. Then reload the bash and execute ruby -v to check if the default version of Ruby was changed properly and then try again to execute the bundle install command.
If you don't know zsh and oh-my-zsh, I highly recommend for this kind of things. You could configure the terminal in order to show you the current version of Ruby and Rails that you're using every moment. Check it here: http://ohmyz.sh/
In addition to doing rvm use --default 2.2.3 or rvm use 2.2.3 make sure that you don't have the ruby package from apt (or whatever package manager) still installed. For some reason, that ruby package could take precedence over an RVM Ruby.
Also, try doing rvm uninstall 2.1.5 to force your system to default to 2.2.3... You can always reinstall 2.1.5 later and, if this issue persists, 2.2.3 should stick as your default.
Using RubyMine as my IDE for ruby development with chef on a mbp running OSX 10.8.4
Chef requires ruby 1.9 ruby, and I have it installed. When querying the ruby version via terminal it does shows : ruby 1.9.3p429 . However, when trying to use it with RubyMine, it shows (Under preferences->SDKs) only 1.8.3, not seeing or allowing me to change to 1.9.x
Any help greatly appreciated!.
Thank you.
So apparently version 1.8.3 is installed at /usr/bin/ruby. How did you install 1.9?
If you are using RVM then your ruby installations are probably at ~/.rvm/rubies/ instead. Or if you're using rbenv, ruby might be at ~/.rbenv. Although RubyMine should detect the default location for rvm and rbenv. Do you have ruby in another location? Maybe check with sudo find -name ruby in the terminal to look for other locations of ruby.
I am using Ruby on Rails 3.2.2 and RVM (Ruby Version Manager). By using RVM I installed 2 Ruby versions: first 1.9.3 and then 1.9.2. After I run the rvm use --default 1.9.2 command line I closed and reopened the Terminal window. Finally I run the following command lines in the Terminal window:
$ which ruby
/<MY_USER_PATH>/.rvm/rubies/ruby-1.9.2-p318/bin/ruby
$ ruby -v
ruby 1.9.2p318 (2012-02-14 revision 34678) [x86_64-darwin10.8.0]
However, if I add the <%= "Ruby version #{RUBY_VERSION}" %> code in a view file of my Ruby on Rails project I get Ruby version 1.9.3.
Why my Ruby on Rails project is still running with the Ruby version 1.9.3? How can I make that to run in Ruby 1.9.2?
Passenger doesn't care about RVM, you need to compile Passenger with the Ruby version you want to use, and follow its instructions to setup Apache's configuration accordingly.
If you want to switch Ruby versions, you need to reinstall Passenger's Apache module via passenger-install-apache-module and follow the instructions.
You will likely see that the PassengerRuby directive in your Apache config is pointing to a specific ruby.
If you need different Ruby versions with Passenger, Phusion's blog post on this may be helpful. RVM's docs on Passenger integration are worth reading as well.
I would guess that Apache (Passenger?) is using your globally installed version of Ruby, which looks like ruby 1.9.2. Do a sudo su and then try which ruby and see if you're still pointing to the RVM version of ruby. That version of Ruby is the one that Apache is using, you'd have to setup ruby globally to allow Apache (Passenger) to use it.
I was having issues with RVM so I tried to uninstall everything (Ruby, RVM and Rails) and start fresh.
I installed Ruby 1.9.2 and Rails 3.1.2 rc2 and I am working on Ubuntu 10.0.4. If I do ruby -v from the command prompt I am able to see the ruby version installed and same is true for rails -v.
However once I get into the application directory which and try to check rails -v I get this error
"Could not find rake-0.9.2 in any of the sources
Run bundle install to install missing gems."
If I do bundle install I am getting this error
"bash: /usr/bin/bundle: /usr/bin/ruby1.8: bad interpreter: No such file or directory"
Nothing seems to work and I am stuck in this recursive loop of uninstalling and installing.
Everything was working fine till I got an error linecache19 which requires Ruby >=1.9.2 (I was using 1.8.7 earlier). I installed RVM and Ruby 1.9.2, I had to uninstall RVM and 1.8.7 and I tried to install to install Ruby 1.9.2 as a standalone package. This obviously didn't work.
Please HELP!!
If you have uninstalled a previously installed Ruby version (in my case it was Ruby 1.8.7) and try to install latest Ruby version (I was trying to install 1.9.2) without using RVM. I manually deleted all the version of Ruby present by searching $whereis ruby from my command prompt.
After that I installed a ruby1.9.2. In my existing rails application I was getting lot of errors because the application creates a reference to the earlier installed ruby version (1.8.7) and try to find gems in the earlier installed location.
SO once you have installed a new version and want to run the earlier developed application search where your application is referencing the older version of ruby.
In my case I had to change the path in script/rails from #!/usr/bin/env to #!/usr/local/bin/ruby .
You might also have to add the path of the latest Ruby which you have installed in path variables.