{"action":"created","issue":{"url":"https://api.github.com/repos/NixOS/nixpkgs/issues/18131","repository_url":"https://api.github.com/repos/NixOS/nixpkgs","labels_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/18131/labels{/name}","comments_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/18131/comments","events_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/18131/events","html_url":"https://github.com/NixOS/nixpkgs/issues/18131","id":174113226,"number":18131,"title":"darwin: go: cycle detected in the references of ... (a private go package)","user":{"login":"mstone","id":412508,"avatar_url":"https://avatars.githubusercontent.com/u/412508?v=3","gravatar_id":"","url":"https://api.github.com/users/mstone","html_url":"https://github.com/mstone","followers_url":"https://api.github.com/users/mstone/followers","following_url":"https://api.github.com/users/mstone/following{/other_user}","gists_url":"https://api.github.com/users/mstone/gists{/gist_id}","starred_url":"https://api.github.com/users/mstone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstone/subscriptions","organizations_url":"https://api.github.com/users/mstone/orgs","repos_url":"https://api.github.com/users/mstone/repos","events_url":"https://api.github.com/users/mstone/events{/privacy}","received_events_url":"https://api.github.com/users/mstone/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-30T20:10:18Z","updated_at":"2016-08-31T16:24:42Z","closed_at":null,"body":"## Overview\r\n\r\nI was just bit by the same issue as #10599 while building a private go package on Darwin and as a result, I'd like to document my debugging efforts so that others who encounter similar problems  may find my workaround between now and whenever we decide how to fix the issue for real.\r\n\r\n## Issue description\r\n\r\nThe symptom of the issue was that while running `nix-build -K -I nixpkgs=~/nixpkgs -j2 --cores 2 shell.nix` with a recent checkout of nixpkgs (https://github.com/NixOS/nixpkgs/commit/5120af001f2bb163b58c41c84b11a0c136a207fe) on a nix-expression using `buildGoPackage` to define a multiple-output derivation, I got a cyclic reference error like this one:\r\n\r\n```\r\ncycle detected in the references of ‘/nix/store/43wwl5kgh0z9yd92ydc7jahy1yjipmwk-go1.6-whist-20160816-ca1fec0-bin’\r\n```\r\n\r\nThe fix, as in #10599, is to use `install_name_tool` to repoint the offending `LC_RPATH` tag.\r\n\r\n## Diagnosis\r\n\r\nTo diagnose the cause(s) of the problem, I rebuilt nix-1.11.3 with a custom backport of https://github.com/NixOS/nix/pull/925/commits/c87a56f4d01442ee94c0db9e89a89292d44015ae (temporarily published at https://github.com/mstone/nix/commit/a715d9ebe419d170d956dd743d072de016ffc24b) which gave me the following clue:\r\n\r\n```\r\ncycle detected in the references of ‘/nix/store/43wwl5kgh0z9yd92ydc7jahy1yjipmwk-go1.6-whist-20160816-ca1fec0-bin’ from ‘/nix/store/baswj95p801zlfhjxarran4xdyjgz4g8-go1.6-whist-20160816-ca1fec0’\r\n```\r\n\r\nUsing this clue, I `cd`'ed to the build directory I kept with `nix-build -K` and grepped `env-vars` for the values of `out=` and `bin=` and then, using the `$bin` directory, I ran `grep -r baswj95p801zlfhjxarran4xdyjgz4g8 /nix/store/43wwl5kgh0z9yd92ydc7jahy1yjipmwk-go1.6-whist-20160816-ca1fec0-bin` to find out which files contained cyclic references, which produced one output:\r\n\r\n```\r\nBinary file /nix/store/43wwl5kgh0z9yd92ydc7jahy1yjipmwk-go1.6-whist-20160816-ca1fec0-bin/bin/.whist-wrapped matches\r\n```\r\n\r\nNext, to find out why this file contained a cyclic reference, I fiddled with `otool` until I ran `otool -l /nix/store/43wwl5kgh0z9yd92ydc7jahy1yjipmwk-go1.6-whist-20160816-ca1fec0-bin/bin/.whist-wrapped | grep -C 5 baswj95p801zlfhjxarran4xdyjgz4g8` which indicated that the problem was an inappropriate `LC_RPATH` setting:\r\n\r\n```\r\nLoad command 16\r\n          cmd LC_RPATH\r\n      cmdsize 96\r\n         path /nix/store/baswj95p801zlfhjxarran4xdyjgz4g8-go1.6-whist-20160816-ca1fec0/lib (offset 12)\r\n```\r\n\r\njust as in #10599. \r\n\r\nFinally, to fix the problem locally, I applied the fixes proposed in 86dae7017364cbf6cfb40f0ccd1d6b0aa7cdd933 and 4e1fdadd022ed9a1f7517b60b704c48bc30aaa75 to my own nix expression and, thankfully, they worked just fine for me once I adapted them to repoint LC_RPATH from `$lib` to `$bin` (since `buildGoPackage` produces derivations with outputs named `out` and `bin`, but not `lib`).\r\n\r\n/cc @pikajude @vcunat @ttuegel "},"comment":{"url":"https://api.github.com/repos/NixOS/nixpkgs/issues/comments/243819719","html_url":"https://github.com/NixOS/nixpkgs/issues/18131#issuecomment-243819719","issue_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/18131","id":243819719,"user":{"login":"vcunat","id":1785925,"avatar_url":"https://avatars.githubusercontent.com/u/1785925?v=3","gravatar_id":"","url":"https://api.github.com/users/vcunat","html_url":"https://github.com/vcunat","followers_url":"https://api.github.com/users/vcunat/followers","following_url":"https://api.github.com/users/vcunat/following{/other_user}","gists_url":"https://api.github.com/users/vcunat/gists{/gist_id}","starred_url":"https://api.github.com/users/vcunat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vcunat/subscriptions","organizations_url":"https://api.github.com/users/vcunat/orgs","repos_url":"https://api.github.com/users/vcunat/repos","events_url":"https://api.github.com/users/vcunat/events{/privacy}","received_events_url":"https://api.github.com/users/vcunat/received_events","type":"User","site_admin":false},"created_at":"2016-08-31T16:24:42Z","updated_at":"2016-08-31T16:24:42Z","body":"@mstone: so you think some of the general frameworks is causing this on Darwin and should be improved?"}}
{"actor":{"display_login":"vcunat"}}