babashka / bbin

Install any Babashka script or project with one command
MIT License
139 stars 9 forks source link

Issues running installed script on Windows 10 #57

Closed keychera closed 1 year ago

keychera commented 1 year ago

I encountered several issues running several installed project on Windows 10 Home Single Language

  1. Firstly, I tried installing a local bb project (initially tried with my existing project, but then I reproduced it to a folder that consist only bb.edn with :bbin/bin and src/hello.clj that only print hello). I install them with bbin install D:/keychera/projects/hello and the installation was successful but when I ran the project, I got this error
    Error during loading bb.edn:
    Exception in thread "main" java.lang.RuntimeException: Unsupported escape character: \k
        at clojure.lang.Util.runtimeException(Util.java:221)
        at clojure.lang.EdnReader$StringReader.invoke(EdnReader.java:457)
        at clojure.lang.EdnReader.readDelimitedList(EdnReader.java:757)
       ...omitted
  2. initially, I thought there was something wrong with my project, but then I tried installing one of the example bbin install io.github.babashka/neil, I got an error as well when running them
    
    ----- Error --------------------------------------------------------------------
    Type:     java.lang.IllegalArgumentException
    Message:  'other' has different root
    Location: C:\Users\Kyoga\.gitlibs\libs\io.github.babashka\neil\350c7ce94060bb0a6e57b32d35c37d9b17d88970\neil:8:1

