Blob Blame Raw
From e2bff2b9ed327434762915429e9033e81815b3ac Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Fri, 7 Jun 2019 20:53:54 -0400
Subject: [PATCH 1/4] Use system path for TINYGOROOT default.

Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
 target.go | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/target.go b/target.go
index 679fa19..fc4589b 100644
--- a/target.go
+++ b/target.go
@@ -267,21 +267,8 @@ func sourceDir() string {
 		return root
 	}
 
-	// Find root from executable path.
-	path, err := os.Executable()
-	if err != nil {
-		// Very unlikely. Bail out if it happens.
-		panic("could not get executable path: " + err.Error())
-	}
-	root = filepath.Dir(filepath.Dir(path))
-	if isSourceDir(root) {
-		return root
-	}
-
-	// Fallback: use the original directory from where it was built
-	// https://stackoverflow.com/a/32163888/559350
-	_, path, _, _ = runtime.Caller(0)
-	root = filepath.Dir(path)
+	// Use system directory
+	root = "/usr/share/tinygo"
 	if isSourceDir(root) {
 		return root
 	}
-- 
2.21.0