boxen / our-boxen

Copy me for your team.
https://github.com/boxen/our-boxen/
MIT License
2.58k stars 883 forks source link

boxen-git-credential error when using different Homebrew root #727

Closed salimane closed 9 years ago

salimane commented 9 years ago
Salimanes-MacBook-Pro:our-boxen salimane$ git push origin master
/opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:37:in `exec': No such file or directory - /opt/boxen/homebrew/bin/git-credential-osxkeychain (Errno::ENOENT)
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:37:in `block in popen4'
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:85:in `call'
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:85:in `block in do_popen'
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:62:in `fork'
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:62:in `do_popen'
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:34:in `popen4'
    from /opt/boxen/bin/boxen-git-credential:45:in `<main>'
Counting objects: 909, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (546/546), done.
Writing objects: 100% (793/793), 43.67 MiB | 224.00 KiB/s, done.
Total 793 (delta 286), reused 604 (delta 234)
To https://github.com/salimane/our-boxen
   7e677e1..7652f6b  master -> master
Salimanes-MacBook-Pro:our-boxen salimane$ 
seanknox commented 9 years ago

/opt/boxen/homebrew/bin/git-credential-osxkeychain is not present. Any idea how it would have been removed?

salimane commented 9 years ago

here is the content of my our-boxen/facts.d/common.yaml. I'm using /usr/local as my homebrew path

---
# Any yaml or json files in this directory may be used to set
# facts. This is useful, primarily, for things like homebrew_root,
# which must be a fact rather than configured with hiera because
# of how Puppet's custom resource providers work.

homebrew_root: /usr/local
brewcask_root: /opt/homebrew-cask
seanknox commented 9 years ago

Does this happen on master? There has been some work recently to support custom homebrew root paths.

sebroeder commented 9 years ago

Does this happen on master? There has been some work recently to support custom homebrew root paths.

Yes, I see this too and my fork is based on 689633f.

seanknox commented 9 years ago

Ok, looks like /opt/boxen/bin/boxen-git-credential needs some updating (and perhaps other things) to respect the custom Homebrew path.

sebroeder commented 9 years ago

Can somebody confirm that /opt/boxen/bin/boxen-git-credential does not take up the environment variable BOXEN_GIT_CREDENTIAL_FALLBACK?

I tried to set it in two different ways:

BOXEN_GIT_CREDENTIAL_FALLBACK=/usr/local/bin/git-credential-osxkeychain git push
export BOXEN_GIT_CREDENTIAL_FALLBACK=/usr/local/bin/git-credential-osxkeychain
git push

They both give me the same unchanged error message:

$ git push sebroeder
/opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:37:in `exec': No such file or directory - /opt/boxen/homebrew/bin/git-credential-osxkeychain (Errno::ENOENT)
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:37:in `block in popen4'
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:85:in `call'
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:85:in `block in do_popen'
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:62:in `fork'
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:62:in `do_popen'
    from /opt/boxen/repo/.bundle/ruby/2.0.0/gems/open4-1.3.4/lib/open4.rb:34:in `popen4'
    from /opt/boxen/bin/boxen-git-credential:45:in `<main>'

If the handling of environmental variables would work in /opt/boxen/bin/boxen-git-credential we could set the path to the git-credential-osxkeychain using ENV['HOMEBREW_ROOT']/bin/git-credential-osxkeychain but it seems to be broken at the moment.

seanknox commented 9 years ago

@sebroeder can you paste the contents of your /opt/boxen/config/boxen/defaults.json?

sebroeder commented 9 years ago

Sure.

$ cat /opt/boxen/config/boxen/defaults.json
{"fde":true,
"homedir":"/opt/boxen",
"login":"sebroeder",
"name":"Sebastian Röder",
"puppetdir":"/tmp/boxen/puppet",
"repodir":"/opt/boxen/repo",
"reponame":"boxen/our boxen",
"ghurl":"https://github.com",
"srcdir":"/Users/sebroeder/src",
"user":"sebroeder",
"repotemplate":"https://github.com/%s",
"s3host":"s3.amazonaws.com",
"s3bucket":"boxen-downloads"}
seanknox commented 9 years ago

@sebroeder do you have any custom hiera.yaml/facts.d config? Please post any non-standard Boxen config items.

sebroeder commented 9 years ago

@seanknox

$ cat hiera/common.yaml
---
boxen::config::srcdir: "/Users/%{::boxen_user}/Developer"

$ cat facts.d/homebrew_root.yaml 
---
homebrew_root: /usr/local
indirect commented 9 years ago

@sebroeder @seanknox I can confirm that simply setting homebrew's root to /usr/local is enough to cause this problem, and I can also confirm that explicitly setting BOXEN_GIT_CREDENTIAL_FALLBACK does not fix it. Somehow the helper is clearing that variable, I'm guessing somewhere inside boxen/config. Is there a place we should be setting it inside boxen, instead?

sebroeder commented 9 years ago

@indirect thanks for confirming the issue. I am not sure how to proceed from here. I want to find out where exactly the env vars are erased as this causes problems for me in other places, too. I also don't know whether the custom boxen-git-credential helper is needed at all, as discussed in boxen/boxen#169.

The README.md in boxen/boxen provides the following info, which might be related to our problem:

We can't pass a FACTER_ env var because sudo has env_reset and we can't just modify the sudoers file due to a chicken-egg problem.

indirect commented 9 years ago

@mikemcquaid do you not experience this issue? My current solution is to hard-code /usr/local, and that sucks. Is there a variable I can use to access the fact that contains the homebrew root instead?