简体   繁体   中英

Rails new command fails if -m template is applied: "NoMethodError: private method `open' called for URI:Module"

I have been bumping into this issue and could not find a way to fix it.

When I am creating new rails apps using templates , the generator fails on private method 'open' called for URI:Module (NoMethodError)

Either way rails new app_name -m any_template_url or bin/rails app:template LOCATION=http://example.com/template.rb would return the same failure.

This is the terminal print out:

/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/thor-1.2.1/lib/thor/actions.rb:226:in `apply': private method `open' called for URI:Module (NoMethodError)

from /.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/railties-5.2.6/lib/rails/generators/app_base.rb:170:in `apply_rails_template'

from (eval):1:in `apply_rails_template'

for which I understand the issue take place when we try to open the path to the file to execute and when rails tries to apply the template

How do I fix this?

For Rails 5.2 is recommended to use ruby 2.5. Update your ruby version and try again.

Reference: https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM