SimpleCov failed with exit 1 + google-protobuf - ruby-on-rails

Hi, i'm working on project which has ruby version 2.4.6 and rails version 5.0.2, iv'e implemented rspec_api_documentation and apitome gem for api documentation. I wrote all the test cases and when i run it with simple rspec spec/acceptance/api/v1/notifications/notification_spec.rb command all test cases are passed with 0 failures, however while running command bundle exec rspec spec/acceptance/api/v1/notifications/notification_spec.rb --format RspecApiDocumentation::ApiFormatter for documentation generation it throws an error of SimpleCov failed with exit 1. I did some R&D and found some answers that remove Gemfile.lock and bundle again, when i removed Gemfile.lock and ran the command bundle install it throws error of google-protobuf incompatibility google-protobuf-3.21.5-x86_64-linux requires ruby version >= 2.5, < 3.2.dev, which is incompatible with the current version, ruby 2.4.6p354, if i do bundle update it throws the same error of google-protobuf. now i can't do anything, i can't understand what's the problem and how to fix it, please help me in this.

Related

Ruby on Rails legacy application update generates Gem Psych Alias error Psych::BadAlias

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.

Unable to integrate sqlite3 with ruby and rails

Disclaimer: I checked the FAQs. I have tried Google, Reddit and YouTube and am posting here after exhausting all available options.
I'm using guides.rubyonrails.org to learn. However, SQLite3 has not downloaded on my system, despite following the instructions on the website.
So I typed 'gem install sqlite3' in the command line and it has thrown multiple errors related to mingw32, mingw64 and msys. The commonality of the errors being they are invalid or corrupted databases (PGP signatures).
The final error stated for installing sqlite3 was "failed to build gem native extension" followed by the directory and a suggestion to install it from the net.
I have installed it from sqlite.org and integrated it with the regular command prompt. Here it says "connected to a transient in memory database".
It is not integrated in the command prompt with ruby. Here it says "the term 'sqlite3' is not recognised as the name of a cmdlet, function, script file, or operable program."
I'm using a laptop using Windows 10 and have rails 6.0.3.2 and ruby 2.7.1 installed.
I tried progressing irrespective and my input was 'rails server' on the regular command prompt.
The following lines showed up -
Could not find gem 'sqlite3 (~> 1.4) x64-mingw32' in any of the gem sources listed in your Gemfile.
Run 'bundle install' to install missing gems.
Please advise how to progress or if there's anything I'm missing. Should I persist and try and fix the error in the ruby command prompt or move forward with the regular command prompt? None of them are working for me to progress my learning. Let me know if you require more information.
Thanks for your time and help.
EDIT: Here is the image for when I run gem install sqlite3.
2nd EDIT: Here is what I get when I run 'rails new blog' and 'bundle install' thereafter.
3rd EDIT: Here is the mkmf file where the problem exists as per command prompt.
4th EDIT: I followed the instructions on guides.rubyonrails.org/getting_started.html. I ran 'bundle install' only when it asked me to after I ran 'rails new blog' in the command line.
Similar error regarding mingw32, mingw64 and msys from the first image came up after I ran bundle install in blog. However, this time it stated Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

How to fix win32console message in rake test output?

