Code Monkey home page Code Monkey logo

Comments (6)

twpayne avatar twpayne commented on September 21, 2024 2

If chezmoi does a lookPath before step 4, does that affect the resolution?

No. The lookup error is cached in the os/exec.Cmd struct and is unaffected by other calls to os/exec.LookPath. See https://github.com/golang/go/blob/go1.20.6/src/os/exec/exec.go#L418-L429.

from chezmoi.

halostatue avatar halostatue commented on September 21, 2024 1

We need to understand what you are seeing more explicitly before we can declare it as a bug or correct behaviour, therefore it is a support request.

from chezmoi.

twpayne avatar twpayne commented on September 21, 2024 1

OK, this one is interesting. It's a "feature" of Go standard library's os/exec.Command function. What's happening it:

  1. When chezmoi reads the external file, it creates the os/exec.Cmd structure for the git command to be run using os/exec.Command.
  2. os/exec.Command immediately looks for the git command, which it doesn't find, as git is not yet installed. It then stores that not found error for later.
  3. Later, chezmoi runs the install-git.sh script, which installs git.
  4. Later, chezmoi calls Run() on the os/exec.Cmd it created in step 1. Instead of checking again for the presence of git in $PATH, Go's standard library returns the not found error it saved at step 2.

I'll have a think about how to fix this.

from chezmoi.

tummetott avatar tummetott commented on September 21, 2024

I'm a bit puzzled as to why this was flagged as "support"? I followed the manpage exactly, and the only deviation is that the prerequisite seems to be necessary for external sources rather than template expansion.

  • /usr/bin is in PATH
  • Git is installed within the run_before_ script to /user/bin/git
  • The external sources are cloned after the run_before_ scripts

Considering these factors, it seems logical that chezmoi should be able to locate git without any issues. It manages to do so when I run chezmoi apply a second time. So, I'm left wondering why it doesn't work on the initial run.

To me, this situation appears to be a bug because the ideal scenario would be to install everything, including prerequisites and dotfiles, with a single command (like sh -c "$(curl -fsLS get.chezmoi.io/lb)" -- init --apply <username>)

image

from chezmoi.

halostatue avatar halostatue commented on September 21, 2024

If chezmoi does a lookPath before step 4, does that affect the resolution?

from chezmoi.

tummetott avatar tummetott commented on September 21, 2024

Thanks for the fast bugfix. You guys are amazing ! ❤️

from chezmoi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.