我正在做一個專案,需要使用預提交。在進行了小的代碼更改后,我嘗試提交更改(在我的本地 git 存盤庫中)。我收到以下錯誤:
dmk@DESKTOP-I1DLS2O:~/Markus$ git commit -m "Removed Grouping#marking_completed?"
[INFO] Installing environment for https://github.com/rubocop/rubocop.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('gem', 'build', 'rubocop.gemspec')
return code: 1
expected return code: 0
stdout:
Executable `ruby` not found
stderr: (none)
Check the log at /home/dmk/.cache/pre-commit/pre-commit.log
這是日志:
版本資訊
pre-commit version: 2.19.0
git --version: git version 2.25.1
sys.version:
3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0]
sys.executable: /usr/bin/python3
os.name: posix
sys.platform: linux
錯誤資訊
An unexpected error has occurred: CalledProcessError: command: ('gem', 'build', 'rubocop.gemspec')
return code: 1
expected return code: 0
stdout:
Executable `ruby` not found
stderr: (none)
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/pre_commit/error_handler.py", line 73, in error_handler
yield
File "/usr/local/lib/python3.8/dist-packages/pre_commit/main.py", line 361, in main
return hook_impl(
File "/usr/local/lib/python3.8/dist-packages/pre_commit/commands/hook_impl.py", line 238, in hook_impl
return retv | run(config, store, ns)
File "/usr/local/lib/python3.8/dist-packages/pre_commit/commands/run.py", line 414, in run
install_hook_envs(to_install, store)
File "/usr/local/lib/python3.8/dist-packages/pre_commit/repository.py", line 223, in install_hook_envs
_hook_install(hook)
File "/usr/local/lib/python3.8/dist-packages/pre_commit/repository.py", line 79, in _hook_install
lang.install_environment(
File "/usr/local/lib/python3.8/dist-packages/pre_commit/languages/ruby.py", line 133, in install_environment
helpers.run_setup_cmd(
File "/usr/local/lib/python3.8/dist-packages/pre_commit/languages/helpers.py", line 51, in run_setup_cmd
cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/pre_commit/util.py", line 146, in cmd_output_b
raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('gem', 'build', 'rubocop.gemspec')
return code: 1
expected return code: 0
stdout:
Executable `ruby` not found
stderr: (none)
其他資訊:我正在做一個 Rails 專案。我正在使用 WSL 2。我正在使用 Docker。
如果您需要任何其他資訊,請告訴我。
uj5u.com熱心網友回復:
看來您的 linux 安裝沒有 ruby?? 可執行檔案(pre-commit當前需要 whenlanguage_version沒有為language: ruby鉤子指定)
您可以通過以下方式在 ubuntu/debian 上安裝一個sudo apt install ruby-dev
免責宣告:我創建pre-commit
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/471096.html
標籤:轨道上的红宝石 红宝石 预提交钩子 预提交 pre-commit.com