I'm currently trying to learn Ruby on Rails on Windows 10.
I'm following the excellent railstutorial by Michael Hartl.
However, I'm getting bugged by the 'gem install win32console' message (and lack of colour) appearing when I run rake test. How can I fix this?
Sample output:
$ bundle exec rake test
ansi: 'gem install win32console' to use color on Windows
Started
3/3: [===================================] 100% Time: 00:00:00, Time: 00:00:00
Finished in 0.35885s
3 tests, 6 assertions, 0 failures, 0 errors, 0 skips
My setup:
Base: Ruby 2.2 Rails Installer for Windows.
Running commands using Git Bash.
I also have the minitest-reporters gem installed (step 3.7.1 of tutorial).
What I've tried:
First I ran gem install win32console bu this had no effect, even though the gem is visible when I run gem list.
Then I saw win32console is deprecated so I installed ansicon.
This also had no effect. And it seems colours are supported on Windows 10 anyway.
E.g. I can run the Hello World example puts "\e[34mHello \e[31mWorld\e[0m" found on this blog and it shows blue and red text, whether ansicon is installed or not.
However, colours won't show up correctly in rake test output and I still get the warning.
Hooray got it working!
In the end your comment Jordan plus the suggestions on Paul's Perambulations got me there.
Steps taken, for anyone else stuck on this:
Download and unzip win32console source
Install specific (older) versions of the dependencies:
gem install rake -v 10.4.2
gem install rake-compiler -v 0.9.9 (this is current latest anyway)
gem install hoe -v 3.7.0
Run rake _10.4.2_ gem in the win32console source directory (to use correct version)
Run gem install pkg/win32console-1.3.2.gem (had to change version number and flip the slash around from original instructions)
Add gem "win32console", '1.3.2' to Gemfile
Go back to project directory and run bundle install
Finally run bundle exec rake test - the info message has disappeared and colours are showing correctly!

How to run a specific version of rake

Background:
I get errors whenever I run rake in an older project. (uninitialized constant Rake::DSL).
The rails project in question is an old project that was started with Rails 2.1 (I think), and since then I've updated the OS on my laptop a couple of times, and made updates along the way to make it run.
Right now, the rails app works fine, provided I have RAILS_GEM_VERSION set to 2.3.5. I'm not sure if the app was completely updated to Rails 2.3.5.
There is no Gemfile in my older project.
If I create a brand-new rails project (and unset RAILS_GEM_VERSION), rake runs fine.
My question: To troubleshoot, I'd like to try newer versions of rake. I'd like to know how to force one specific version to be used, since it appears I have multiple versions installed.
Info on my environment:
$ gem list rake
*** LOCAL GEMS ***
rake (0.9.2.2, 0.9.2, 0.8.7, 0.8.3)
$ rake --version
rake, version 0.8.7
So it looks like it's picking up the 0.8.7 version.
All the help files online seem to tell me to specify the rake version in the Gemfile, but there isn't one in this project. (Maybe it predates gemfiles?)
If I unset the RAILS_GEM_ENVIRONMENT variable altogether, and try to run rake, I get:
rake aborted!
can't activate rails (= 2.3.5, runtime) for [], already activated rails-3.2.8 for []
None of the environment config files in my older project set that variable either.
This may be of help. Have you tried the underscore solution?
Example:
rake _0.9.2_
you can run rake specific version by using this
bundle exec rake ...
more detail see this - bundle exec, rake
You can uninstall the current version of rake and install another desired version using commands similar to the following:
gem uninstall rake 12.3.1
gem install rake 10.5.0
(Note: you might need to run as sudo for permissions)
I had a problem where I received the following error while trying to install rake 10.5.0:
Could not find a valid gem '0.8.7' (>= 0) in any repository
I resolved this problem by adding the following line to my Gemfile:
gem 'rake', ' <11.0'
After editing Gemfile I was able to successfully downgrade rake by updating my gems:
bundle update

Rake generate - not working

I am installing redmine1.4 and following these step .
I am in 5 step of installation process
When I am trying to do rake generate_session_store its saying to install rdoc
Please let me know do I really need to create document cant I skip that OR
if I need to create docs then how to install rdoc with proper version .
I am using :
Rails 2.3.14
RubyGems 1.8
ruby 1.8.7
This is not an error message, it's just a naggy warning - your task has probably completed fine (as indicated by the updating of session_store.rb in config/initializers.
This does btw not look like a programming question to me, why not ask on the Redmine forums?
It's just a warning message and you can skip it. Even though you can remove this rdoc message disappear
If you have redmine's trunk version, edit Gemfile and add the following line:
gem "rdoc", ">= 2.4.2
Then run bundle install

Resources