I have currently moved to a appplication on rails 2.3.4 and ruby 1.8.7 using rvm.
There are a no of gems installed in the app.When i do gem install gem_name ,it installs it but iam not sure whether the gem version is compatible with my app.The gem versions are not specified in case of many gems listed config/environment.rb.Iam unable to figure out ,how to install the correct version as unable to run the application till now. Any suggestions are welcome..
To provide true gem-consistency in your app, you should consider use Bundler to manage these dependencies. The Gembundler site has a good guide on setup for rails 2.x apps.
Once you have your dependencies in bundler, you can start to work out what is compatible and what isn't. In the case of third-party gems, you can search for them on the RubyGems site, and work out which version was the last to be released before Rails 3.x was released. Of course most gems will just work, but any breaking gems will possibly need to run an older version.
I would use Bundler, and add the gems to the Gemfile. Here is the syntax to use a specific version:
gem 'gem-name', '1.0.4'
Related
I know the question to this is probably very straight forward, but Im a bit new to rails, so please bear with me. I have had rails version 5.1.5 on my Mac and I need to update rails to version 5.1.6 and I'm not able for the life of me to do that.
I tried
`sudo gem install rails -v 5.1.6`
but this gives the error
ERROR: Failed to build gem native extension.
Using gem list gives that I have
rails (5.1.5, 5.1.4)
I also tried bundle update rails
I keep getting Could not locate Gemfile
What am I doing wrong??
gem is the native package manager for Ruby.
Bundler (bundle) is a gem to manage bundles of gems via a Gemfile.
I recommend you use a version manager for Ruby like rvm, rbenv or chruby and also install xcode and the commandline-tools package of xcode. Some gems have dependencies written in C that need to be configured and compiled, all of that and some more comes with xcode.
I currently have Ruby 2.2.6 and Rails 5.0.1 installed on my Windows 10 machine. I have cloned an existing project that has the following settings included in its Gemfile:
# Lock-in Lang and Framework:
ruby '2.2.0'
gem 'rails', '4.2.0'
I'm having a surprisingly hard time figuring out how to get Ruby 2.2.0 and Rails 4.2.0 installed. Ruby has good documentation of different installation options, but I think I've exhausted the Windows options without any success. Here are a couple I tried:
Installers: I couldn't find an option for downloading either from RailsInstaller, RubyInstaller, and Bitnami.
RVM: I tried (unsuccessfully) following this blog post to install cygwin so that I could use RVM, but then saw in the comments that the author now recommends spinning up a linux VM rather that using this method.
Pik and Uru: It appears Pik is no longer maintained, and I couldn't figure how to download new versions and ruby and rails with Uru as opposed to managing already downloaded versions.
EDIT: I also tried simply changing the version numbers for ruby and rails in the Gemfile to 2.2.6 and 5.0.1. When I do this I (very understandably) get a message when I try to use a rails command saying I need to run bundle update rails. When I run that rails update I get the following error: Bundler could not find compatible versions for gem "rack". I've done some googling on that option, and it looks like resolving that issue might be possible but requires some more involved tinkering with my Gemfile configuration.
I think my next option is to install Ruby from the source, but I wanted to throw a question up here first to make sure I'm not missing an easier method. So my question is - is it really this hard to get an older minor release of ruby and rails installed on Windows? I realize that the majority of users are probably looking for the most recent release, but it doesn't seem to me that my use case is terribly unique.
The oldest available Ruby 2.2.x via RubyInstaller is 2.2.1
So, the answer to your question is, "Yes, you'll have to build from source."
But then again,
v2.x of gem "rack" requires at least Ruby v2.2.2
And depending on what other gems are included in your Gemfile, you'll still have to reconfigure your Gemfile to get this app running.
So the best solution is probably to use the latest patch version of Ruby 2.2.x and lock rails to 4.2.x. (The app may not be compatible with Rails 5.x)
# Lock-in Lang and Framework:
ruby '2.2.6'
gem 'rails', '~> 4.2'
Then run bundle install to install all the gems required by the Gemfile
i have a project of rails with versions ruby 1.8.7, gems 1.3.6, rails 2.3.5
I want to update the project to the current version can you guys please give the picture how to update older rails applications to current version....
thank you..
RVM and Bundler with the use of a gemfile is helpful in the situation you are in.
RUBY Versioning
Install Ruby Version Manager (pay careful instructions to how to install)
Installation documentation for RVM is here https://rvm.io/rvm/install/
once installed download the version of RUBY you want to use
rvm install 1.9.3 or rvm install 1.8.7
afterwards type in RVM use 1.8.7 and it will set your system to use the older version
Gem Versioning
Apparently you can install the gems in rails 2 by using the rake command
enter in rake gems:install
Your code to config gems are located in the config/environment.rb
There is a helpful tool called "Bundler" which is a gem that easily lets you manage your gem version through the use of a file called a "gemfile". I think the link below is a good resource on how to upgrade your Rails 2 project
http://llamarada-cinetica.heroku.com/blog/2011/02/14/using-gemfiles-on-rails
with RVM and gem configuration you can upgrade gems as needed and check if it works with your build.
(others please correct me if i'm wrong I've only been on rails for a short while)
My suggestion is If your client want you to update the project you can update else extend the application features with older version of Rails because lots of features will break if you upgrade to new Rails version.
And your question is not suitable to ask in Stackoverflow.
I have rails (2.3.5) and prawn (0.12.0) installed. When I install prawnto, gem installs rails version 3.2.6 also.
The dependency of prawnto is:
prawn >= 0
rails >= 2.1
Why gem install Rails 3.x when the prawnto dependency is already there?
tl;dr Use Bundler. It rocks.
Alright, this is basically down to how dependency resolution works in RubyGems. If you're not terribly familiar with it, get up to speed real quick like with the Primer panel from this XKCD comic. RubyGems dependency management and the Primer storyline are very similar in terms of complexity.
When a gem specifies a dependency of, say rails >= 2.1, when you go to install that gem, RubyGems conveniently ignores all the gems that you've currently got installed and then queries the web API to find the absolute latest version of Rails that's greater than or equal to 2.1.
It will find, as of this writing, version 3.2.6, and so will dutifully install that version of Rails because it fits the dependency requirements. It will also install every single dependency of Rails, and their dependencies, and the sub-sub-sub-sub-dependencies all the way down until there's not a gem left without a dependency installed.
I won't go into exactly how that works because it makes my vision go blurry when I think about it.
Now, if you were using something that's not pure-RubyGems such as Bundler, you'd be able to have a Gemfile like this:
source 'http://rubygems.org'
gem 'rails', '2.3.4'
gem 'prawnto', '0.1.1'
And then run bundle install and then something magical will happen. Bundler will figure out the dependencies for all the gems specified in the Gemfile, as well as the gems that they depend on, and then install only those gems.
This means that if you have prawnto wanting Rails >= 2.1, it won't install 3.2.6 because there's another dependency saying that Rails must precisely be 2.3.4. So therefore Rails 2.3.4 will be installed.
If you have conflicting versions, with a gem A specifying a dependency on gem B of ~> 1.0, but then gem C specifying a dependency that gem B must be '= 0.5.0', Bundler won't be very happy and will raise an error because the dependencies can't be resolved.
I'd really recommend using Bundler for all your Rails projects. Even those that are running on Rails 2. There's a page on the Bundler website which will get you started with a Rails 2.3 project and Bundler.
I am newbie to Rails development and working with Spree Commerce bitnami Stack VM instance. I am trying to install spree extension and the instructions says to make configuration changes to application Gem file which I cannot find in the webserver directory
Running Rails 2.3.5
Spree 0.9.4 version
The reason why you can't find it because Gemfile is a standard from Rails 3+ and you're using a Rails2 app. Rails3 uses Bundler which takes cares about all Gems for your app.
In Rails 2 gem dependency definition is different. It doesn't have Bundler so "bundle install" also won't work in your case.
Instead you need to add Gem dependency to config/environment.rb like this:
config.gem 'your_gem_name_here'
also you need to install the Gem manually, so not like in Rails3 where Bundler installs it. Use this in shell:
gem install your_gem_name
In general it's a good idea to update the app to Rails3, I'd recommend it because as I saw this Gem you wanna use doesn't have earlier release.