运行rails 7任务提示调试控制台
在 Amazon Linux 2 计算机中部署 Rails 7 应用程序时,我注意到正在运行: bundle execrails db:migrate
或 bundle 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过仔细查看 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