Which Rails version is compatible with which Bundle version - ruby-on-rails

I am trying to establish a rails environment. I can't use the latest version (6) because my computer needs admin rights to install NodeJS and Yarn. So I have to use an older version (say rails v4.2.2).
Trouble is, when I install this, the Bundle doesn't allow me to create a demo (using 'rails new demo'). I have tried various options but always get an error that the Bundle in incompatible.
I did manage one successful combination (rails v4.2.2 and Bundle v1.17.3) but when trying to run the server ('rails server') I get a BigDecimal error. So it seems that combo is not great either.
Essentially, could anyone advise of an installation procedure (with versions) that would lead to a successful server being run?

The most important question is not which bundler version to use but which Ruby version.
Ruby 2.4 unified Fixnum and Bignum to Integer and that change is not supported by old Ruby on Rails versions. At the same time, Ruby on Rails usually requires a minimum Ruby version – for Ruby on Rails 4.2 that was >= 1.9.3.
Therefore I would try Ruby 2.3.8 when I had to run an old Ruby on Rails 4.2 application.
Keep in mind that Rails 4.2 is unmaintained and doesn't get any security updates anymore. I cannot recommend using it anymore. When you only plan to use it as a learning exercises and do not plan to release your application on a public server, it might feel like an old version would still be safe to use. But Rails moves fast, you would learn things that might be done differently on newer version. And upgrading your application later on might be painful too. Therefore I recommend always use the latest available version for Rails when starting a new project.

Looking at my Gemfile.lock, we can safely assume rails (4.2.8) insists on bundler version to be less than 2.x:
rails (4.2.8)
actionmailer (= 4.2.8)
actionpack (= 4.2.8)
actionview (= 4.2.8)
activejob (= 4.2.8)
activemodel (= 4.2.8)
activerecord (= 4.2.8)
activesupport (= 4.2.8)
bundler (>= 1.3.0, < 2.0)

Related

How to fix conflicting requirements installing Nokogiri for Rails on Windows

Recently switched from a Mac to a PC and hit a wall with bundle install.
I get an error but I'm have trouble figuring out what it means and how to fix it. I searched through the GitHub issues and other StackOverflow threads, but none of the fixes suggested help me because they're focused on Linux mostly.
Bundler found conflicting requirements for the Ruby version:
In Gemfile:
Ruby (~> 2.6.5.0)
pg was resolved to 0.21.0, which depends on
Ruby (< 2.5) x64-mingw32
Ruby (< 2.5), which is required by gem 'nokogiri (>= 1.4.1)', is not available
in the local ruby installation
I deleted the Gemfile.lock file which fixed the issue.
The Ruby versions are fine at the project level, I knew this because the server runs on my Mac, so it was a Windows or machine-exclusive issue.
Your version of Ruby is too recent for that project. Downgrade to Ruby 2.4.X or update the gems of the Gemfile.

Could not find 'railties' (= 4.2)

