I have a rails 3 app that was made with 2.0.0-p0 ruby.
Now i would like to update just the ruby to 2.2.2
I changed already the local and global ruby on rbenv to 2.2.2.
There is a way or i have to keep using the 2.0.0-p0 on this app?
You have switched to another version of Ruby and you are probably using a different gemset (probably an empty one). Try running:
bundle install
Note that after switching to a newer version of Ruby, some of your old code might not be compatible, i.e. need debugging.
Hope this help!
Related
I can't seem to find this simple yes no question online so sorry for the super noob question!
I'm using an EC2 instance for my development and I set it up to have ruby 2.1.1 and rails 4.1. I have RVM, but don't actually have any other ruby versions.
I cloned my friends project and told him I would start helping him. His project is a ruby 2.0 and rails 4.0.4.
He's concerned that when I merge changes it will update the project to 2.1.1 and rails 4.1 and then it will crash on his computer (since he doesn't have 2.1.1 or rails 4.1)
I don't think this is the case, but I'm not 100% sure, so how valid are his concerns? I was under the assumption that as long as I don't use any functionality from rails 4.1 and 2.1.1 that isn't in 4.0.4 or 2.0.0 then there is no need to be concerned. Also, I assume when I cloned the project and make changes to it, it should stay in 4.0.4 and 2.0.0 versions. Is that true?
Thanks for any clarification!
The Rails version should be defined in Gemfile, so unless you change it, it will stay the same (and when you run bundle install the proper version will be installed if it's missing, so even on your computer you will not work on Rails 4.1, but on Rails 4.0.4).
With Ruby version it's a bit more complicated, because it can be defined in some file (like .rvmrc or .ruby-version), but does not have to. Still, if you don't change anything in project's configuration, neither Ruby nor Rails version will be changed.
If you are physically merging a 4.1 into the 4.0.4, then you will most likely encounter some issues. (I don't know the exact differences between those versions, but a full minor version up usually comes with new/changed goodies)
If you are just working on each app separately, then they would be isolated by their Gemfile. This is assuming the Gemfile.lock has been saved into the repo. Or the versions have been locked in the Gemfile itself.
Your Ruby version probably won't matter if you are running the bundle install fresh on your current version. Unless there are specific needs for a specific version.
I finished Michael Hartl's tutorial and created an app using Ruby 1.92 and Rails 3.2. Now I want to make my own app but I want to use the new versions of Ruby and Rails.
If I install the new versions for my new app, can I still make changes to my old app without things getting messed up or do I have to keep installing/uninstalling different Ruby and Rails versions?
You should look at using a ruby environment manager. I use rbenv, you can also specify in your gemfile which version of ruby and rails should be used for a specific application.
https://github.com/sstephenson/rbenv
You should be fine. Just make sure the proper versions are specified in your Gemfile and you will be good to go.
After installing the new version, by default new version will be used. However, already existing app will still use the version of rails they already exist as.
Bundler takes care a lot of the hard work for you in your situation.
Other notes:
Keep in mind RVM allows you to install "Gemsets". Should you have the need to use specific versions for gems you can create sets of them for use when needed.
You can also specify the version of rails when you're creating your app via rails _3.x.x_ new FooBar and you can identify what versions of rails are installed on your system via gem list --local | grep rails
If you need to negotiate local and global ruby versions, consider using rbenv.
https://github.com/sstephenson/rbenv
RVM is another popular option for ruby environment management.
https://rvm.io/
Personally, I have been more successful with rbenv.
I currently have several Rails applications running version 3.2.13 that use Ruby 1.9.3. I plan to eventually upgrade my current applications to Rails 4.0 then upgrade Ruby to 2.0. I need to time the conversion to Ruby 2.0 carefully since from my understanding Phusion Passenger will only handle one version of Ruby without some nose bleeding solutions which I do not plan to attempt to implement at this point.
I currently use one gemset for all my Rails applications. I would like to convert my Rails applications one by one from 3.2.13 to the current version of Rails 4.0 at some point. When I have tried to update one of my applications to a newer version of Rails I was told I had to do a update rails command.
What I want to do is to be able to run some of my applications using Rails 3.2.13 and others using Rails 4.0 until I am sure they will all run properly under Rails 4.0. Once I do this I will review the differences between Ruby 1.9.3 (if any) and upgrade all of them to use Rails 2.0. At this point I understand that I would just create the gemset for 2.0.0 or whatever the latest stable version of Ruby 2 is.
I have done web searches and checked the RVM website. I understand how the gemsets are assigned to the version of Ruby you want to run. However I'm not seeing anything about using gemsets with the same version of Ruby but using different versions of Rails or other combinations of gems on the same machine for different applications. Can this be done?
Any help would be appreciated.
Take a closer look! ;)
First, create a new gemset with a name corresponding to your project
https://rvm.io/gemsets/creating/
ex: rvm gemset create project_name
Then create/edit .rvmrc file in project directory: rvm use 1.9.3#project_name
One pitfall is that if you execute following commands
cd some_project
cd ../other_project
and other_project doesn't have gemset specified you'll stay in some_project gemset. To avoid that you can create .rvmrc file with default gemset in your "projects" directory (if you have one)
Project Folder
|___Gemfile
|__.ruby-gemset
|__.ruby-version
Gemfile with all the required gems mention in your project folder
.ruby-gemset should have gem set name like sample-gemset
.ruby-version file should have specific ruby version (e.g 2.0)
rvm gemset list
it will show gem set created with sample-gemset and do the
bundle install
which will install all the specific gems for this project under sample-gemset,
same you can do for other project to create other gem set, in this way you can maintain different rails/gems and ruby version for different projects with rvm.
Your Gemfile.lock nails down which version of every gem you use - you don't need to worry about gemsets.
bundle install will always install the correct versions and your app will always use the versions in Gemfile.lock, even if there are other versions floating around
I have an app using Rails 3.0.6 which I run on two machines. I started with ruby 1.8.7 and recently installed ruby 1.9. I swapped my link in '/usr/bin/ruby' to point to the 1.9 install. When I run 'ruby --version' I get the 1.9. However, in my rails app, when I check 'RUBY_PLATFORM' it shows rails is running with 1.8.7.
How do I tell Rails which ruby environment to use? Strangely, this is not the easiest thing to search for. Probably because I don't know enough about it to form a specific question.
https://rvm.io/rvm/install
Install RVM using these instructions, then you can manage and switch between different Ruby versions and gemsets very easily. Using RVM you can have both 1.8.7 and 1.9.x (or any other version) on your system without having to constantly manually change your path and ruby alias.
Older versions of RVM used the .rvmrc file to automatically switch the ruby within a directory. Newer versions use the .ruby-version file.
To switch between rubies, just type rvm use 2.0.0 or whatever version it is you want to use. For ongoing projects it's a good idea to add the .ruby-version file in the root of the directory that contains the version string you want to use, i.e.
2.0.0
I just finished a project with rails 2.3.8. Client won't pay for the migration, so I want to keep it as is.
I want to start a new project, which is to build my own homepage. Want to use similar tools but want to go to rails 3.0.
Can these versions co-exist on the same machine? If yes, what do I need to do? Found few pages online, but not sure they are up-to-date (e.g. about rails 3 beta and rvm).
I'm using rvm and running 2.3.9 on ruby 1.8.7 and 3.0.1 on ruby 1.9.2 and it works quite well. I followed http://rvm.beginrescueend.com/rvm/install/ to get rvm installed and then switched to it with:
rvm use 1.9.2
Then you can install Rails 3 on that rvm, set up your new project and switch back to your system ruby and older rails when you need to with:
rvm use system
It's been a really great way of switching back/forth for me.
Make R3 the default for your system. Then freeze rake rails:freeze:edge RELEASE=2.3.8 applications if you need to develop with old versions
With rvm you can also use different gemsets with the same ruby installation:
http://rvm.io/gemsets/basics/