Skip to content
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

empty .gx/post-install created #208

Open
dignifiedquire opened this issue Aug 30, 2018 · 13 comments
Open

empty .gx/post-install created #208

dignifiedquire opened this issue Aug 30, 2018 · 13 comments

Comments

@dignifiedquire
Copy link

Sometimes an empty .gx/post-install file is generated after running through an update from gx-workspace. I haven't found a pattern yet, as to when or why.

@Stebalien
Copy link
Collaborator

What's the output of gx-go link?

@schomatis
Copy link
Collaborator

When Gx runs the post-install hook on a package directory it "marks" it with that file to avoid rerunning it later (I'm not sure the rationale behind it, I mean, in which Gx work flow that hook is called multiple times and why is that avoided, if for performance reasons or because the hook operation is not meant to be idempotent).

(@Stebalien This is related to the whyrusleeping/gx-go#51 (comment) in gx-go link where re-linking has no effect because this hook is not rerun).

gx/gxutil/pm.go

Lines 98 to 112 in 855ebcf

func maybeRunPostInstall(pkg *Package, pkgdir string, global bool) error {
dir := filepath.Join(pkgdir, pkg.Name)
if !pkgRanHook(dir, "post-install") {
before := time.Now()
VLog(" - running post install for %s:", pkg.Name, pkgdir)
args := []string{pkgdir}
if global {
args = append(args, "--global")
}
err := TryRunHook("post-install", pkg.Language, pkg.SubtoolRequired, args...)
if err != nil {
return err
}
VLog(" - post install finished in ", time.Since(before))
err = writePkgHook(dir, "post-install")

@Stebalien
Copy link
Collaborator

@schomatis that's assuming that the package was linked, right?

@schomatis
Copy link
Collaborator

that's assuming that the package was linked, right?

Not sure I follow, the hook is independent of the link command, I mean, gx-go link is just one of the commands that calls gx-go hook post-install (e.g., so does gx install), so I don't think there's any assumption about that.

@Stebalien
Copy link
Collaborator

gx won't usually run the post-install hook in a normal repo; it should only do that when it installs packages in $GOPATH/src/gx/ipfs/.... The issue here is that gx is, for some reason, doing exactly that (dropping a post-install file in the github repo) when used with gx-workspace.

@schomatis
Copy link
Collaborator

gx won't usually run the post-install hook in a normal repo;

The issue here is that gx is, for some reason, doing exactly that (dropping a post-install file in the github repo)

Ok, now I understand the original question. Yes, the hook is run in $GOPATH/src/gx/ipfs/... but that path is linked to a github path so the hook is effectively being run in a git-cloned repo. I'm not sure if I would consider this is a bug (it seems to me more like we don't clarify well enough what does our link API do).

(By the way, this is a nice example of why I would like to invest some time defining a clear path terminology, to avoid terms like "normal" or having to specify the entire $GOPATH/src/gx/ipfs/... to mean that I'm referring to that kind of paths instead of the "normal" ones.)

@Stebalien
Copy link
Collaborator

I'm not sure if I would consider this is a bug (it seems to me more like we don't clarify well enough what does our link API do).

"that's assuming that the package was linked, right?"

If the package isn't linked, then this is a bug. And really, gx-workspace shouldn't care so this is probably a bug.

@dignifiedquire
Copy link
Author

What's the output of gx-go link?

In which repo, the one with the file, or the one I used gx-workspace from?

@dignifiedquire
Copy link
Author

dignifiedquire commented Aug 31, 2018

Some details

> go-merkledag (master) ✗ ls .gx
lastpubver   post-install
>  go-merkledag (master) ✗ gx-go link
QmRiQCJZ91B7VNmLvA6sxzDuBJGSojS3uXHHVuNr3iueNZ /Users/dignifiedquire/.go/src/github.com/ipfs/go-merkledag
>  go-merkledag (master) ✗ cat .gx/post-install
>  go-merkledag (master) ✗ ls -lh .gx
total 8
-rw-r--r--  1 dignifiedquire  staff    55B Aug 30 14:08 lastpubver
-rw-r--r--  1 dignifiedquire  staff     0B Aug 30 14:13 post-install

@Stebalien
Copy link
Collaborator

Yeah, you've linked a dependency. Basically, this means that whenever you "install" that dependency, it'll rewrite it and add the post-install file.

When using gx-workspace, you should either:

  1. Use a temporary workspace.
  2. Make sure to cleanup any gx links, misc changes, etc.

@Stebalien
Copy link
Collaborator

@schomatis is right, this is a documentation issue.

@dignifiedquire
Copy link
Author

dignifiedquire commented Aug 31, 2018 via email

@Stebalien
Copy link
Collaborator

I had not linked this before using gx-workspace, so this sounds more like an issue with the interaction between the two.

But you had run gx-go link on go-merkledag sometime in the past, right (the answer is almost certainly yes). That will globally symlink gx/ipfs/.../go-merkledag to github.com/ipfs/go-merkledag.

I also still don’t understand how not cleaning up empty files is not a bug in any state.

These are the marker-files gx leaves behind once it installs a package in gx/ipfs/.... They tell gx that the rewrite completed successfully and the package has been properly installed (we could probably also do it by first putting the package in a temporary directory and then moving it but that's not how gx currently works).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants