clj-on-windows 2020-12-17

OK, thanks for the clarification on where scoop puts its modules. Yes, I see that file. clj works provided I change the execution policy, but when I change it back to default and restart power shell, I get that error message again that it can't load the ClojureTools module.

hmm, i don't understand how that works to be of much use, sorry. on a possibly related note, from the traditional non-powershell prompt, does cmd-clj work for you with the execution policy set to the default? (i believe that's a shim prepared by scoop.)

@puzzler if you have Windows clojure problems and you are already using scoop, you could try to scoop install babashka and then try:

bb --clojure -M -e (+ 1 2 3)
for example. Babashka now ships with a clojure runner as well which may work better in some circumstances on Windows (e.g. in cmd.exe)

Could be useful for debugging

cmd-clj : File C:\Users\Mark\scoop\shims\cmd-clj.ps1 cannot be loaded because running scripts is disabled on this
system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ cmd-clj
+ ~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

the babashka clojure stuff doesn't use powershell which is a recurring reported problem

@puzzler you could try: Set-ExecutionPolicy RemoteSigned

I just installed babashka, but I don't know much about it. Does it take similar command line args as clj?

Yes, setting the execution policy like you describe definitely works, I just don't understand the implications of leaving it like that, so am reluctant. My hope was to find something where I could set the execution policy just for install, and then put it back to default and still be able to run clj.

Do people generally feel like RemoteSigned is safe for leaving on?

@puzzler The newest babashka has a --clojure option which then takes the same args as the official clojure CLI. It invokes the same tools.deps.alpha jar.

That worked great! Thanks.

@puzzler this is execution policity I currently have:

~ $ Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine    RemoteSigned

@puzzler it's a common configuration change particularly for anyone who needs to do dev or administrative tasks in PowerShell. There's actually a GUI toggle for it through the Settings app under Settings > Update & Security > For developers > PowerShell, to give you an idea of how regularly people change it.

I tried the scoop instructions, and the install appeared to work, but when I restarted powershell, I saw no evidence of the installation, nor could I find a directory in the modules folder associated with scoop.

I'm considering Sean's suggestion of WSL2, but figured I'd try the easier install processes first.

fwiw, this is the sort of output i get when installing via scoop:

Installing 'clojure' (1.10.1.754) [64bit]
clojure-tools-1.10.1.754.zip (16.7 MB) [======================================================================] 100%
Checking hash of clojure-tools-1.10.1.754.zip ... ok.
Extracting clojure-tools-1.10.1.754.zip ... done.
Linking ~\scoop\apps\clojure\current => ~\scoop\apps\clojure\1.10.1.754
Creating shim for 'cmd-clojure'.
Creating shim for 'cmd-clj'.
Installing PowerShell module 'ClojureTools'
Linking ~\scoop\modules\ClojureTools => ~\scoop\apps\clojure\current
'clojure' (1.10.1.754) was installed successfully!

when i look in C:\Users\user\scoop\modules\ClojureTools i see some relevant looking bits

restarting powershell (the windows one) gives an environment that allows clj to work it seems -- i wonder what's different