Hi i'm new to ruby on rails
I have 3 ruby version in my computer.
In a project i had to use rails 3.2.1 and ruby 1.9.2
So I switched using rvm use 1.9.2 in terminal. But after that my rails commands are not detected.
$ rails g model abc
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Why is this happening? And how to solve this?
You may need to differentiate your gem set that contains that specific version of rails from the old ones.
rvm use 1.9.2#new_gem_set_of_yours --create --default
And then retry installing the 3.2.1 rails
gem install rails --version 3.2.1
Or specify the new rails version in your Gemfile and let Bundler take care of it
gem 'rails', '3.2.1'
and run bundle install.
Type in your terminal
gem install rails -v 3.2.1
if it does not work, first try
rvm install 1.9.3
then
rvm rubygems current
and repeat.
Related
What gives?
I typed this in gem install rails -v 4.2.2
After that, I tried rails -v, and it keeps coming out Rails 3.2.13
Why is this?
My ruby version after ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
You can manage gems with bundler (http://bundler.io/)
Put this on your Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.2'
gem install bundler
and then
bundle install
bundle exec rails -v
If you still working without bundler, you can make
gem list
look at your rails version and then uninstall older versions
gem uninstall rails --version 3.2.13
and then
rails -v
I've encountered this before. And this is what I did.
Change version of rails
Just change the versions.
If you have multiple versions of Rails installed, you'll get conflicting information like this.
If you need to run a command with a specific version of Rails, you can specify the version as part of the command, eg.
rails _4.2.2_ -v
That will tell you you are using Rails 4.2.
Once you've created a new app by doing something like rails _4.2.2_ new app_name, then the Gemfile for that app will specify Rails 4.2.2 and you can drop the special prefix.
When I use rvm use 1.9.2, I get Rails v3.0.0:
vikas#admin1-DL-H61MXEL:~$ rvm use 1.9.2 --default
Using /home/vikas/.rvm/gems/ruby-1.9.2-p320
vikas#admin1-DL-H61MXEL:~$ rails -v
Rails 3.0.0
When I use rvm use 2.0.0, I get Rails v3.2.13:
vikas#admin1-DL-H61MXEL:~$ rvm use 2.0.0
Using /home/vikas/.rvm/gems/ruby-2.0.0-p195
vikas#admin1-DL-H61MXEL:~$ rails -v
Rails 3.2.13
I need Rails v3.2.13 with Ruby 1.9.2.
When I used rvm use 1.9.2 --default and gem install rails -v 3.2.13, I got the following error:
While executing gem ... (Gem::FilePermissionError) You don't have write permissions into the /home/vikas/.rvm/gems/ruby-1.9.2-p320/bin directory.
This is the error I'm facing now.
The most likely reason you're getting the error:
(Gem::FilePermissionError) You don't have write permissions into the /home/vikas/.rvm/gems/ruby-1.9.2-p320/bin directory.
Is because, at some point, you used sudo or were running as root when you use RVM to install a gem. When that happened, the ownership of files and/or folders changed to root's permissions, which you can't override running as you.
You don't want to run as root, or use sudo EVER when running rvm or gem commands if you have a RVM installation to provide Ruby in a sandbox in your home directory.
To fix this, try this command:
sudo chown -R vikas ~/.rvm
That will use sudo to change ownership of all files in the ~/.rvm directory to your own account, from the "root" user. This will take at least a few seconds so let it run.
Once that has run, you should be able to switch to each of your Rubies and delete the installed Rails:
rvm use 1.9.2
gem uninstall rails
gem install rails -v 3.2.13
Then:
rvm use 2.0.0
gem uninstall rails
gem install rails -v [whatever version you want]
gem install rails -v
rvm use 1.9.2 --default Using /home/vikas/.rvm/gems/ruby-1.9.2-p320
gem install rails -v 3.2.13
rvm is software tool by which you can manage multiple version of rubies on your system.
for each ruby version you can create a gemset which is just a group of gems.
each ruby version you install has a 'default' gemset.
and it seems that you have installed rails 3.0 for ruby 1.9.2 and rails 3.2.13 for ruby 2.0
you can create your own gemset by command
rvm gemset create rails3
this will create a gemset named 'rails3' and to use it you have to do
rvm gemset use rails3
and in this gemset you can install any version of rails you want.
with command
gem install rails -v='3.2.13'
for more info see rvm doc.
https://rvm.io/
I try to install skylinecms but I have a problem with installing the gem.
The gem factory_girl asked me to use version> = 1.9.2 of Ruby
atmoner#atmoner:~/base_ror$ sudo gem install skylinecms
ERROR: Error installing skylinecms:
factory_girl requires Ruby version >= 1.9.2.
ruby -v
atmoner#atmoner:~/base_ror$ ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]
I have tried to change ruby version to 1.9.2
atmoner#atmoner:~/base_ror$ rvm use 1.9.2
Using /home/atmoner/.rvm/gems/ruby-1.9.2-p320
But still same problem
atmoner#atmoner:~/base_ror$ sudo gem install skylinecms
ERROR: Error installing skylinecms:
factory_girl requires Ruby version >= 1.9.2.
what's the source of this problem?
you have an idea?
You shouldn't use sudo with rvm, as it creates a new subshell with a completely new environment. See more about sudo and rvm here: RVM and 'sudo'
Most likely your system ruby version is 1.8.7, and that is what is getting invoked when you run sudo gem install skylinecms. You can verify that with the following commands:
rvm use system
ruby -v
Try installing the skylinecms gem without sudo.
Best to use per-project gemsets as suggested in rvm best practices
I had already installed rails 1.8.7, forgot about it, then installed 1.9.3 through RVM. I was getting weird errors, so I purged my Mac of the system version of Ruby and started again using RVM. So far I've
Installed Ruby:
rvm reinstall 1.9.3-p0
which ruby
/Users/User/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
Manually setup Rubygems
which gem
/Users/User/.rvm/rubies/ruby-1.9.3-p0/bin/gem
Tried to install rails
sudo gem install rails
Successfully installed rails-3.2.1
1 gem installed
gem list
rails (3.2.1, 3.2.0)
It says rails is installed, but which gem does not work, and when I try to use rails new I get:
-bash: rails: command not found
I'm definitely missing something here. The only explanation I can think of is that there are remnants of a previous ruby or rails install that's causing problems. Is there a way to start completely from scratch?
If you are using RVM, you should not use "sudo" when you install gems. That will install gems to your system ruby version (not on the RVM rubies).
First, set up default rvm ruby like
rvm use ruby-1.9.3-p0 --default
Then, install rails on it by running:
gem install rails -v=3.2.1
It's actually better to use gemsets so you can have different gems set for the same ruby version. Check here for more info.
Somehow my rails installation hides itself successfully...
I have:
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
rvm 1.10.0-pre
gem 1.8.10
and I try to install rails:
sudo gem install rails
it works fine:
Successfully installed rails-3.1.3
1 gem installed
Installing ri documentation for rails-3.1.3...
Installing RDoc documentation for rails-3.1.3...
when I do:
rails - v
I get
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Also, when I do
rake
in a rails app root directory, I get:
Missing the Rails gem. Please `gem install -v= rails`, update your
RAILS_GEM_VERSION setting in config/environment.rb for the Rails version
you do have installed, or comment out RAILS_GEM_VERSION to use the
latest version installed.
executing
gem install -v= rails
raises an error:
ERROR: While executing gem ... (ArgumentError)
Illformed requirement ["="]
So apparently it is sitting somewhere and cannot be seen by my environment. I guess installing via apt-get is not an option as I don't want to confuse gem...
Any ideas?
Cheers
Mac
Do not use sudo.
Just gem install rails
Use RVM instead of the packaged ruby/gems distribution. http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/