I am using authlogic gem. I was following the railscasts video for help
http://railscasts.com/episodes/160-authlogic?autoplay=true
I run into a problem when I do the
sudo rake gems:install
it gives me an error :
at /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
rake aborted!
(eval):1:in `define_callbacks': compile error
(eval):1: syntax error, unexpected tEQ, expecting '\n' or ';'
... def self.terminatorresult == false(*methods, &block) ...
^
I tried uninstalling the rake gem and installing it again.
I tried going to a lower version of rake and that also did not work.
What should I do here?
Do I need to edit the rake gem
and include this in there..
base.define_callbacks :persist, :terminator => "result == true"
I found the above on
http://pastebin.com/Q3eL53ZJ
If yes then how?
If there is a better solution then please guide me.
Make sure you are not trying to use the master branch with Rails 2.x it is only compatible with Rails 3.x.
Use the rails2 branch if you are on Rails 2.x, I actually just used an older version since I wanted to just maintain some legacy site without too much concern about upgrading gems. I used version 2.1.5 and it worked fine.
Good luck!
To fix this, I first removed all my authlogic gems:
gem uninstall authlogic
I'm using rails 2.3.15 because that is what hostgator is using. The authlogic version that matches is 2.1.3, so I added this to config/environment.rb:
config.gem "authlogic", :version => '2.1.3'
Then did rake gems:install. Afterwards, a script/generate controller user_sessions command actually generated the user_session.rb in model.
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.
I am using rails 4.1.4, ruby 2.1.2 and rvm.
Gemfile (extract)
gem 'rails-perftest'
gem 'ruby-prof', group: :test
I installed ruby using these commands (in order to apply patch which enables memory profiling)
rvm get stable
rvm reinstall 2.1.2 --patch railsexpress
But still no luck and memory reports are empty with rake test:benchmark or rake test:profile
I was trying to get the same Ruby patch and version working with a Rails 3 benchmark and that was broken too, albeit in a different way. It looks to me like this is an oversight in Rails. I'm seeing this warning string on a Rails 3.2 app
$ bundle exec rake test:benchmark
Update your ruby interpreter to be able to run benchmarks.
$ bundle exec rails -v
Rails 3.2.21
The problem seems to be that ActiveSupport 3.2 isn't aware of Ruby versions higher that 2.0 for this particular piece of code
if RUBY_VERSION.between?('1.9.2', '2.0')
require 'active_support/testing/performance/ruby/yarv'
elsif RUBY_VERSION.between?('1.8.6', '1.9')
require 'active_support/testing/performance/ruby/mri'
else
$stderr.puts 'Update your ruby interpreter to be able to run benchmarks.'
exit
end
see https://www.omniref.com/ruby/gems/activesupport/3.2.12/symbols/ActiveSupport::Testing::Performance::Metrics::CpuTime#line=145
After editing the version check manually I can confirm that the patch does work in Rails 3 with version 2.1.2. Perhaps you could check your RUBY_VERSION and RUBY_ENGINE constants for anything unusual?
(I understand this isn't really an answer but I don't have enough reputation to comment. Also it hopefully rules out the rvm patch and ruby-prof as a problem)
I installed rails 3.2.3 in my pc but for my new project i need to work in rails 3.0.5 so I installed 3.0.5 version of rails and now when i write any rake command i get the following error
rake aborted! ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
currently this rake version is installed in my pc rake (10.1.0)
I know the error says everything but im new in ruby and rails. So i don't understand what to do. I googled it but most of the solutions ask to update rails
I know the error says everything but im new in ruby and rails. So i don't understand what to do. I googled it but most of the solutions ask to update rails
That's unfortunately the best solution. You are using a very old version of Rails that was based on some conventions of the time. Rake has changed and 10.0 is no longer compatible with that Rails version.
You should install a previous rake version. 0.9.0 should be sufficient.
In your Gemfile set
gem 'rake', '0.9.0'
then run $ bundle. Make sure you will prefix every command with
bundle exec
such as
bundle exec rake -T
instead of
rake -T
otherwise the script will fall back again using the most recent version of Rails on your machine.
For your reference, the reason of the error is probably caused by the documentation.rake file that at the very beginning it includes a deprecated rake file, removed in GH-1301.
Keep in mind that, assuming the app will then run, your first goal should be to upgrade your app. In fact, if you try to use it as it is, it's likely you will encounter so many other incompatibilities.
That was fairly simple to debug (assuming you have a reasonable knowledge of Ruby and Rails internals), but others may be harder or even impossible to fix forcing you to nothing else than upgrade.
first of all I'm really not really friendly with ruby or with rails, so I got few issue when i try to install redmine.
In fact i have to type a rake commande :
rake generate_session_store
And server answers me :
"Could not find rails (=2.3.14) amongst [actionmail-2.3.11, actionmailer-2.3.5, actionpack..."
So i checked my rails version and i see that I got 2.3.11, I update it with gem, retry rake but the same error happends, I check again my rails version.
Suprise ! It's still 2.3.11.
I'm running on debian 6 with ruby 1.8.7, gem 1.8.19
What should i do ? Thx.
Have you tried this ?
gem install rails -v 2.3.14
I'm running on Rails 3.1.1 and ruby 1.9.2 on Mac OS and just started a new project where I want to use gettext for translations.
I followed every step when using fast_gettext described here: https://github.com/grosser/gettext_i18n_rails
The installation and everything works find. But when I try to rake gettext:find I get this error message:
$ bundle exec rake gettext:find
rake aborted!
undefined method `add' for "/Users/Olaf/.rvm/gems/ruby-1.9.2-p0":String
Tasks: TOP => gettext:find
I also have to use bundle exec when performing any kind of rake task, I have the problem described here:
rake db:create Not working
Maybe that is related.
Has anyone an idea what is going on? I'm a bit desperate, sitting here since hours trying to figure it out. Google doesn't deliver any hints.
Thanks!
Olaf
I was having similar issues. I believe it comes down to an incompatibility between gettext and more recent versions of RubyGems (1.8+). There is a pull request that addresses this issue, but unfortunately it hasn't been merged yet.
In the meantime you can try adding the fork (and the commit that resolves the issue) as a dependency in your Gemfile:
group :development do
gem 'gettext', git: 'https://github.com/cameel/gettext.git', ref: 'c3a8373'
gem 'ruby_parser'
gem 'locale'
end
Install
gem 'gettext', '>=3.0.2'
As it is specified on https://github.com/grosser/gettext_i18n_rails#optional