Update rails app to ruby 2.0.0 bundler error - ruby-on-rails

I started a Heroku Rails app using Ruby 1.9.3 and Rails 4.0.1.
I decided soon after to update my ruby version to 2.0.0 as this apparently works better with Rails 4.0.1. So, I installed the ruby2.0 package using apt-get and other associated packages, then I set ruby 2.0.0 as the default using sudo ruby-switch --set ruby2.0, finally I updated the Gemfile in my app, changing the line ruby '1.9.3' to ruby '2.0.0' Now, when I run bundle install I am presented with this error, and I don't know why...
Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0
Following this heroku guide didn't seem to help... I set the path to what is shown there and it didn't seem change anything. Maybe I am being stupid and there is something in that path that I need to replace something with information specific to my machine? I feel like the part where I set vendor/bundle/ruby/2.0.0/bin should have some specific info, like changing "vendor" to something but I don't know what... I'm not totally familiar with this stuff yet, this is my first time using heroku and ruby.
EDIT: I forgot to mention (in case it is important) I am running Xubuntu 13.10.

I believe I have fixed the issue. I was somehow running the bundle command which was installed for ruby 1.9.3... so when it compared the gemfile definition with the version it was running on they mismatched. Re-rerunning sudo gem install bundler has sorted it out.

Related

how can i find what version of rails my app is running on?

I am trying to run an old rails app, but I am receiving this error after calling $ rails server:
uninitialized constant AppGenerator::Config
Did you mean? RbConfig
I am brand new to Rails, and I really don't know what this means/where to start. The app is supposedly built on 2.3.8. My computer says I have 2.4.1 and 2.3.18 installed.
I would like to know if I should install 2.3.8, or if I should upgrade to the latest version? Also I don't understand the error that is coming up, where should I look in the app to fix this - or is this a Rails problem?
Verify the version your project is built type bundle show inside it. It's gonna show all the gems and your respective versions.
And to check the rails version just type rails -v in your terminal.
The gemfile in the app folder should tell you what version of rails it is.
You can use bundle update to update the version or if you have a newer version and want an older version, do gem uninstall rails and then gem install rails -v "version number" for example, gem install rails -v 2.3.8.
You can check the rails version on Gemfile.
Try the command rake about to see the application environment.
I would suggest to have your environment setup same on the Gemfile, your application might have compatibility issues if you use a lower version.

Rails appears as not installed even though it is installed

I'm new to rails. After finally getting my environment to work properly with RVM 2.0.0 rails 4.0.5, all of a sudden rails disappeared and I keep getting the message: Rails is not currently installed on this system...
When I quit terminal, reopen it, and type:
$ rails v
It shows 4.0.5
However, as soon as I change directory into my rails app and check the rails version I get the message that rails is not installed.
Any idea what's going here?
When you use rvm you have multiple versions of ruby installed. You select which one you want like this:
rvm use 2.0
or
rvm use 2.1
You can also specify a ruby version in a .ruby-version file in a directory. Then when you change to that directory in the terminal, RVM will switch versions for you.
Each version of ruby has its own set of installed gems. Rails is a gem.
Ergo, when you installed rails, you were in your default ruby version (probably the one build-in on your system). When you change directory to your rails application, RVM is kicking in to switch to the correct ruby version for you. But you don't have rails installed in that version.
So the solution is to switch to the directory for your rails app and run:
bundle install
This will install your gem bundle for your application, including the rails gems, and it will do it into the correct ruby version.

Can't boot WEBrick, the folder for Rails gem is empty

