运行rails 7任务提示调试控制台

发布于 2025-01-09 10:38:49 字数 2664 浏览 0 评论 0原文

在 Amazon Linux 2 计算机中部署 Rails 7 应用程序时,我注意到正在运行: bundle execrails db:migratebundle execrails edit:credentials 但不能与 bundle execrails c -e production 一起使用,它只是提示 rdb控制台:

[ec2-user@ip-172-31-86-136 current]$ bundle exec rake edit:credentials
/home/ec2-user/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError
/home/ec2-user/production/gw_outsourcing_backend/releases/7/vendor/bundle/ruby/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here
/home/ec2-user/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE
/home/ec2-user/production/gw_outsourcing_backend/releases/7/vendor/bundle/ruby/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:208: warning: previous definition of BUFSIZE was here
/home/ec2-user/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket
/home/ec2-user/production/gw_outsourcing_backend/releases/7/vendor/bundle/ruby/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:504: warning: previous definition of Socket was here
/home/ec2-user/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/aarch64-linux/continuation.so: warning: callcc is obsolete; use Fiber instead
Debug.rb
Emacs support available.

/path/to/my/app/releases/7/config/application.rb:9:module RailsAppName
(rdb:1) 

rails c -e production 将不会运行,因为我必须先创建我的凭据;但我无法创建凭据或迁移数据库,因为它会提示该控制台。

这是我的 Gemfile:

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "2.7.0"
gem 'dotenv-rails'
gem "rails", "~> 7.0.0"
gem 'puma', '~> 4.1'
gem 'pg', '>= 0.18', '< 2.0'
gem 'devise'
gem 'jwt'
# Reduces boot times through caching; required in config/boot.rb
# gem "bootsnap", require: false
gem 'rollbar'
gem 'byebug'
gem 'kaminari'
gem 'mina'

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem "rack-cors"

group :development, :test do
  # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
  gem "debug", platforms: %i[ mri mingw x64_mingw ]
end

group :development do
  # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
  # gem "spring"
end

如何让迁移和凭证编辑命令起作用,为什么控制台会提示?

While deploying a Rails 7 app in Amazon Linux 2 machine i noticed that running:
bundle exec rails db:migrate or bundle exec rails edit:credentials but NOT with bundle exec rails c -e production, It just prompts the rdb console:

[ec2-user@ip-172-31-86-136 current]$ bundle exec rake edit:credentials
/home/ec2-user/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError
/home/ec2-user/production/gw_outsourcing_backend/releases/7/vendor/bundle/ruby/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here
/home/ec2-user/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE
/home/ec2-user/production/gw_outsourcing_backend/releases/7/vendor/bundle/ruby/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:208: warning: previous definition of BUFSIZE was here
/home/ec2-user/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket
/home/ec2-user/production/gw_outsourcing_backend/releases/7/vendor/bundle/ruby/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:504: warning: previous definition of Socket was here
/home/ec2-user/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/aarch64-linux/continuation.so: warning: callcc is obsolete; use Fiber instead
Debug.rb
Emacs support available.

/path/to/my/app/releases/7/config/application.rb:9:module RailsAppName
(rdb:1) 

The rails c -e production won't run because i have to create my credentials first; but i can't create credentials or migrate the database because it prompts that console.

Here is my Gemfile:

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "2.7.0"
gem 'dotenv-rails'
gem "rails", "~> 7.0.0"
gem 'puma', '~> 4.1'
gem 'pg', '>= 0.18', '< 2.0'
gem 'devise'
gem 'jwt'
# Reduces boot times through caching; required in config/boot.rb
# gem "bootsnap", require: false
gem 'rollbar'
gem 'byebug'
gem 'kaminari'
gem 'mina'

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem "rack-cors"

group :development, :test do
  # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
  gem "debug", platforms: %i[ mri mingw x64_mingw ]
end

group :development do
  # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
  # gem "spring"
end

How can I get the migration and credential edit commands to work, and why does that console prompts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

此生挚爱伱 2025-01-16 10:38:49

通过仔细查看 Gemfile,我发现 byebug gem 并不在开发组中。我将其移至开发组,任务开始工作。 byebug gem 在生产中不起作用,因此它失败了,但没有明确输出原因。

吸取教训,不要在生产中使用 byebug

By looking closely to the Gemfile i see byebug gem was not in the development group. I moved it to development group and tasks started working. The byebug gem does not work in production, and so it was failing but not explicitly outputting why.

Lesson learned, do not use byebug in production

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文