git diff errors on startup and during push (OD-1409)
Jonathan Simon opened 3 years ago

I'm running the docker container. Here is my compose.

services:
    server:
        container_name: onedev
        restart: unless-stopped
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
            - /media/storage/docker_configs/onedev/:/opt/onedev
        ports:
            - 6610:6610
            - 6611:6611
        image: 1dev/server:latest

On container startup, I get a bunch of errors where git diff is being misused (according to the error).

Launching a JVM...
WrapperManager: Initializing...
02:14:20 INFO  i.onedev.commons.bootstrap.Bootstrap - Launching application from '/opt/onedev'...
02:14:20 INFO  i.onedev.commons.bootstrap.Bootstrap - Cleaning temp directory...
02:14:20 INFO  io.onedev.commons.loader.AppLoader - Starting application...
02:14:35 INFO  i.o.s.e.i.DefaultBuildMetricManager - Caching build metric info...
02:14:36 INFO  i.o.s.e.impl.DefaultIssueManager - Caching issue info...
02:14:36 INFO  i.o.s.e.impl.DefaultProjectManager - Checking projects...
02:14:37 INFO  i.o.s.e.i.DefaultAgentAttributeManager - Caching agent attribute info...
02:14:37 INFO  i.o.s.e.i.DefaultBuildParamManager - Caching build param info...
02:14:37 INFO  i.o.s.e.impl.DefaultBuildManager - Caching build info...
02:14:41 INFO  io.onedev.server.OneDev - Server is ready at http://localhost:6610.
02:14:41 ERROR i.o.s.g.command.ListNumStatsCommand - warning: Not a git repository. Use --no-index to compare two paths outside a working tree
02:14:41 ERROR i.o.s.g.command.ListNumStatsCommand - warning: Not a git repository. Use --no-index to compare two paths outside a working tree
02:14:41 ERROR i.o.s.g.command.ListNumStatsCommand - warning: Not a git repository. Use --no-index to compare two paths outside a working tree
02:14:41 ERROR i.o.s.g.command.ListNumStatsCommand - warning: Not a git repository. Use --no-index to compare two paths outside a working tree
02:14:41 ERROR i.o.s.g.command.ListNumStatsCommand - warning: Not a git repository. Use --no-index to compare two paths outside a working tree
02:14:41 ERROR i.o.s.g.command.ListNumStatsCommand - usage: git diff --no-index [<options>] <path> <path>
02:14:41 ERROR i.o.s.g.command.ListNumStatsCommand - usage: git diff --no-index [<options>] <path> <path>
02:14:41 ERROR i.o.s.g.command.ListNumStatsCommand - usage: git diff --no-index [<options>] <path> <path>
02:14:41 ERROR i.o.s.g.command.ListNumStatsCommand - usage: git diff --no-index [<options>] <path> <path>

etc

I get the same error when I try to push commits and client side see this (replaced my repo uri)

❯ git push backup-origin
Enumerating objects: 46, done.
Counting objects: 100% (46/46), done.
Delta compression using up to 20 threads
Compressing objects: 100% (43/43), done.
Writing objects: 100% (44/44), 99.05 KiB | 7.62 MiB/s, done.
Total 44 (delta 26), reused 0 (delta 0), pack-reused 0
remote: curl: (22) The requested URL returned error: 500
To ssh://my.domain.com:12345/myrepo
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'ssh://my.domain.com:12345/myrepo'

I can upload the whole log if necessary, it's quite large.

