Hi I'm following Rails Tutorial using Cloud9 ...
Tutorial says to install Rails 4.2.2. Before I did, I ran "rails -v" and saw that it was 4.2.1.
I ran Gem install Rails 4.2.2 and a load of stuff was installed. Tutoral then said to execute Rails 4.2.2 New MyApp. I decided to see what would happen if I did Rails 4.2.1 New Myapp, expecting an error (since 4.2.2 is installed and not 4.2.1 [I think] ), only to get successful execution.
Why is this? Thanks.
Because that version is available in your default gem set which is associated to the Ruby version you are using. Run gem list rails and it will list the rails versions that you have. Try running rails _4.2.3_ new myApp but instead of _4.2.3_ use a version not listed and you will get an error,Could not find 'railties' (= x.x.x) If you install the rails version with gem install rails -v x.x.x you will have that rails version available for that ruby version. Also if you cd to your application and run rails -v it will output the rails version of that one application.
Related
I installed ruby, rails, postgresql on freshly installed Manjaro linux.
[thiebo#Ruth ~]$ rails -v
Rails 6.0.3
[thiebo#Ruth ~]$ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
I could create a new app with rails new mynewapp and that works fine.
I then downloaded my app already live on heroku. When I change directory to my app downloaded from heroku and command rails server, I get bash: rails: command not found.
the app from heroku was with rails 5.2.3 so I expected quite some error messages and necessary upgrade from rails 5.2.3 to rails 6.2. But I can't explain and don't know how to solve the command not found.
You need to install Rails per each version of Ruby on your machine and you need to install each version of Rails that is required by apps running under a specific version of Ruby.
Therefore you need to run
bundle install
after downloading your application to install all required dependencies for the current Ruby version.
I attempt to upgrade to Rails 5.1.4. Seems to update without an issue, however, a version check still shows 5.0.4. Any ideas?
Ruby Version:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
Terminal Output:
$ rails -v
Rails 5.0.4
$ gem install rails --version=5.1.4
Successfully installed rails-5.1.4
Parsing documentation for rails-5.1.4
Done installing documentation for rails after 0 seconds
1 gem installed
$ rails -v
Rails 5.0.4
Uninstall all versions of rails installed in your system by:
gem uninstall rails
It should prompt you with something like below
Select gem to uninstall:
1. rails-4.2.6
2. rails-5.1.4
3. All versions
Choose Option "All Versions" and uninstall all
Install the desired rails version:
gem install rails --version=5.1.4
rails -v
5.1.4
Update: Since you mentioned using bundle install, check if rails is specified with 5.1.4 in your Gemfile or not.
Sometimes, i met this problem, because you have two versions of rails in your railties. You can do this
gem uninstall railties
Select gem to uninstall:
1. railties-5.1.4
2. railties-5.0.4
3. All versions
Type 3 to remove all, then you can reinstall rails 5.1.4 again.
Either use
bin/rails -v
or
bundle exec rails -v
to select the version of rails specified in your Gemfile
Or do what I do and install https://direnv.net/ and add a .envrc file to the project. Then when you cd to that project, the path will be updated appropriately and rails -v will work as expected:
PATH_add "./bin"
Just a quick question using nitrous.io. Been following a tutorial on treehouse for ruby on rails, now as they use version 3.2 and I was using 4 it just was impossible to follow.
So, how do I choose which version of Nitrous.io I'm installing / targeting? I need to be using 3.2.
One quick and easy way to handle this would be to install Rails 3.2 alongside with Rails 4.
gem install rails -v 3.2
From there, you can create a new project with Rails 3.2 with the following command:
gem _3.2_ new appname
If you are working on an existing project, ensure your Gemfile is specifying gem 'rails', '3.2.0', and from there you can run bundle install to ensure all dependencies have been installed.
I am using ubuntu 12.04. I have installed ruby 1.9.3 and rails 3.2.13. When I check my version of rails using command rails -v, it shows Rails 4.0. How can I switch to Rails 3.2.13?
As you have already installed rails and its current version is 4.0, so please do this
gem install rails -v 3.2.13 and if you want to remove 4.0 version please do gem uninstall rails, you will get the list of rails and then choose 4.0.0 version.
Simple If you want to switch rails then you can install multiple rails version by using
sudo gem install rails -v 3.2.x or gem install rails or any version you want
If you want to switch ruby version use rvm and choose rvm use 1.9.3 or rvm use 2.0.0
Thanks
rails new appname will use the latest version of rails. To use an earlier installed version, call:
rails _3.2.13_ new appname
You can then have both versions of rails installed and not have to deal with uninstalling rails which can be problematic.
I am trying to get my Instant Rails working on my Windows 7 laptop.
The error I keep getting when trying to access my site files are:
c:/rails/ruby/lib/site_ruby/1.8/rubygems.rb:779:in 'report_activate_error'
RubyGem version error: rack<1.1.0 not~> 1.0.1> <Gem::LoadError>
from c:/rails/ruby/lib/ruby.site_ruby/1.8/rubygems.rb:214:in 'activate'
from c:/rails/ruby/lib/ruby.site_ruby/1.8/rubygems.rb:1082:in 'gem'
from c:/depot/vendor/rails/actionpack/lib/action_controller.rb:34
from c://rails/ruby/lib/ruby.site_ruby/1.8/rubygems/custom_require.rb:31 in 'gem_original_require'
etc...
I have intalled Rubygems 1.3.7 and they work fine and when I run the test it works and the gem env shows that the 1.3.7 has been installed correctly.
What can I do to get this working?
Any prompt help would be VERY appreciated.
Thanks
Your rack gem is outdated. Try to run gem update rack. Or, if you use Rails with Bundler, just run bundle install in the root of your project and it will do everything for you.
I decided to write a little manual about the Ruby 1.8.7 and Rails stable installation.
Download RubyInstaller 1.8.7 from here. During the installation, check the 'Add Ruby executables to your PATH' box. After the installation, don't forget to restard cmd. Then try running ruby -v and gem -v to check for installed Ruby 1.8.7 and RubyGems 1.3.7;
Install the latest stable Rails 2.3.8 using gem install rails --no-ri --no-rdoc; Check it using rails -v;
Create a new application using rails myapp;
Test it: script/server. That's it!
gem install rack -v 1.0.1