[sanorian@Elliot Ruby]$ sudo rails new blog
create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create .gitattributes
create Gemfile
run git init -b main from "."
Initialized empty Git repository in /home/sanorian/Documents/Projects/Ruby/blog/.git/
create app
create app/assets/config/manifest.js
create app/assets/stylesheets/application.css
create app/channels/application_cable/channel.rb
create app/channels/application_cable/connection.rb
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/jobs/application_job.rb
create app/mailers/application_mailer.rb
create app/models/application_record.rb
create app/views/layouts/application.html.erb
create app/views/layouts/mailer.html.erb
create app/views/layouts/mailer.text.erb
create app/assets/images
create app/assets/images/.keep
create app/controllers/concerns/.keep
create app/models/concerns/.keep
create bin
create bin/rails
create bin/rake
create bin/setup
create Dockerfile
create .dockerignore
create bin/docker-entrypoint
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/cable.yml
create config/puma.rb
create config/storage.yml
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/assets.rb
create config/initializers/content_security_policy.rb
create config/initializers/cors.rb
create config/initializers/filter_parameter_logging.rb
create config/initializers/inflections.rb
create config/initializers/new_framework_defaults_7_1.rb
create config/initializers/permissions_policy.rb
create config/locales
create config/locales/en.yml
create config/master.key
append .gitignore
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create lib
create lib/tasks
create lib/tasks/.keep
create lib/assets
create lib/assets/.keep
create log
create log/.keep
create public
create public/404.html
create public/422.html
create public/500.html
create public/apple-touch-icon-precomposed.png
create public/apple-touch-icon.png
create public/favicon.ico
create public/robots.txt
create tmp
create tmp/.keep
create tmp/pids
create tmp/pids/.keep
create tmp/cache
create tmp/cache/assets
create vendor
create vendor/.keep
create test/fixtures/files
create test/fixtures/files/.keep
create test/controllers
create test/controllers/.keep
create test/mailers
create test/mailers/.keep
create test/models
create test/models/.keep
create test/helpers
create test/helpers/.keep
create test/integration
create test/integration/.keep
create test/channels/application_cable/connection_test.rb
create test/test_helper.rb
create test/system
create test/system/.keep
create test/application_system_test_case.rb
create storage
create storage/.keep
create tmp/storage
create tmp/storage/.keep
remove config/initializers/cors.rb
remove config/initializers/new_framework_defaults_7_1.rb
run bundle install
Don't run Bundler as root. Installing your bundle as root will break this application for all non-root users on this machine.
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Bundle complete! 14 Gemfile dependencies, 82 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
run bundle lock --add-platform=x86_64-linux
Writing lockfile to /home/sanorian/Documents/Projects/Ruby/blog/Gemfile.lock
run bundle binstubs bundler
rails importmap:install
<internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require': cannot load such file -- json (LoadError)
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache/json.rb:49:in `init!'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache/json.rb:42:in `install!'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache.rb:34:in `setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap.rb:68:in `setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap.rb:112:in `default_setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/setup.rb:5:in `<top (required)>'
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /home/sanorian/Documents/Projects/Ruby/blog/config/boot.rb:4:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
rails turbo:install stimulus:install
<internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require': cannot load such file -- json (LoadError)
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache/json.rb:49:in `init!'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache/json.rb:42:in `install!'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache.rb:34:in `setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap.rb:68:in `setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap.rb:112:in `default_setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/setup.rb:5:in `<top (required)>'
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /home/sanorian/Documents/Projects/Ruby/blog/config/boot.rb:4:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
[sanorian@Elliot blog]$ bin/rails server
<internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require': cannot load such file -- json (LoadError)
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache/json.rb:49:in `init!'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache/json.rb:42:in `install!'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache.rb:34:in `setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap.rb:68:in `setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap.rb:112:in `default_setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/setup.rb:5:in `<top (required)>'
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /home/sanorian/Documents/Projects/Ruby/blog/config/boot.rb:4:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
[sanorian@Elliot blog]$ sudo bin/rails server
<internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require': cannot load such file -- json (LoadError)
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache/json.rb:49:in `init!'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache/json.rb:42:in `install!'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/compile_cache.rb:34:in `setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap.rb:68:in `setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap.rb:112:in `default_setup'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.18.3/lib/bootsnap/setup.rb:5:in `<top (required)>'
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from <internal:/usr/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
from /home/sanorian/Documents/Projects/Ruby/blog/config/boot.rb:4:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
我只是想学习 ruby on Rails 和 ruby,但我不知道该怎么做。我使用启动项目,由
rails new blog
创建,官方指南中是这么说的
https://guides.rubyonrails.org/getting_started.html。我无法通过bin/rails server
运行它
这是我做的。我添加了 ruby gem 的路径变量,将 require 'json' 添加到 config/boot.rb 并将 `gem 'json' 添加到 Gemfile