I'm following Michael Hartl's Ruby on Rails tutorial, and I got stuck at trying to start rails server on my Windows 7 machine.
I'm trying to do this by following instructions in Chapter 1.2.5., i.e. by typing
rails server
However, instead of booting WEBrick, this returns the instructions for usage of 'rails' command. I've been googling this for a while, and some of the answers seem to have implied that something is wrong with the rails gem.
Now, I've found the rails gem folder ("C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\rails-3.2.3"), and it's empty!
Also when I try
rails -v
it returns "Rails 3.2.16", although I've removed this version of the gem; if I try
gem list
it kept telling me that the version is 3.2.3.
This persisted until I deleted railties version 3.2.16, which resulted in
rails -v
returning 'Rails 3.2.3', but I still can't boot WEBrick.
Any help would be appreciated.
Did you run the installer?
At the time of this writing, I recommend using the Ruby 2.0.0-p353.
http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353.exe?direct
Save yourself some future gem headaches and install the DevKit too.
http://rubyinstaller.org/downloads/
It should create a folder at C:\Ruby200. Start a new command prompt for the new paths to take affect.
Once Ruby is install, gem install Rails. From your other post, I recommend gem install rails -v 3.2.16
Then execute rails new project_name, then cd project_name. Then run rake db:migrate to create the initial database. At this point, you should be able to run rails server and visit localhost:3000 in your browser.
OK, I've managed to solve my problem.
I've seen a few more people having the same issue, but none of the solutions that I've found helped me, so here's what did it for me, though I'm not 100% sure what exactly was that one thing that actually did it...
I've followed the advice #scarver2 gave in response to my other question, and uninstalled both Rails and Railties gems from my crispy fresh installation of Ruby 1.9.3. (I've installed it using RailsInstaller). Then I've installed Rails 3.2.16 gem by typing
gem install rails -v 3.2.16
and this also installed the corresponding Railties 3.2.16 gem without my intervention.
Then I followed steps from chapters 1.2.3. and 1.2.5. of the tutorial, but making sure that line referencing ruby version in my Gemfile actually corresponds to the version of Ruby that I have installed.
I typed
ruby -v
in the console, to make sure that I have version 1.9.3. indeed. Confirming this, I've edited the Gemfile in my app so it says
ruby '1.9.3'
instead of ruby '2.0.0' line that's used in Listing 1.5. of the tutorial.
After that I've simply went to my app folder, and typed
bundle update
bundle install
in the console, and this time it did not return any errors as it did in my previous attempts. After that, typing
rails server
did what it should have, and my WEBrick server booted, allowing me to access my app on localhost. Yay!
Now, what I think may have gone wrong the last time was either me screwing up the Gemfile, so the gem versions and their dependencies got messed up. I also assume that ineptly trying to fix this by installing and uninstalling different versions of various gems did not quite help. What may have helped was uninstalling Rails and Railties gems, and installing Rails gem again.

Rails version stuck at 2.3.5 how to update to 3.x

Hi there thanks for looking into this.
after a clean install of Linux ubuntu 10.10 i tried to re-install rails.
after doing sudo gem install rails, I can see I am returned version 3.2.3 of rails
But after generating a new project i couldn't find my gemfile so i tried ruby -v which returns 2.3.4 wich is odd since I know I got the latest.
Also when trying sudo gem update --system I get an error because I might override system files. any solution here?
I'd recommend using rvm to manage your ruby sets -- as well as defining gemsets for each project that will allow you to make sure each project has just the gems it needs.
Here's a link to the rvm installation instructions (they should work with ubuntu):
https://rvm.io/rvm/install/
Here's some info on basic use of gemsets with rvm:
https://rvm.io/gemsets/basics/
Also, when using rails 3+, you should make a practice of typing bundle exec rails -v -- that way you'll use the gems defined for the project you're in.
Can you try typing bundle exec rails -v and letting us know what you see?

How do you change Rails version on a mac?

I've got Snow Leopard with Rails 2.3.5 installed along with other versions (2.2.2 and 1.2.6). I'd like to use 2.2.2 as the webserver I want to deploy to uses a 2.2.x version of Rails. I've tried to uninstall Rails 2.3.5 but get this error:
ERROR: While executing gem ... (Gem::InstallError)
cannot uninstall, check `gem list -d rails`
Is there any other way of setting the Rails version to one of the other installed Rails versions?
You should really take look to RVM(Ruby Version Manager) it's awesome!
https://rvm.io
http://teachmetocode.com/screencasts/rvm-ruby-version-manager/
Cheers
Denis
You should be able to do this without needing to uninstall anything. You can specify the version of rails you want to create an application for by typing the following when creating a new app.
rails _2.2.2_ app_name

Resources