I try to create a new Rails application with Rails 4.2:
$ rails _4.2_ new my_app
I get the following error:
/Users/myuser/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:298:in
`to_specs': Could not find 'railties' (= 4.2) - did find:
[railties-4.2.7.1,railties-4.1.10,railties-4.1.5,railties-4.1.0.beta2]
(Gem::LoadError)
These are the railties I have:
$ gem list | grep railties
railties (4.2.7.1, 4.1.10, 4.1.5, 4.1.0.beta2)
Why is it demanding that I use railties 4.2 and not one of the others I have, such as 4.2.7.1?
gem install railties - it should fix your problem. At least it helped me
You get the error because you have explicitly specified that you want to use the rails executable from the gem with version 4.2 on your command line.
Rubygems doesn't resolve approximate versions here. Instead, you have to specify the exact version you want to use (or omit the version from the command line to use the executable from the newest version of the gem installed.
Thus, you can use
rails _4.2.7.1_ new my_app
or (given that Rails 4.2.7.1 is the newest version of the rails gem installed to your computer), you can also just use
rails new my_app

How to switch back to Rails 5 once the version has been changed?

I can't believe I could not figure this out and I have been spending needlessly too long. I used to use rails v. 5.0.0.1. Somehow when I was cloning apps from railscasts, I switched my rails to 3.1.0. Ever since then everytime I do rails new myApp it created rails v. 3.1.0..
I have a project folder name Project where I store all my rails app. When I typed rails -v in that Project folder, I get
Projects iggy$ rails -v
Rails 3.1.0
I just created new app named demo (rails new demo), and it generated a new app with rails 3.1.0.
When I do gem list, this is what I got:
demo iggy$ gem list --local rails
*** LOCAL GEMS ***
autoprefixer-rails (6.5.3, 6.4.1, 6.4.0.2, 6.3.7, 6.3.6, 6.3.1)
coffee-rails (4.2.1, 4.1.1, 4.1.0, 3.1.1)
factory_girl_rails (4.7.0, 4.6.0, 4.5.0)
haml-rails (0.9.0)
jquery-rails (4.2.1, 4.1.1, 4.1.0, 4.0.4, 3.1.4)
less-rails (2.7.1)
pry-rails (0.3.4)
rails (5.0.0.1, 5.0.0, 4.2.7.1, 4.2.5, 4.2.4, 4.2.3, 3.1.0)
I have tried going to my app that uses rails 5, ran bundle update / bundle install, but whenever I go to Project folder, it always defaults back to rails 3.1.0. I use rvm.
How can I switch back to rails 5.0.0.1 so whenever I create new app it will use latest rails? Moreover in general, is it possible to seamlessly switch between different version of rails app? If so, how can I do that?
You can uninstall Rails, and re-install it, and reinstalling it will convert the version to the latest.
gem uninstall rails
gem install rails # To re-install it.
Edit:
If you do not want to uninstall Rails, you may need to create a new Gemset for using using Rails 5 throughout your project space. Here's how:
rvm gemset create rails-5.0.0
rvm use 2.2.2#rails-5.0.0 --default
Kindly replace 2.2.2 with the Ruby version that you would like to use, but it should be later than 2.2.2.

Gem dependency hell installing redmine with CRM plugins

I was installing a clean Redmine 3.0 with CRM plugin on a fresh install of Ubuntu Server 14.04LTS. I succeeded with redmine and a minor plugin, but the CRM one has hit me with this:
# bundle install --without development test RAILS_ENV=production
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Warning: this Gemfile contains multiple primary sources. Using `source` more
than once without a block is a security risk, and may result in installing
unexpected gems. To resolve this warning, use a block to indicate which gems
should come from the secondary source. To upgrade this warning to an error, run
`bundle config disable_multisource true`.
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "i18n":
In Gemfile:
rails (= 4.2.0) ruby depends on
actionpack (= 4.2.0) ruby depends on
activesupport (= 4.2.0) ruby depends on
i18n (~> 0.7) ruby
money (~> 5.1.0) ruby depends on
i18n (~> 0.6.0) ruby
I installed i18n 0.6.0 and 0.7.0, didn't fix:
# gem list --local | grep i18n
i18n (0.7.0, 0.6.0)
I tried removing the Gemfile.lock and using bundler (bundle update && bundle install) again, same result.
I have no idea how to proceed with this issue. I know very little of ruby, gems and bundler and searching has failed me. Help, please.
You can't use the CRM plugin from redminecrm.com with Redmine 3 right now.
At the time of writing, the plugin is only compatible to Redmine 2.x. While the plugin will probably get updated by the authors, it is not yet compatible with Redmine 3.0.
Generally, you should not expect plugins to magically continue to work across major version updates. Especially when there was a major update recently, many plugins will not yet be compatible to the new Redmine version. If you need the plugins, you might be able to use an older version, e.g. Redmine 2.6, until all the plugins you need are updated.
You always have to check if a plugin is compatible to the Redmine version you intend to use.

rails 2.3.8 and activesupport runtime error

this is the error im getting when i "script/server":
can't activate activesupport (= 3.0.0, runtime) for [], already activated activesupport-2.3.8 for ["rails-2.3.8"]
i THINK whats happening here is that something is trying to call in / active "activesupport" for 3.0.0 ... when the "activesupport" for 2.3.8 is already working?
helps?
thanks!
You need uninstall rails 3.0.0 and activesupport 3.0.0.
You can use some different gemset with rvm by example.
Another solution is using bundler with a specific rails version define inside.
If you use bundler you need launch your server with bundler
bundle exec script/server

Resources