-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error prefetching hash: exit status 1 #19
Comments
If it makes a difference, |
I'm still running into this. I really wish I could get this tool to at least print out the command it was executing. |
I just modified the source to print out the Edit: Actually it does exist while the tool is running, I guess it deletes the dir before returning. |
I figured out that stderr was being lost. After restoring that, I got the wonderful error
|
Ultimately, the problem is dep produces a |
This is rather hacky but seems to work: diff --git a/prefetch.go b/prefetch.go
index dc3e74c..78b3b00 100644
--- a/prefetch.go
+++ b/prefetch.go
@@ -4,6 +4,9 @@ import (
"bytes"
"encoding/json"
"github.com/Masterminds/vcs"
+ "io/ioutil"
+ "net/url"
+ "os"
"os/exec"
"strings"
)
@@ -36,8 +40,31 @@ func cmdStdout(command string, arguments ...string) (string, error) {
type gitPrefetcher struct{}
-func (p *gitPrefetcher) fetchHash(url string, revision string) (string, error) {
- out, err := cmdStdout("nix-prefetch-git", "--url", url, "--rev", revision, "--quiet", "--fetch-submodules")
+func (p *gitPrefetcher) fetchHash(localUrl string, revision string) (string, error) {
+ if strings.Contains(localUrl, "@") {
+ // nix-prefetch-git does not sanitize the @ character, but it's not allowed in Nix paths.
+ // We need to copy this directory to another path that doesn't contain the @.
+ realUrl, err := url.Parse(localUrl)
+ if err != nil {
+ return "", err
+ }
+ dir, err := ioutil.TempDir("", "dep2nix")
+ if err != nil {
+ return "", err
+ }
+ defer os.RemoveAll(dir) // clean up the temp dir
+ // HACK: I don't want to write a recursive copy myself. I'll just leverage ditto instead.
+ cmd := exec.Command("ditto", "--", realUrl.EscapedPath(), dir)
+ cmd.Stderr = os.Stderr
+ if err := cmd.Run(); err != nil {
+ return "", err
+ }
+ localUrl = (&url.URL{
+ Scheme: "file",
+ Path: dir,
+ }).String()
+ }
+ out, err := cmdStdout("nix-prefetch-git", "--url", localUrl, "--rev", revision, "--quiet", "--fetch-submodules")
if err != nil {
return "", err
} |
It looks like we could use the |
I'm trying to use this on a project with a Gopkg.lock and when I run
dep2nix
I get the outputThe project is an internal project but the import domain doesn't require authentication AFAICT (it just requires being on VPN, which I am). I don't know what "error prefetching hash" means. The Gopkg.lock file lists this for the given dependency:
The text was updated successfully, but these errors were encountered: