This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-04
Channels
- # announcements (8)
- # babashka (78)
- # beginners (15)
- # calva (6)
- # cider (12)
- # clerk (1)
- # clojure (46)
- # clojure-dev (13)
- # clojure-europe (15)
- # clojure-norway (5)
- # clojure-portugal (1)
- # clojure-uk (1)
- # clojurescript (23)
- # clr (29)
- # conjure (4)
- # core-async (10)
- # cryogen (1)
- # data-science (8)
- # hoplon (4)
- # hyperfiddle (11)
- # introduce-yourself (3)
- # jobs (6)
- # kaocha (12)
- # lsp (11)
- # malli (8)
- # membrane (11)
- # releases (1)
- # shadow-cljs (20)
- # spacemacs (47)
- # tools-deps (1)
Can someone help me understand this?
(-> "GOOGLE_APPLICATION_CREDENTIALS" ;; envvar
(System/getenv)
(java.io.File.)
.exists) ;; => false
(-> "./tokens/StoredCredential"
(java.io.File.)
.exists) ;; => true
I am not aware of how/why the existence of a file would be conditional upon the directory I'm in. (The envvar in the first snippet is set to the absolute path of the file in the second.)What is the value of (-> "GOOGLE_APPLICATION_CREDENTIALS" (System/getenv))
out of curiosity?
And a wild guess: could there be directories in the full path that you do not have read/search permissions for?
@U0CMVHBL2 "~/Documents/clojure/writing-workflow/tokens/StoredCredential"
and re: permissions, that seems unlikely to me, this is my personal machine and I'm the root user. But then again I wouldn't bet money on it.
~ is a shell thing, not a feature of the underlying filesystem, the shell often expands it away, and some non-shell code also supports it, but the jvm does not
Good to know about ~ here. I used .getCanonicalPath
on the file object I created from the envvar and I got back the absolute path of the file appended to the path of my working directory. Is that to be expected?
calling getCanonicalPath makes it absolute, by prepending the current working directory
The file object represents a file named "foo" in a directory named "~" under "/home/kevin"
Seems best to change the value of the env var to not use ~
if you want fewer headaches.
Either that, or write special code for interpreting ~
in the value of any env vars that you want to support it, yourself, explicitly.
Yeah, I did already. I put it in my .bashrc
as an absolute path and it works now. Thanks @U0NCTKEV8 @U0CMVHBL2 🙏:skin-tone-2: