I'm installing Ruby using MacPorts.
After using the following command:
sudo port install rb-rubygem
I got the following error:
Error: Port rb-rubygem not found
What should I be doing?
This post is old but I'll add this here. If you want to use mac ports you can add ruby by using sudo port install ruby and then sudo port install rb-rubygems (notice you missed the 's' in rubygem*s* in your original post). You can always check what repositories are available in mac ports by typing port list. Hope this helps.
Ruby is installed by default in every mac. However, it's ruby 1.8, which is very old and shouldn't be used in any of your projects.
Take a look at rvm.
It will allow you to install several versions of ruby in the same system.
So, for example, you can do the following :
rvm use 1.9.3
ruby -v #=> ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin12.2.0]
rvm use 2.0.0
ruby -v #=> ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.1]
Using rvm, you can install any new version of ruby using the following :
rvm install 2.0.0-p0 #=> This will install Ruby 2.0.0
rvm install jruby #=> This will install jruby
And so on
Related
I have installed RVM successfully on my Mac and using it I have installed Ruby 2.6.3. I have set my current and default version of Ruby to be 2.6.3. Everything seems to be fine because when I enter ruby -v into the terminal it tells me I'm using ruby 2.6.3.
My problem comes when I try to install Rails 6, I'm entering:
gem install rails --version=6.0.0 -no-ri -no-rdoc
It seems to install correctly however when I try to confirm with:
rails -v
I get:
Rails 6 requires Ruby 2.5.0 or newer.
You're running
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64- darwin18]
Please upgrade to Ruby 2.5.0 or newer to continue.
Why am I getting this message when my ruby -v command is telling me that I am using ruby 2.6.3
Any help would be very welcome.
You're running ruby 2.3.7p456. You need to set your local ruby version to 2.6.3.
Try which ruby to see which ruby version is loaded.
rvm install 2.6.3
rvm use 2.6.3
You can then see which ruby is running with which ruby.
See the basics on the rvm docs
As an aside, I also recommend recommend rbenv over rvm; however, you can only have one installed. If you have both installed, you're going to have a bad time.
To make sure you do not have both installed try which rbenv, and that should return rbenv not found
Please edit your original question with the output of the following commands:
which -a ruby
echo $PATH (That will help debug if your $PATH is set up incorrectly.)
which rbenv
ls (in your project directory)
i also had the similar problem which i resolved by uninstalling rvm completely and then installing rbenv.
I want to use Rails with Ruby 2.1.0, but it's using Ruby 1.9.3 (the system's version).
I'm using rbenv to manage my Ruby versions. My steps were something along the lines of:
$ rbenv install 2.1.0
$ rbenv global 2.1.0
$ sudo gem install rails -v 4.0.2
$ rbenv rehash
$ rbenv versions
system
* 2.1.0 (set by /home/dennis/.rbenv/version)
$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
$ rails new app && cd app
$ rails server
Rails is using is Ruby 1.9.3 (x86_64-linux), according to localhost:3000/rails/info/properties. A log message from rails server gives: INFO ruby 1.9.3 (2012-04-20) [x86_64-linux].
I think Rails is using the system version of Ruby because the versions match.
$ rbenv local system
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
$ rbenv local --unset # Unset local Ruby version, go back to 2.1.0
Some things I've tried with no luck:
setting the local and shell versions of Ruby to 2.1.0 with rbenv
rehash rbenv shims (rbenv says to do this after installing executables)
made new Rails projects after switching to 2.1.0 just in case I made the projects while using 1.9.3
putting 2.1.0 in a .ruby-version file in the root of my project (suggested by #Agis)
restarting terminal session and starting a login bash shell (suggested by #Russel)
specifying the desired Ruby version in the project's Gemfile (suggested by #rlecaro2)
FWIW, I'm using Ubuntu 13.10 with the fish shell.
Sounds silly, but did you restart terminal session?
Otherwise try and type
/bin/bash --login
You didn't tell how you installed rbenv, but I think it is per-user installation (which is default). In this case you should install gems without using sudo. When you did sudo gem install rails, it was installed in system ruby, not rbenv's selected one.
Solution - install rails without sudo:
rbenv global 2.1.0
gem install rails
rbenv rehash
Try creating a .ruby-version file in the root of your project with the following contents:
2.1.0
I'm getting the next error installing RoR
How can I set the correct Ruby Version?
#####:path$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
#####:path$ sudo gem install rails
ERROR: Error installing rails:
activesupport requires Ruby version >= 1.9.3.
#####:path$
You shouldn't have to use sudo with gem install .... That's what's causing the mismatch between Ruby versions, since root is using the default installed Ruby, whereas your own account is using RVM's installed version.
Updating the system version of Ruby depends on your operating system, and usually lags behind the very latest version of Ruby. I've been using 2.0 for my latest project I launched last month. I doubt big OS vendors like Ubuntu or Apple are providing that version in their latest distribution. It's best that you manage your own Rubies whenever possible.
To install 1.9.3 you can run:
$ rvm install 1.9.3
then later
$ rvm use 1.9.3
You have :
###:path$ ruby -v
.....
###:path$ sudo gem install rails
...you said in your comment that :
$ sudo ruby -v
...gives you
ruby 1.8.7
To resolve this problem you shouldn't use sudo, as it tries to install using root session with 1.8.7 ruby version which is not supported.
To install rails just type the following without sudo:
$ gem install rails
...it should works as you've a supported ruby version (ruby 2.0.0p247)
You can check Install Ruby on Rails ยท Ubuntu Linux instructions (Which I found useful) if you've more troubles.
Accidently I have installed both versions of ruby on my system and now the default version is set to
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
but I need to set the default version to 2.0.0...
for this I used the command
$ rvm 2.0.0p294 --default
but it says rvm is not currently installed though I installed it, typing various commands(via google) .
Also I want to install an Integrated Ruby shell in ubuntu 13.04, do suggest how to do it.
I have also installed Aptana Studio on my system, now how should I get started with it.
Finally, the last problem is tell me how to check whether rails is currently installed in my system or not...
Thanx in advance!!
to use a gemset try writing
rvm use ruby_gemset_version
to check the rails version try to type rails -v
you have to install RVM (ruby version manager), then you have control to use any specific versions of ruby, and coming to rails you have to manually install rails gem once you have installed rvm and selected a version.
This would be helpful to install rvm
https://rvm.io/rvm/install
After installation you have to install ruby versions.
Then you can use the following cmd
$ rvm use 2.0.0
to use ruby 2.0.0
Thank you.
Go to this http://rvm.io/rvm/install It has instruction to install and cofigure RVM. It is dependant on CURL lib. So make sure you have curl installed in your system, if not then the command is
#sudo apt-get install curl
Once it is intalled and configured properly.
On Ubuntu:
GoTo Terminal > Profile Preferences > Title and Command > Set checkbox for (Run command as login shell)
Install rubies using rvm install.
Odd problem, trying to figure out what is going on here with my fresh install.
I installed Ruby 1.9.3 using homebrew. I installed Rails 3.2.0 using ruby gems. I then created a test application with rails new test_app to make sure everything looked okay in the test environment. Somehow, the rails environment is using 1.8.7 instead of 1.9.3.
When doing a ruby -v, I get this:
overcast:test_app joe$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
But when running rails s I get this:
overcast:test_app joe$ rails s
=> Booting WEBrick
=> Rails 3.2.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-21 23:21:35] INFO WEBrick 1.3.1
[2012-01-21 23:21:35] INFO ruby 1.8.7 (2010-01-10) [universal-darwin11.0]
And, obviously, when looking at the rails environment webpage at localhost:3000 I am showing 1.8.7 instead of 1.9.3. I've edited /etc/paths to have /usr/local/bin at the top based on some answers I've found here, but it doesn't seem to make a difference.
Any help would be greatly appreciated!
Addendum: The same situation happens when installing and attempting to use Ruby through RVM.
If you are running mac os x you have ruby 1.8 preinstalled. Use RVM or rbenv if you want to have more than one ruby version installed.
Homebrew not so bad :)
You may use rbenv. It is ruby version manager.
My success story for MAC OS X 10.8.2 is:
install Homebrew
change PATH in /etc/paths (/usr/local/bin need to be first)
install rbenv and ruby-build (it is plugin for rbenv) using homebrew
create ~/.profile with content:
export RBENV_ROOT=/usr/local/opt/rbenv
if which rbenv > /dev/null; then
eval "$(rbenv init -)"
fi
install last stable ruby version using rbenv install 1.9.3-p374
change default ruby version using rbenv global 1.9.3-p374
update gem using gem update --system (optional)
install rails gem install rails
...
Profit :)
bundle exec rails server
Should work just fine. It also worked for me to close the terminal and open a new one.
if you have multiple versions of ruby, I recommend you use RVM
Install it https://rvm.io/rvm/install
Use: https://github.com/wayneeseguin/rvm#usage
To view all versions of ruby use "rvm list"
and set default version "rvm --default version"
sudo update-alternatives --config gem
and select your verison!