May be this is just a simple error but since I am Rails noobie any help to my problem will be greatly appreciated.
I have been facing the following error everytime I start the rails server.
I am using Ruby 2.6 and Rails 4.2
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.0/lib/active_support/core_ext/object/duplicable.rb:85: warning: BigDecimal.new is deprecated; use BigDecimal() method instead.
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.0/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.2.0/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
Exiting
Traceback (most recent call last):
bin/rails: stack level too deep (SystemStackError)
Rails 4.2 does not support Ruby 2.6. You should be using Ruby 2.4 for Rails 4.2, as support for Ruby 2.4 was explicitly added in Rails 4.2.8.
If you wish to use Ruby 2.6 you'll want to use Rails 6. Upgrading from Rails 4.2 to 5 to 6 is a complex process so you'll most likely to have an easier time downgrading Ruby rather than upgrading Rails. Running Ruby 2.4 on Windows is an exercise left up to the reader, though.
You can read more about the compatibility between Ruby and Rails versions in this answer.
Related
I have started a project to update, which was updated also a couple of months ago, but today it's not running on the development, I have deleted Gemfile.lock and reinstall the gems & update the bundler but showing still.
Here are below I have attached the full specification of this project.
// Environment
$ ruby -v
- ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin20]
$ rails -v
- Rails 5.2.6
$ bundle -v
- Bundler version 2.2.31
macOS v12.0.1
When running the rails server it's showing like this below
user#Users-MacBook-Pro max-domain % rails server
=> Booting Puma
=> Rails 5.2.6 application starting in development
=> Run `rails server -h` for more startup options
Exiting
/Users/user/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-5.2.6/lib/active_record/type/adapter_specific_registry.rb:9:in `add_modifier': wrong number of arguments (given 3, expected 2) (ArgumentError)
.........
....
I don't even find any clue where can I fix that!
Would you please help me out with that?
Thanks
If you want Ruby 3.0.1 you need to be on Rails 6.1 (and above). Max ruby version for Rails 5.2 is 2.7.0.
Here's a compatibility table.
Did anyone resolve this issue with Ruby 2.7.0?
I used rbenv and installed Ruby v2.7.0 and then created a Rails project using Rails v6.0.2.1.
Currently, by running one of
rails s
rails s -u puma
rails s -u webrick
the server is up and the site is served but in the Console log I see two warning messages:
local:~/rcode/rb27$ rails s
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
=> Run `rails server --help` for more startup options
.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/static.rb:110: warning: The called method `initialize' is defined here
Puma starting in single mode...
* Version 4.3.1 (ruby 2.7.0-p0), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://127.0.0.1:3000
* Listening on tcp://[::1]:3000
So, the warning messages are:
**.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call**
**.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/static.rb:110: warning: The called method `initialize' is defined here**
I saw this link and there are some suggestion to switch of warnings like "If you want to disable the deprecation warnings, please use a command-line argument -W:no-deprecated or add Warning[:deprecated] = false to your code." but I was thinking on little bit better solution/fix for actionpack v6.0.2.1
To suppress warnings like:
warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
For now, simply prefix/pass the RUBYOPT environment variable to your rails commands:
RUBYOPT='-W:no-deprecated -W:no-experimental' rails server
or
RUBYOPT='-W:no-deprecated -W:no-experimental' rails db:migrate
This may not work with earlier versions of ruby.
For backward compatibility with earlier versions of ruby prefix it with RUBYOPT='-W0' instead.
example:
RUBYOPT='-W0' bundle exec rspec
If you don't want to prefix this each time you run a command, then simply add this to the last line of your .zshrc or .bashrc (whatever you're using):
export RUBYOPT='-W:no-deprecated -W:no-experimental'
or
export RUBYOPT='-W0'
Also see last point of the notes here:
https://rubyreferences.github.io/rubychanges/2.7.html#warning-and-
Update to Rails 6.0.3, they fixed the warnings.
If you still get warnings, it's other libraries (see if there are fixed versions or submit a patch) or your own code (how to fix it).
Obviously it will take some time to for ruby team to remove all this warning in next ruby version. For now the command in your terminal
`RUBYOPT='-W:no-deprecated' rails s`
on my basic, plain new rails 6.0.2.1 && ruby 2.7.0 project remove these two warnings lines above in a question.
Also, with command
RUBYOPT='-W:no-experimental' rails s
you will hide warnings about experimental features.
You can combine these two in one command like:
RUBYOPT='-W:no-deprecated -W:no-experimental' rails s
However, I tried these commands inside my old project built with rails 5.2 and ruby 2.6.4 later upgraded to rails 6.0.1 and they didn't worked well on for all warnings messages I got from different rails Active* modules and ruby gems.
Probably we will need some time for upgrading code and gems for new latest stuff.
When I'm trying to run my rails server from RubyMine IDE, I get the error:
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
ExitingTraceback
I'm currently running Ruby 2.5.5p157 with Rails 4.2.7.1. What should I do in order to run the web app? Thank you very much for your help!
Full log when attempting to run the website:
C:\Ruby25-x64\bin\ruby.exe "C:/Users/Sam/Desktop/Takai/Website/bin/rails" server -b 127.0.0.1 -p 3000 -e development -b 0.0.0.0
=> Booting WEBrick
=> Rails 4.2.7.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
ExitingTraceback
(most recent call last):
C:/Users/Sam/Desktop/Takai/Website/bin/rails: stack level too deep (SystemStackError)
Process finished with exit code 1
You are using an old version of Rails with a newer version of Ruby and Rails wants to use something (Fixnum) that doesn't exist anymore in the new version of Ruby.
You have two options:
Use a version of Ruby that is supported by your old version of Rails. According to this list Ruby 2.4 should work for you.
Update your Rails application to a newer version of Rails that supports Ruby 2.5. Rails 5.1 seems to be the first version of Rails which officially supports Ruby 2.5
The first option is probably much easier. But I still suggest updating your Rails version because your Rails version is unmaintained and will not get any updates or security anymore.
All,
After upgrading my Ruby to 2.5.1 and Rails version to 4.2.5, when I try to start my rails server I get the following message below and it crashes. I've seen a couple of links about the error, but those didn't prevent the rails server from starting up. Is there another way besides upgrading to 5.0.2? Also my Gem version is 2.7.6.
rails server
=> Booting WEBrick
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
/usr/local/lib/ruby/gems/2.5.0/gems/activesupport-4.2.5/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
/usr/local/lib/ruby/gems/2.5.0/gems/activesupport-4.2.5/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
Exiting
Traceback (most recent call last):
You can try using an earlier version of ruby. I'm on rails 4.2.7.1 with ruby 2.3.1 and all is fine.
Alternatively, and according to this issue on Github, you can upgrade to rails 4.2.8 or higher for ruby 2.4 (and presumably higher) support.
This must be a simple question, but I could not find the answer by browsing this forum.
When I check rails version, it shows version 3.2.8
user#domain.com [~/rails_apps]# rails -v
Rails 3.2.8
user#domain.com [~/rails_apps]#
But when I start the server, it runs version 2.3.11
user#domain.com [~/rails_apps/myapp]# script/server -p12011
=> Booting Mongrel
=> Rails 2.3.11 application starting on http://0.0.0.0:12011
/home3/user/rails_apps/myapp/config/environment.rb:45: warning: already initialized constant RAILS_ENV
NOTE: SourceIndex.new(hash) is deprecated; From /usr/lib64/ruby/gems/1.8/gems/rails-2.3.11/lib/rails/vendor_gem_source_index.rb:100:in `new'.
=> Call with -d to detach
=> Ctrl-C to shutdown server
What am I doing wrong?
If you application is a 2.x rails application, you need to complete some changes before upgrade to 3.x
You may have a look to railscast http://railscasts.com/?tag_id=27
On the other hand, you may want to upgrade your ruby to 1.9 using rvm
rails 3.x work better with ruby 1.9
Try following in your environment.rb
RAILS_GEM_VERSION = '3.2.8' unless defined? RAILS_GEM_VERSION
Check your Gemfile and make sure it is pointing to rails 3.2.8
Then run bundle or bundle update
I wonder if this is an old app, built originally upon rails 2.3.1 and periodically upgraded insitu. Instead of script/server, try rails server
And make sure your Gemfile contains reference to rails 3.2.8