I have attempted to upgrade from rails 4.2 to 5. my ruby version and rails version are now both upgraded, and I've attempted to run through what I believe to be most of the upgrade steps. When I run rails server, the server will boot up but when I access localhost:3000, the browser throws an error.
The odd thing is that the terminal/log does not throw any error at all. I see this in the log:
iMac:appDirectory name$ rails server
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from block in <top (required)> at /Users//.rvm/gems/ruby-2.4.0#global/gems/gretel-3.0.8/lib/gretel/deprecated/default_style_key.rb:10)
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from block in <top (required)> at /Users//.rvm/gems/ruby-2.4.0#global/gems/gretel-3.0.8/lib/gretel/deprecated/show_root_alone.rb:11)
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from block in <top (required)> at /Users//.rvm/gems/ruby-2.4.0#global/gems/gretel-3.0.8/lib/gretel/deprecated/yield_links.rb:19)
DEPRECATION WARNING: Accessing mime types via constants is deprecated. Please change `Mime::HTML` to `Mime[:html]`. (called from <class:Request> at /Users//.rvm/gems/ruby-2.4.0#global/gems/web-console-2.2.1/lib/web_console/request.rb:7)
DEPRECATION WARNING: Accessing mime types via constants is deprecated. Please change `Mime::TEXT` to `Mime[:text]`. (called from <class:Request> at /Users//.rvm/gems/ruby-2.4.0#global/gems/web-console-2.2.1/lib/web_console/request.rb:7)
DEPRECATION WARNING: Accessing mime types via constants is deprecated. Please change `Mime::URL_ENCODED_FORM` to `Mime[:url_encoded_form]`. (called from <class:Request> at /Users//.rvm/gems/ruby-2.4.0#global/gems/web-console-2.2.1/lib/web_console/request.rb:7)
=> Booting WEBrick
=> Rails 5.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
[2017-02-26 00:51:50] INFO WEBrick 1.3.1
[2017-02-26 00:51:50] INFO ruby 2.4.0 (2016-12-24) [x86_64-darwin15]
[2017-02-26 00:51:50] INFO WEBrick::HTTPServer#start: pid=xxxxx port=3000
Started GET "/" for ::1 at 2017-02-26 00:51:57 -0600
I believe this may just be something dumb i'm forgetting (and not relevant to the rails 5 upgrade at all) but I'm a bit stumped as I can't see any error messages even though localhost:3000 throws:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
thanks for any assistance...
Updating web-console gem as per Shabini's comment did the trick.
Related
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.
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.
I'm new in rails. I follow the tutorial on the web of rails. After install sqlite3, I try start the server, but I can't. the terminal show me this code
invitado#Home:~/blog$ bin/rails server
=> Booting Puma
=> Rails 5.2.2 application starting in development
=> Run `rails server -h` for more startup options
/usr/lib/ruby/vendor_ruby/rack/mime.rb:54: warning: already initialized constant Rack::Mime::MIME_TYPES
/var/lib/gems/2.3.0/gems/rack-2.0.6/lib/rack/mime.rb:49: warning: previous definition of MIME_TYPES was here
/usr/lib/ruby/vendor_ruby/rack/file.rb:15: warning: already initialized constant Rack::File::ALLOWED_VERBS
/var/lib/gems/2.3.0/gems/rack-2.0.6/lib/rack/file.rb:17: warning: previous definition of ALLOWED_VERBS was here
/usr/lib/ruby/vendor_ruby/rack/file.rb:16: warning: already initialized constant Rack::File::ALLOW_HEADER
/var/lib/gems/2.3.0/gems/rack-2.0.6/lib/rack/file.rb:18: warning: previous definition of ALLOW_HEADER was here
/usr/lib/ruby/vendor_ruby/rack/response.rb:23: warning: already initialized constant Rack::Response::CHUNKED
/var/lib/gems/2.3.0/gems/rack-2.0.6/lib/rack/response.rb:26: warning: previous definition of CHUNKED was here
Exiting
/var/lib/gems/2.3.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:76:in `block in load_missing_constant': uninitialized constant Rack::Session::Abstract::Persisted (NameError)
from /var/lib/gems/2.3.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in without_bootsnap_cache
and so on with a lot of lines. If anyone can help me I appreciate it. Thank you!
A better choice is to install rvm or rbenv to handle your ruby/gems versions for your app.
Just follow this link http://railsapps.github.io/installrubyonrails-ubuntu.html
I think it will help you. :)
I cloned a Ruby project called Publify (an open-source blogging platform.) However, when I run rails server, I get the following error (I have copy-pasted the info below the image) >
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from <class:Simple> at /home/ubuntu/workspace/publify-master/lib/i18n_interpolation_deprecation.rb:24)
=> Booting Thin
=> Rails 5.0.3 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
Exiting
/usr/local/rvm/gems/ruby-2.2.2/gems/actionpack-5.0.3/lib/action_controller/railtie.rb:60:in `block (3 levels) in <class:Railtie>': Invalid option key: page_cache_directory= (RuntimeError)
And then a slew of "From:" statements (as seen in the image.)
My open repo is here, if you would like to take a look: https://gitlab.com/AvBloom98/publify. I did some work to update the gems and such, because they were failing before, thus it is not 1-to-1 with the original Publify Github (found here: https://github.com/publify/publify)
The Publify gem is setting up page caching directory in its configuration but page caching has been deprecated and removed from Rails 4.
However, you can put page caching support back by adding actionpack-page_caching gem into the project, as documented in the Rails guides. From this issue I assume the gem will run nicely in Rails 5, too.