We are using pg_jobs gem for our rails 5 application but now we are trying to upgrade our application with rails 7 ...In that place, we are facing some issues like can't able to bundle the pg_jobs in rails 7 because it's supports the rails 5 only so can't able to run bundle install.
we tried to change the version of pg_jobs gem then also same error we are facing.
This is the error :
**Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (~> 7.0.4)
pg_jobs was resolved to 0.1.0, which depends on
rails (< 6.0, >= 5.1)```
**
The latest version of the pg_jobs gem (as of today) does not even support Ruby on Rails >= 6.0 yet (see Rubygems).
I would consider this gem being abandoned, taking into account that:
only one version of the gem was released ever
the gem does not support any up-to-date Rails version anymore and
the gem's source code didn't get any update in the last 3 years
That means your options are very limited, because it seems unreasonable to expect any updates from the gem's maintainer anymore. And downgrading your application is also not an option because then you were locked to an unsupported Ruby on Rails version.
The only two options I see are:
Fork the gem and update it to Ruby on Rails 7.0 on your own.
Switch to another ActiveJob worker implementation, like Sidekiq.
Forking and taking over maintenance feels like a burden, given that the gem doesn't seem to provide something very special or unique. Therefore, I suggest switching to another gem. Sidekiq is certainly the most popular nowadays, but there are other alternatives like Resque or DelayedJob (see Background Jobs on the Ruby Toolbox) that are worth it being considered depending on your requirements.
Related
Goal: Upgrade legacy app step by step as recommended by the RailsGuides: Upgrading Ruby on Rails (from ruby 2.3.1 and rails 4.2.2)
Expected result: rake assets:precompile completes successfully without a gem psych alias error: Psych::BadAlias
Help needed: Can someone please tell me how to implement the recommended solution: Psych::AliasesNotEnabled: Alias parsing was not enabled. To enable it, pass `aliases: true` to `Psych::load` or `Psych::safe_load` . What is (a) the code and (b) which file does it belong in. Full details follow.
Actual result:
I am updating an application from ruby 2.3.1 and rails 4.2.2: I stepped through major ruby revisions, i.e., 2.4, 2.5, 2.6, and am currently running 2.7.0 I updated rails to ~> 5.0 and then issues with the psych gem arose:
Problem: Running: rake assets:precompile led to: rake aborted! / Psych::BadAlias: Cannot load database configuration / Unknown alias: default / Caused by: Psych::BadAlias: Unknown alias: default / error: Precompiling assets failed
The recommended solution is: Psych::AliasesNotEnabled: Alias parsing was not enabled. To enable it, pass `aliases: true` to `Psych::load` or `Psych::safe_load`
I learned that psych 3.1.0 is a "default gem" (when I tried to delete / reinstall psych since it wasn't in my Gemfile or Gemfile.lock). So, I added gem 'psych', '~> 5.0', '>= 5.0.1' to the Gemfile and installed it, ran bundle install, and then ```rake assets:precompile`` -- which returned the same psych aliases error.
Unfortunately, I don't know how to pass `aliases: true` to `Psych::load` or `Psych::safe_load`
The accepted answer to this SO Q&A was helpful: visit_Psych_Nodes_Alias: Unknown alias: default (Psych::BadAlias)
Adding the recommended module YAML as lib/yaml.rb (the right place?) didn't resolve the issue.
I did more research and discovered a Rails patch: https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017 which noted that rails 5.2.8.1 (among others was "fixed"). So I upgraded to rails 5.2.8.1 and the error persisted.
Then, since the SO Q&A cited above ended with a "Note for Rails users (>= 7.0.3.1)" and the rails patch said rails 7.0.3.1 was a "fixed version", I upgraded to rails 7.0.3.1 and added the recommended code - from the Note - to resolve the psych issue:
# config/initializers/activerecord_yaml.rb
ActiveRecord.use_yaml_unsafe_load = true
It didn't work. rails app:update recommended numerous changes and, when running rake assets:precompile, I get an unrelated sprockets / popper.js error (probably higher in the stack than the psych error). So, I downgraded the app to rails 5.2.8.1 (with ruby 2.7.0) and am again getting the psych alias error when running rake assets:precompile
Hopefully, resolution is as simple as someone telling me how to implement the recommended solution: Psych::AliasesNotEnabled: Alias parsing was not enabled. To enable it, pass `aliases: true` to `Psych::load` or `Psych::safe_load` .
Also, what's a reasonable approach for the step-by-step upgrade of my code. I.e., once this issue is resolved for rails 5.2.8.1 should I skip ahead to the next fixed version (6.0.5.1)? The SO Q&A suggests different versions of psych for different versions of ruby; the issues are also related to different versions of rails.
Thank you in advance for your help. (I've returned to coding after a 3+ year break.)
use a psych version below 4 and it should work again. It's because of a breaking change in PSYCH:load in v4. If you want to use a newer version, aliases: true would be necessary... am also upgrading old rails apps. it started breaking on upgrade rails 5.0 to 5.1
I popped this error when running rails db:seed after updating a legacy Rails app.
Fixed this error by removing gem versions in my gem file and running bundle update
My Faker gem was set to ~> 2.7.0 and wasn't updating with the rest of my app.
It should tell you which gem is causing the YAML parsing error. It's most likely not the PSYCH gem.
How to find out which gems need to be updated in a Rails app if the Ruby version is upgraded?
For example, I would like to know which of my Rails app gems will have to be upgraded if I upgrade my Ruby from 2.1.3 to 2.2.2. The preference would be to keep the changes minimal as to reduce the probability of things breaking.
The important thing would be for this to be a dry-run. So that one can assess the amount of work that an upgrade will require.
I have checked bundle and gem readme's without much luck.
If you update your rails version, it should install or resolve the required dependencies needed to run the new rails version. As far as as the gems you have entered that are NOT dependencys to Rails, you can check gem compatibility on rubygems.org. Just type in the title of your gem in the search bar.
In a my previous question (asked about 2 months ago) I was trying to upgrade Ruby on Rails from version 3.2.13 to 4.0.0, without success because the globalize3 ruby-gem compatibility. Today I'm trying again to do the upgrade, without success because the globalize3 ruby-gem compatibility.
I tried all possible solutions that I found on the web (even those that refer to the rails4 branch) but no one works for me: I get error outputs as-like those present in my previous question. However, as you can read here, it seems that someone (lucky, maybe) has solved the compatibility issue. I am not a "lucky" one and, since I aim to use features added by Rails 4 and still use globalize3, I would like to know if there is someone running Rails 4 and the globalize3 with success. If so, what did he / she made to make that?
What is the compatibility status between globalize3 and Rails 4?
Note: I also opened a issue at github.
I'm using it with rails 4 and have no issue.
In my Gemfile:
gem 'globalize3', github: 'svenfuchs/globalize3', branch: 'rails4'
Run bundle update instead of bundle install to resolve all dependencies again. Just lock gems that you don't want updated by indicating a version specifier as explained here http://bundler.io/v1.3/gemfile.html.
I work at spree app(v. 0.70.5), but I need to install some gem which depends on spree v. 0.70.0. This app already work at production and I don't know can I rollback spree version (to 0.70.0) or not.
How I can solve this problem?
Take a look at the change log between the versions, if nothing jumps at you, try using 0.70.0
gem "spree", "0.70.0"
and test your app
Alternatively you can fork the gem that has dependency on the older version of spree and try to upgrade it
It causes so many deployment issues it's ridiculous. Most of the time I don't care what version of gems are used, just want to use the latest one.
UPDATE in response to comments:
Here are a couple of examples off the top of my head:
developer A is using a pre-release of a gem so when he runs 'bundle update', the Gemfile.lock is messed up for everyone else and if you deploy it, there goes your site.
A bug in a gem gets fixed so we run gem update across our servers, restart rails and yay, bug fixed! Oh, but wait, it's not fixed? Thanks bundler. What should have been an easy fix is now a full code deploy across our servers.
That's just a couple off the top of my head. At least let us decide if we want to lock in gem versions or perhaps at least allow a range of versions for instance any 2.X version.
UPDATE 2: And yet another issue when there are windows developers on the team
Here is what's showing up in a windows Gemfile.lock:
nokogiri (1.4.4)
nokogiri (1.4.4-x86-mingw32)
Wow, this is just awesome. Sure makes for easy teamwork and deployment.
I recommend starting to use two techniques with your development and deployment:
Specify version number of gems in your gemfile.
For example:
gem "rails", "3.0.1"
gem "will_paginate", "~> 3.0.pre2"
This way, when you decide you want to update rails, or will_paginate, change the version numbers in your gemfile.
Only update certain gems
Rather than the generic bundler update command, run
bundler update rails
This will only update the rails gem to the newest version, rather than get the latest of all gems.
If you use both 1 & 2, you'll have a happier experience.
Then, simply, don't check your Gemfile.lock into source control. All of the specific problems you listed are solved.
Of course, you are sacrificing the enormous advantage that Bundler gives you over any other dependencies management system.