Skip to content

Fix locateSrcDir#127

Closed
lanzafame wants to merge 3 commits intotestground:masterfrom
lanzafame:fix/locate-src-dir
Closed

Fix locateSrcDir#127
lanzafame wants to merge 3 commits intotestground:masterfrom
lanzafame:fix/locate-src-dir

Conversation

@lanzafame
Copy link
Copy Markdown

Running testground in $GOPATH/src/github.com/ipfs/testground returned:

$ testground
attempting to guess testground base directory; for better control set ${TESTGROUND_SRCDIR}
attempting to guess testground base directory; for better control set ${TESTGROUND_SRCDIR}
attempting to guess testground base directory; for better control set ${TESTGROUND_SRCDIR}
attempting to guess testground base directory; for better control set ${TESTGROUND_SRCDIR}
attempting to guess testground base directory; for better control set ${TESTGROUND_SRCDIR}
attempting to guess testground base directory; for better control set ${TESTGROUND_SRCDIR}
panic: unable to determine testground src dir

goroutine 1 [running]:
github.com/ipfs/testground/cmd.glob..func1(0x0)
	/home/lanzafame/src/github.com/ipfs/testground/cmd/all.go:12 +0x5b
github.com/ipfs/testground/cmd.init()
	/home/lanzafame/src/github.com/ipfs/testground/cmd/all.go:15 +0x37

Discovered that locateSrcDir was getting the directory of the executable, instead of the working directory, i.e. where the executable was called, and it was also truncating the path before checking if it was the source directory.

Also, check initial path from Getwd, before getting the parent
directory.
@lanzafame
Copy link
Copy Markdown
Author

Closing as I have misunderstood the use of os.Executable and my fix only works if you are running testground in the source directory, which I was because I had just pulled it down. The reason that the original code didn't work though was because I had run go install instead of go build therefore putting the binary in $GOPATH/bin instead of $GOPATH/src/github.com/ipfs/testground.

@lanzafame lanzafame closed this Nov 6, 2019
@lanzafame lanzafame deleted the fix/locate-src-dir branch November 6, 2019 03:05
@raulk
Copy link
Copy Markdown
Contributor

raulk commented Nov 6, 2019

No, I think you're right! We can improve this logic, and also document it in the README.

@raulk
Copy link
Copy Markdown
Contributor

raulk commented Nov 6, 2019

Did so in #130.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants