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

Issues running installed script on Windows 10 #57

Closed
keychera opened this issue Mar 4, 2023 · 19 comments
Closed

Issues running installed script on Windows 10 #57

keychera opened this issue Mar 4, 2023 · 19 comments

Comments

@keychera
Copy link

keychera commented Mar 4, 2023

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
  1. 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
  1. 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
Copy link
Author

keychera commented Mar 4, 2023

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

  • bbin install io.github.rads/watch --latest-sha
  • bbin install org.babashka/http-server --mvn/version 0.1.11
  • bbin install io.github.borkdude/quickblog --tool --ns-default quickblog.api
  • bbin install foo.clj
  • bbin install https://gist.githubusercontent.com/keychera/6a35d8f30328cdcff2e6c7cca8f7b536/raw/8852f3585c0b1fa4805aa68dc0d35624873dafd8/panas.file-server.clj

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

@borkdude
Copy link
Contributor

borkdude commented Mar 4, 2023

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

@borkdude
Copy link
Contributor

borkdude commented Mar 4, 2023

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

@borkdude
Copy link
Contributor

borkdude commented Mar 4, 2023

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

@keychera
Copy link
Author

keychera commented Mar 4, 2023

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
Copy link
Contributor

borkdude commented Mar 4, 2023

OK, I see the issue and will provide a PR

@borkdude
Copy link
Contributor

borkdude commented Mar 4, 2023

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

@keychera
Copy link
Author

keychera commented Mar 5, 2023

@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 [email protected]/java.io.FileInputStream.open0(FileInputStream.java)
        at [email protected]/java.io.FileInputStream.open(FileInputStream.java:219)
        at [email protected]/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
Copy link
Contributor

borkdude commented Mar 5, 2023

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 borkdude reopened this Mar 5, 2023
@borkdude
Copy link
Contributor

borkdude commented Mar 5, 2023

Btw please specify your bb --version

@keychera
Copy link
Author

keychera commented Mar 5, 2023

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
Copy link
Contributor

borkdude commented Mar 5, 2023

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

@keychera
Copy link
Author

keychera commented Mar 5, 2023

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

@borkdude
Copy link
Contributor

borkdude commented Mar 5, 2023

@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 borkdude closed this as completed Mar 5, 2023
@borkdude
Copy link
Contributor

borkdude commented Mar 5, 2023

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
Copy link
Contributor

borkdude commented Mar 5, 2023

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
Copy link
Author

keychera commented Mar 6, 2023 via email

@keychera
Copy link
Author

keychera commented Mar 6, 2023

@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 [email protected]/sun.nio.fs.WindowsPath.relativize(WindowsPath.java:420)
        at [email protected]/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
Copy link
Contributor

borkdude commented Mar 6, 2023

If it happens again, please make another issue :)

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

No branches or pull requests

2 participants