janet-lang / spork

Various Janet utility modules - the official "Contrib" library.
MIT License
124 stars 36 forks source link

janet-netrepl and janet-format missing from `bundle/init.janet`? #187

Closed sogaiu closed 3 months ago

sogaiu commented 5 months ago

After installing via (bundle/install "."), I don't get janet-netrepl or janet-format on my PATH.

May be they need to get mentioned in bundle/init.janet?

I wasn't sure how to indicate where they should get installed. In some testing, I used a destination via relative paths, but wasn't confident that is advisable.

Something like:

(bundle/add-file manifest "bin/janet-netrepl" "../../bin/janet-netrepl" 8r755)
pepe commented 5 months ago

Thank you for exploring bundle corners!

sogaiu commented 4 months ago

Possibly relevant bit from jpm man page:

JANET_BINPATH
       The directory where jpm will install binary scripts and
       executables to.  Defaults to (dyn :syspath)/bin The
       --binpath=/some/path will override this variable.
sogaiu commented 4 months ago

Perhaps this commit may contain something that will help with this issue.

sogaiu commented 4 months ago

Using a janet with the commit mentioned in the previous comment, the following diff seems to get things to work:

diff --git a/bundle/init.janet b/bundle/init.janet
index b0c2dd7..5a5d7eb 100644
--- a/bundle/init.janet
+++ b/bundle/init.janet
@@ -3,6 +3,10 @@

 (defn install [m &]
   (bundle/add-file m "src/tarray.h" "tarray.h")
+  (each file (os/dir "bin")
+    (def f (string "bin/" file))
+    (when (= (os/stat f :mode) :file)
+      (bundle/add-bin m f)))
   (bundle/add m "spork")
   (each file (os/dir "build")
     (def f (string "build/" file))

...but perhaps it feels a bit repetitive?

Here's another attempt:

diff --git a/bundle/init.janet b/bundle/init.janet
index b0c2dd7..5cb40b3 100644
--- a/bundle/init.janet
+++ b/bundle/init.janet
@@ -4,10 +4,15 @@
 (defn install [m &]
   (bundle/add-file m "src/tarray.h" "tarray.h")
   (bundle/add m "spork")
-  (each file (os/dir "build")
-    (def f (string "build/" file))
-    (when (= (os/stat f :mode) :file)
-      (bundle/add-file m f (string "spork/" file)))))
+  (each dir ["bin" "build"]
+    (each file (os/dir dir)
+      (def f (string dir "/" file))
+      (when (= (os/stat f :mode) :file)
+        (cond
+          (= "bin" dir)
+          (bundle/add-bin m f)
+          (= "build" dir)
+          (bundle/add-file m f (string "spork/" file)))))))

 (defn clean [&]
   (sh/rm "build"))

Not sure if that's a net win...

sogaiu commented 4 months ago

As another piece of info regarding destinations, there is this line in jpm's source:

:binpath (string prefix "/bin")

I guess this tends to end up at a different location compared to (dyn *syspath*)/bin as prefix is typically something like /usr/local or $HOME/.local.

Probably obvious, but IIUC the above is for *nixy systems and doesn't apply as-is for Windows.

bakpakin commented 3 months ago

So taking a look at this, spork should be updated now.

As for binpath, we are taking a different approach with installing scripts with bundle. All scripts will now just be installed to (string (dyn *syspath*) "/bin"), and the user would be expected to modify their path. If you wanted to actually put scripts in /usr/bin or similar, one could use a symlink. This avoids extra configuration as well as makes it clear these scripts are installed by bundle/install.

sogaiu commented 3 months ago

Thanks for the clarification.