question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When the "origin" remote points to a local directory that itself doesn't have an "origin" remote, SourceLink emits warning/error even though it has a fallback

See original GitHub issue

The scenario is that I want to run a build on an isolated, clean new source tree, without throwing away work with git clean on my dev repo. Thanks to git, git clone . <somewhere-else> is inexpensive. But sourcelink makes the build fail if I don’t have an origin remote on my dev repo.

This warning is a problem because there’s a strong standard in arcade-powered repos to have warning-as-error turned on.

I think that not having an origin is considered valid as a sourcelink scenario, based on https://github.com/dotnet/arcade/issues/3236.

(For this specific scenario, a worktree might work better. However, in some cases it’s not good to have to manage .git/worktrees/* in the originating repo, and there are still some Git versions on our build machines that doesn’t support worktree. This is related to a source-build scenario I can get into more if desired, but that seems off topic for now.)


Here’s how to repro (f225c7a5 at the time):

git clone https://github.com/dotnet/sourcelink dev
git clone dev isolated
( cd dev; git remote rename origin dotnet )
( cd isolated; ./build.sh /bl )

Here’s the warning (as error): (RepositoryDoesNotHaveSpecifiedRemote)

/work/.rhelhome/.nuget/packages/microsoft.build.tasks.git/1.1.0-beta-20206-02/build/Microsoft.Build.Tasks.Git.targets(24,5): error : Repository ‘/work/dev’ does not have the specified remote ‘origin’; using ‘dotnet’ instead. [/work/isolated/src/Microsoft.Build.Tasks.Git.UnitTests/Microsoft.Build.Tasks.Git.UnitTests.csproj]

Microsoft.Build.Tasks.Git.LocateRepository
    Assembly = /work/.rhelhome/.nuget/packages/microsoft.build.tasks.git/1.1.0-beta-20206-02/build/../tools/netcoreapp2.0/Microsoft.Build.Tasks.Git.dll
    Parameters
        Path = /work/isolated/src/Microsoft.Build.Tasks.Git.UnitTests
    SourceLink: Reusing cached git repository information.
    Errors
        /work/.rhelhome/.nuget/packages/microsoft.build.tasks.git/1.1.0-beta-20206-02/build/Microsoft.Build.Tasks.Git.targets(24,5): Repository '/work/dev' does not have the specified remote 'origin'; using 'dotnet' instead. [/work/isolated/src/Microsoft.Build.Tasks.Git.UnitTests/Microsoft.Build.Tasks.Git.UnitTests.csproj]
        /work/.rhelhome/.nuget/packages/microsoft.build.tasks.git/1.1.0-beta-20206-02/build/Microsoft.Build.Tasks.Git.targets(24,5): Repository '/work/dev' does not have the specified remote 'origin'; using 'dotnet' instead. [/work/isolated/src/Microsoft.Build.Tasks.Git.UnitTests/Microsoft.Build.Tasks.Git.UnitTests.csproj]
    OutputProperties
        _GitRepositoryId = /work/isolated/.git
        ScmRepositoryUrl = https://github.com/dotnet/sourcelink
        SourceRevisionId = f225c7a58fb63c232505622642ad69c5b32523e2
    OutputItems
        SourceRoot
            /work/isolated/
                RevisionId = f225c7a58fb63c232505622642ad69c5b32523e2
                ScmRepositoryUrl = https://github.com/dotnet/sourcelink
                SourceControl = git

Binlog: sourcelink-no-origin-local.zip

Workaround: disable sourcelink when building this way. (/p:EnableSourceControlManagerQueries=false /p:EnableSourceLink=false)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
tmatcommented, Jul 13, 2020

I see. OK.

0reactions
dagoodcommented, Jul 13, 2020

Do you see the warning not reported if built from dev directory and reported from isolated?

Yep. This is the behavior described in https://github.com/dotnet/arcade/issues/3236#issuecomment-508964579, which I suppose isn’t working correctly after sourcelink hops over to the original local repo:

BTW, currently we first check for origin then for any other remote (the first one).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does Git tell me "No such remote 'origin'" when I try to ...
The error message you're encountering indicates that there is no remote named 'origin' in your Git repository. This suggests that the repository ...
Read more >
How to fix 'fatal: remote origin already exists' Git error
The error itself can occur against any handler, provided that it has the same placeholder name. To check if origin even exists, run...
Read more >
Remote Origin Already Exists Error: How To Fix It
1. Remove the Existing Remote · Create a new repository online using GitHub or GitLab. · Go to your local repository and remove...
Read more >
git remote - Showing, adding and removing connections to ...
git remote. The "remote" command helps you to manage connections to remote repositories. It allows you to show which remotes are currently connected,...
Read more >
2.5 Git Basics - Working with Remotes
If you clone a repository, the command automatically adds that remote repository under the name “origin”. So, git fetch origin fetches any new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found