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

bin-dir is not resolved correctly on Windows platform #19

Closed
littleli opened this issue Sep 4, 2022 · 2 comments
Closed

bin-dir is not resolved correctly on Windows platform #19

littleli opened this issue Sep 4, 2022 · 2 comments

Comments

@littleli
Copy link

littleli commented Sep 4, 2022

This is from Windows Terminal + Powershell:

~ $ bbin install io.github.rads/watch
----- Error --------------------------------------------------------------------
Type:     java.nio.file.AccessDeniedException
Message:  C:\Users\.bbin
Location: C:\Users\alesn\scoop\apps\bbin\current\bbin:61:3

----- Context ------------------------------------------------------------------
57:          (when-let [v (:local/root cli-opts)]
58:            {:local/root (str (fs/canonicalize v {:nofollow-links true}))})))
59:
60: (defn ensure-bbin-dirs [cli-opts]
61:   (fs/create-dirs (bin-dir cli-opts)))
      ^--- C:\Users\.bbin
62:
63: (ns babashka.bbin.scripts
64:   (:require [babashka.fs :as fs]
65:             [babashka.deps :as deps]
66:             [rads.deps-info.infer :as deps-info-infer]

----- Stack trace --------------------------------------------------------------
babashka.fs/create-dirs             - <built-in>
babashka.bbin.util/ensure-bbin-dirs - C:\Users\alesn\scoop\apps\bbin\current\bbin:61:3
babashka.bbin.util/ensure-bbin-dirs - C:\Users\alesn\scoop\apps\bbin\current\bbin:60:1
babashka.bbin.scripts               - C:\Users\alesn\scoop\apps\bbin\current\bbin:337:7
babashka.bbin.cli                   - C:\Users\alesn\scoop\apps\bbin\current\bbin:373:10
babashka.bbin.cli/bbin              - C:\Users\alesn\scoop\apps\bbin\current\bbin:403:5
babashka.bbin.cli/bbin              - C:\Users\alesn\scoop\apps\bbin\current\bbin:400:1
babashka.bbin.cli                   - C:\Users\alesn\scoop\apps\bbin\current\bbin:406:3
clojure.core/apply                  - <built-in>
babashka.bbin.cli                   - C:\Users\alesn\scoop\apps\bbin\current\bbin:409:3

Error reported on
https://github.com/babashka/bbin/blob/main/bbin#L61

But in fact the issue seems to be here
https://github.com/babashka/bbin/blob/main/bbin#L47

Looks like (fs/expand-home) is not working correctly and it forgets last component from the path. I'll do a bug report to babashka/fs too.

My recommendation is to get user directory from environment variables which are mutually exclusive on each platform, something along these lines:

(def ^:dynamic *bbin-root*
  (str (or (.get (System/getenv) "HOME")
           (.get (System/getenv) "USERPROFILE"))
  File/separator
  ".bbin"))

Probably just wait a moment to fs/expand-home to be fixed.

@littleli
Copy link
Author

littleli commented Sep 4, 2022

After short conversation with @borkdude it turned out fs/expend-home will be fixed with the very next release of bb

@rads rads closed this as completed in 52bc0d0 Sep 6, 2022
@rads
Copy link
Collaborator

rads commented Sep 10, 2022

Thanks for creating this issue. I bumped the minimum Babashka version to 0.9.162 and made sure we check this even in the generated bbin script.

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