FWIW, I can clone projects without issue so the data is seemingly fine.

  • Jonathan Simon changed title 3 years ago
    Previous Value Current Value
    Many errors on startup and during push
    git diff errors on startup and during push
  • Robin Shen commented 3 years ago

    Please check directory /media/storage/docker_configs/onedev/site/projects. Seems that it contains some directory not expecting to be a valid OneDev project directory. A valid project directory contains a valid git sub directory.

  • Jonathan Simon commented 3 years ago

    They all have a git directory with what looks like valid contents.

    $ ls -l **/git
    1/git:
    Permissions Size User   Group  Date Modified    Name
    drwxr-xr-x     - jsimon jsimon 2022-08-09 21:12  branches/
    drwxr-xr-x     - jsimon jsimon 2022-08-09 21:12  hooks/
    drwxr-xr-x     - jsimon jsimon 2022-08-09 21:12  logs/
    drwxr-xr-x     - jsimon jsimon 2022-08-09 21:15  objects/
    drwxr-xr-x     - jsimon jsimon 2022-08-09 21:12  refs/
    .rw-r--r--   162 jsimon jsimon 2022-08-09 21:12  config
    .rw-r--r--    21 jsimon jsimon 2022-08-09 21:15  HEAD
    
    2/git:
    Permissions Size User   Group  Date Modified    Name
    drwxr-xr-x     - jsimon jsimon 2022-08-09 22:09  branches/
    drwxr-xr-x     - jsimon jsimon 2022-08-09 22:09  hooks/
    drwxr-xr-x     - jsimon jsimon 2022-08-09 22:09  logs/
    drwxr-xr-x     - jsimon jsimon 2023-05-31 14:36  objects/
    drwxr-xr-x     - jsimon jsimon 2022-08-09 22:09  refs/
    .rw-r--r--   162 jsimon jsimon 2022-08-09 22:09  config
    .rw-r--r--    23 jsimon jsimon 2022-08-09 22:09  HEAD
    
    3/git:
    Permissions Size User   Group  Date Modified    Name
    drwxr-xr-x     - jsimon jsimon 2022-08-22 13:26  branches/
    drwxr-xr-x     - jsimon jsimon 2022-08-22 13:26  hooks/
    drwxr-xr-x     - jsimon jsimon 2022-08-22 13:26  logs/
    drwxr-xr-x     - jsimon jsimon 2022-08-22 13:27  objects/
    drwxr-xr-x     - jsimon jsimon 2022-08-22 13:26  refs/
    .rw-r--r--   162 jsimon jsimon 2022-08-22 13:26  config
    .rw-r--r--    21 jsimon jsimon 2022-08-22 13:27  HEAD
    
    4/git:
    Permissions Size User   Group  Date Modified    Name
    drwxr-xr-x     - jsimon jsimon 2022-09-01 13:55  branches/
    drwxr-xr-x     - jsimon jsimon 2022-09-01 13:55  hooks/
    drwxr-xr-x     - jsimon jsimon 2022-09-01 13:55  logs/
    drwxr-xr-x     - jsimon jsimon 2023-06-06 22:21  objects/
    drwxr-xr-x     - jsimon jsimon 2022-09-01 13:55  refs/
    .rw-r--r--   162 jsimon jsimon 2022-09-01 13:55  config
    .rw-r--r--    21 jsimon jsimon 2022-09-01 13:56  HEAD
    
    5/git:
    Permissions Size User   Group  Date Modified    Name
    drwxr-xr-x     - jsimon jsimon 2022-12-17 13:17  branches/
    drwxr-xr-x     - jsimon jsimon 2022-12-17 13:17  hooks/
    drwxr-xr-x     - jsimon jsimon 2022-12-17 13:17  lfs/
    drwxr-xr-x     - jsimon jsimon 2022-12-17 13:17  logs/
    drwxr-xr-x     - jsimon jsimon 2023-05-31 20:34  objects/
    drwxr-xr-x     - jsimon jsimon 2022-12-17 13:17  refs/
    .rw-r--r--   162 jsimon jsimon 2022-12-17 13:17  config
    .rw-r--r--    21 jsimon jsimon 2022-12-17 13:18  HEAD
    
  • Robin Shen commented 3 years ago

    Please edit /media/storage/docker_configs/onedev/conf/logback.xml to add below logger:

    <logger name="io.onedev.commons.utils.command.Commandline" level="TRACE"/>
    

    Then restart OneDev to see the command execution details including working directory. You can then run that command directly in that directory to see if it reports the same error.

  • Jonathan Simon commented 3 years ago

    Here is a snippet of what I got:

    2023-06-09 02:51:38,298 DEBUG [pool-3-thread-2] i.o.c.utils.command.Commandline Executing command: git diff --numstat --no-renames e2cae04b8a96d8da7699c2ae7fd63fb86e65646b..e2cae04b8a96d8da7699c2ae7fd63fb86e65646b
    2023-06-09 02:51:38,301 TRACE [pool-3-thread-2] i.o.c.utils.command.Commandline Command working directory: /opt/onedev/site/projects/4/git
    2023-06-09 02:51:38,302 TRACE [pool-3-thread-2] i.o.c.utils.command.Commandline Command execution environments:
            PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
            WRAPPER_PID=115
            WRAPPER_WORKING_DIR=/opt/onedev/boot
            WRAPPER_JAVA_VERSION_MINOR=0
            WRAPPER_OS=linux
            WRAPPER_HOSTNAME=9eab8c492a10
            LANG=en_US.UTF-8
            WRAPPER_BITS=64
            WRAPPER_BIN_DIR=/opt/onedev/boot
            WRAPPER_VERSION=3.5.51
            WRAPPER_BASE_NAME=wrapper
            WRAPPER_HOST_NAME=9eab8c492a10
            WRAPPER_CONF_DIR=/opt/onedev/conf
            WRAPPER_LANG=en
            WRAPPER_JAVA_VENDOR=OpenJDK
            PWD=/
            WRAPPER_FILE_SEPARATOR=/
            _=/opt/onedev/boot/wrapper-linux-x86-64
            ONEDEV_COMMAND_EXECUTION_UUID=d969d4bc-f9fa-44d1-a874-f3d279ad9f1f
            LANGUAGE=en_US:en
            WRAPPER_INIT_DIR=/
            WRAPPER_PATH_SEPARATOR=:
            WRAPPER_EDITION=Standard
            HOSTNAME=9eab8c492a10
            WRAPPER_JAVA_VERSION_MAJOR=11
            LC_ALL=en_US.UTF-8
            WRAPPER_JAVA_VERSION_REVISION=19
            WRAPPER_RUN_MODE=console
            WRAPPER_ARCH=x86
            WRAPPER_JAVA_VERSION=11.0.19
            SHLVL=0
            HOME=/root
    

    If I manually go to /media/storage/docker_configs/onedev/site/projects/4/git (which corresponds to /opt/onedev/site/projects/4/git) and execute git diff --numstat --no-renames e2cae04b8a96d8da7699c2ae7fd63fb86e65646b..e2cae04b8a96d8da7699c2ae7fd63fb86e65646b, it exits 0 and has no output.

    ETA: For clarity, later in the log, that thread emitted the same error as mentioned in the OP.

  • Robin Shen commented 3 years ago

    Please exec into onedev container, and run the same command in directory /opt/onedev/site/projects/4/git to see what happens.

  • Jonathan Simon commented 3 years ago

    Aha!

    When inside the container, I get the error that is listed in the logs. My gut says permissions issue so I added

            environment:
                - PUID=1000
                - PGID=1000
    

    to the compose and chowned the whole directory to my host user. It had no effect on the outcome.

  • Robin Shen commented 3 years ago

    OneDev needs to run as root inside the container. Please change all files under /opt/onedev to be owned by root (this directory can be owned by normal user, but that needs docker to run in rootless mode, which is another topic).

  • Jonathan Simon commented 3 years ago

    And there you have it, I can now push. Thank you for the support!

  • Jonathan Simon changed state to 'Closed' 3 years ago
    Previous Value Current Value
    Open
    Closed
  • Jonathan Simon commented 3 years ago

    Config issue, all fixed thanks to @robin

issue 1/1
Type
Question
Priority
Normal
Assignee
Issue Votes (0)
Watchers (4)
Reference
OD-1409
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover