开始学习Ruby on Rails。我已经通过RVM安装了Ruby 2.7.0。SQLite3也默认安装在Ubuntu 20.04.3 LTS中。我的Rails版本是7.0.2.2。当我运行命令时:
rails new blog
字符串
从本指南:https://guides.rubyonrails.org/getting_started.html
它抛出一个错误:
lou@lou-VirtualBox:~$ rails new blog
create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create .gitattributes
create Gemfile
run git init from "."
Traceback (most recent call last):
27: from /home/lou/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `<main>'
26: from /home/lou/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `eval'
25: from /home/lou/.rvm/gems/ruby-2.7.0/bin/rails:23:in `<main>'
24: from /home/lou/.rvm/gems/ruby-2.7.0/bin/rails:23:in `load'
23: from /home/lou/.rvm/gems/ruby-2.7.0/gems/railties-7.0.2.2/exe/rails:10:in `<top (required)>'
22: from /home/lou/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
21: from /home/lou/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
20: from /home/lou/.rvm/gems/ruby-2.7.0/gems/railties-7.0.2.2/lib/rails/cli.rb:18:in `<top (required)>'
19: from /home/lou/.rvm/gems/ruby-2.7.0/gems/railties-7.0.2.2/lib/rails/command.rb:48:in `invoke'
18: from /home/lou/.rvm/gems/ruby-2.7.0/gems/railties-7.0.2.2/lib/rails/command/base.rb:87:in `perform'
17: from /home/lou/.rvm/gems/ruby-2.7.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
16: from /home/lou/.rvm/gems/ruby-2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
15: from /home/lou/.rvm/gems/ruby-2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
14: from /home/lou/.rvm/gems/ruby-2.7.0/gems/railties-7.0.2.2/lib/rails/commands/application/application_command.rb:26:in `perform'
13: from /home/lou/.rvm/gems/ruby-2.7.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
12: from /home/lou/.rvm/gems/ruby-2.7.0/gems/thor-1.2.1/lib/thor/group.rb:232:in `dispatch'
11: from /home/lou/.rvm/gems/ruby-2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `invoke_all'
10: from /home/lou/.rvm/gems/ruby-2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `map'
9: from /home/lou/.rvm/gems/ruby-2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `each'
8: from /home/lou/.rvm/gems/ruby-2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `block in invoke_all'
7: from /home/lou/.rvm/gems/ruby-2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
6: from /home/lou/.rvm/gems/ruby-2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
5: from /home/lou/.rvm/gems/ruby-2.7.0/gems/railties-7.0.2.2/lib/rails/generators/rails/app/app_generator.rb:328:in `create_root_files'
4: from /home/lou/.rvm/gems/ruby-2.7.0/gems/railties-7.0.2.2/lib/rails/generators/app_base.rb:134:in `build'
3: from /home/lou/.rvm/gems/ruby-2.7.0/gems/railties-7.0.2.2/lib/rails/generators/app_base.rb:134:in `public_send'
2: from /home/lou/.rvm/gems/ruby-2.7.0/gems/railties-7.0.2.2/lib/rails/generators/rails/app/app_generator.rb:76:in `version_control'
1: from /home/lou/.rvm/gems/ruby-2.7.0/gems/railties-7.0.2.2/lib/rails/generators/rails/app/app_generator.rb:258:in `user_default_branch'
/home/lou/.rvm/gems/ruby-2.7.0/gems/railties-7.0.2.2/lib/rails/generators/rails/app/app_generator.rb:258:in ``': No such file or directory - git (Errno::ENOENT)
型
我找不到与我相关的问题,所以我希望有人能帮助我。
2条答案
按热度按时间sczxawaw1#
我解决了我的问题。看起来它还需要安装git。
ipakzgxi2#
要解决这个问题,请安装
git
。以下是一些背景:
Rails尝试运行
git init from "."
来初始化当前工作目录中的存储库。Rails读取git默认分支,参见this post on superuser.com about the default branch。
要在git > 2.28中配置init.defaultBranch参数,可以运行
git config --global init.defaultBranch main
。不知道你为什么要这样做,但你可以通过使用这些控制台选项跳过这一步:
-G, [--skip-git], [--no-skip-git]
个-p, [--pretend], [--no-pretend]
个查看Rails代码并运行
rails new --help
以了解更多信息。