----- Context ------------------------------------------------------------------ 4: ;; DO NOT EDIT DIRECTLY. GENERATED FROM scr/babashka/neil.clj 5: 6: (require '[babashka.deps :as deps]) 7: 8: (deps/add-deps '{:deps {borkdude/rewrite-edn {:mvn/version "0.4.6"} ^--- 'other' has different root ...omitted



3. however, weirdly, I tried installing the second example `bbin install https://gist.githubusercontent.com/rads/da8ecbce63fe305f3520637810ff9506/raw/25e47ce2fb5f9a7f9d12a20423e801b64c20e787/portal.clj` and it ran just fine

so I am not so sure what is going on here

also regarding the first error, I did some investigation, `Unsupported escape character: \k` apparently is from the first 
letter of the folder name in the path name provided, and I did move around the `hello` project to several places and the error is the same but the character will show the first letter of the path folder. I also tried installing the project with different slash and using relative folder as well but the error stays the same. I also tried this in both cmd and Powershell and there are no differences
keychera commented 1 year ago

Adding more information, I tried several other example and it seems that everything works fine, I tried

and all of these works fine, so far only neil and installing a project via path that has issue

borkdude commented 1 year ago

Luckily neil can be installed via scoop, but I'll take a look soon! Help debugging or a PR is appreciated

borkdude commented 1 year ago

Can you give the code of the installed script here? I suspect there is something with the paths not right.

borkdude commented 1 year ago

I mean the code of the script as installed, not of the script before installation.

keychera commented 1 year ago

if you mean the script in the bbin/bin folder here it is

#!/usr/bin/env bb

; :bbin/start
;
; {:coords {:bbin/url "file://D:\\keychera\\projects\\hello"}}
;
; :bbin/end

(require '[babashka.process :as process]
         '[babashka.fs :as fs]
         '[clojure.string :as str])

(def script-root "D:\\keychera\\projects\\hello")
(def script-main-opts-first "-m")
(def script-main-opts-second "hello")

(def tmp-edn
  (doto (fs/file (fs/temp-dir) (str (gensym "bbin")))
    (spit (str "{:deps {local/deps {:local/root \"" script-root "\"}}}"))
    (fs/delete-on-exit)))

(def base-command
  ["bb" "--deps-root" script-root "--config" (str tmp-edn)
        script-main-opts-first script-main-opts-second
        "--"])

(process/exec (into base-command *command-line-args*))

just in case, these two files are in the hello folder that I am trying to install bb.edn

{:paths ["src"]
 :bbin/bin {hello {:main-opts ["-m" "hello"]}}}

src/hello/clj

(ns hello)
(println "hello bbin!")
borkdude commented 1 year ago

OK, I see the issue and will provide a PR

borkdude commented 1 year ago

@keychera A new bbin version was just released. Can you verify if things are working for you now?

keychera commented 1 year ago

@borkdude hmm actually, using bbin 0.1.10 it now produces different error

Error building classpath. Manifest file not found for local/deps in coordinate #:local{:root "D:\\keychera\\projects\\hello"}
Exception in thread "main" java.io.FileNotFoundException: C:\Users\kyoga\.clojure\.cpcache\0E6F116D4EDDF77A5F4F2DAE2F5A3A44.cp (The system cannot find the file specified)
        at java.base@11.0.17/java.io.FileInputStream.open0(FileInputStream.java)
        at java.base@11.0.17/java.io.FileInputStream.open(FileInputStream.java:219)
        at java.base@11.0.17/java.io.FileInputStream.<init>(FileInputStream.java:157)
        at clojure.java.io$fn__11617.invokeStatic(io.clj:229)
...omitted

I tried several times and I think the missing file name stays the same. I do check that folder and it's true that file is not found, deleting the .cpcache does not seem to help as well, should this be a different issue?

also I encounter another weird issue. I tried running other installed script I did above, and three of them (http-server, watch, adn quickblog) nows produces the same error as neil on CMD Exception in thread "main" java.lang.IllegalArgumentException: 'other' has different root but then I tried running them on Powershell, it works fine. what is weird is that when I tried those three again back on CMD, they don't produce the error again. I tried this with neil and now neil works on both terminal

but the installed local hello still have that .cpcache file not found error on CMD and 'other' has different root on Powershell

borkdude commented 1 year ago

Manifest file not found for local/deps in coordinate #:local{:root "D:\keychera\projects\hello"}

This means that your project doesn't have a deps.edn file. Projects need to have deps.edn file to be able to use them as a library.

I'll have a look at the neil issue on Windows.

borkdude commented 1 year ago

Btw please specify your bb --version

keychera commented 1 year ago

bb --version babashka v1.1.173

and I tried setting up deps.edn, it works now! thank you very much personally for now, I only need to install as a local library but I'll leave this ticket open regarding the neil problem

borkdude commented 1 year ago

Just to be sure, can you try v1.2.174?

keychera commented 1 year ago

I just tried v1.2.174 and I got the same 'other' has different root error

borkdude commented 1 year ago

@keychera I can't reproduce the error with neil:

I re-installed bbin on a Windows machine. Then I ran: bbin install io.github.babashka/neil After restarting my cmd.exe terminal, I was able to execute neil.

Can you provide a detailed step by step report of what you are doing, so I can reproduce it? Let's start with only one problem and not several, as it's hard to keep track of all the details.

In fact, let's close this issue and please create a new issue for each problem.

borkdude commented 1 year ago

Ah wait, I think the issue may be that you are on a different hard drive than where neil is installed. I'll try that.

borkdude commented 1 year ago

I still can't reproduce:

U:\tmp>bbin uninstall neil
Removing C:\Users\borkdude\.babashka\bbin\bin\neil

U:\tmp>where neil
INFO: Could not find files for the given pattern(s).

U:\tmp>bbin install io.github.babashka/neil
{:coords
 #:git{:url "https://github.com/babashka/neil.git",
       :tag "v0.1.57",
       :sha "350c7ce94060bb0a6e57b32d35c37d9b17d88970"},
 :lib io.github.babashka/neil}

U:\tmp>neil
Usage: neil <subcommand> <options>

Most subcommands support the options:
  --alias      Override alias name.
  --deps-file  Override deps.edn file name.
keychera commented 1 year ago

Ok, I will get back to this when I got the chance, I will make a new issue if I can reproduce it again. Earlier, I also encounter that other error to some of my locally installed script after upgrading babashka that I had to reset back to the previous one I used, I will be reporting all the related findings

2023年3月6日(月) 2:43 Michiel Borkent @.***>:

I still can't reproduce:

U:\tmp>bbin uninstall neil Removing C:\Users\borkdude.babashka\bbin\bin\neil

U:\tmp>where neil INFO: Could not find files for the given pattern(s).

U:\tmp>bbin install io.github.babashka/neil {:coords

:git{:url "https://github.com/babashka/neil.git",

   :tag "v0.1.57",
   :sha "350c7ce94060bb0a6e57b32d35c37d9b17d88970"},

:lib io.github.babashka/neil}

U:\tmp>neil Usage: neil

Most subcommands support the options: --alias Override alias name. --deps-file Override deps.edn file name.

— Reply to this email directly, view it on GitHub https://github.com/babashka/bbin/issues/57#issuecomment-1455184664, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFRA2M63YJSCV643DQK4QX3W2TUEPANCNFSM6AAAAAAVPTS5OM . You are receiving this because you were mentioned.Message ID: @.***>

keychera commented 1 year ago

@borkdude I did a number of attempts and I can't seem to reproduce it consistently. The best I can describe it is that the error occassionally show up.

What I did was to duplicate the hello lib project above, rename bbin bin folder, and do all sort of bbin install to those hello projects in two terminal on different path: C:\Users\kyoga and D:\keychera\projects. I did this because I suspected the error is path related after reading the source code of sun.nio.fs.WindowsPath.relativize since this is the one that throws the error

Exception in thread "main" java.lang.IllegalArgumentException: 'other' has different root
        at java.base@19.0.2/sun.nio.fs.WindowsPath.relativize(WindowsPath.java:420)
        at java.base@19.0.2/sun.nio.fs.WindowsPath.relativize(WindowsPath.java:42)
        at borkdude.deps$relativize.invokeStatic(deps.clj:583)
        at borkdude.deps$_main.invokeStatic(deps.clj:795)
...omitted

and the error did show up, but only on some attempts out of all attempts that I did. One attempts flow like this

- in terminal `C:\Users\kyoga`
  - bbin install `D:/keychera/projects/hello`
  - hello  => this works
  - bbin install `D:/keychera/projects/hello2`
  - hello2 => this works
  - bbin install `D:/keychera/projects/hello3`
  - hello3 => this throws "other" error
- in terminal `D:\keychera\projects`
  - hello3 => now this works, why? 
- back to terminal `C:\Users\kyoga`
  - hello3 => this works now, why???

and this is not consistent and not always in that order, and the latest attempts that I did, the error did not even show up at all. So I don't know, I think I'll not make another issue for now since, well, the error stopped showing up which should be a good thing but somehow I feel defeated 😅 anyway thank you very much for helping me solving the original issue and everything else! 🙏

borkdude commented 1 year ago

If it happens again, please make another issue :)