Clojure installed, but clj fails - powershell

I installed Clojure via Powershell on Windows 10 and it installed without any errors. When I typed "clj" however, it gave me the following error:
clj : The 'clj' command was found in the module 'ClojureTools', but the module could not be loaded. For more
information, run 'Import-Module ClojureTools'.
At line:1 char:1
+ clj
+ ~~~
+ CategoryInfo : ObjectNotFound: (clj:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
I installed it to the following location: C:\Program Files\WindowsPowerShell\Modules
How can I resolve this error?

I think you need to do run:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Because your system does not allow execution of downloaded scripts. Of course decision about how much this is secure for you is completely up to you.
I'd recommend to check this tutorial, written by me:
https://github.com/littleli/scoop-clojure/wiki/Getting-started
It provides alternative, and more convenient way to install Clojure. Also it provides easy path for updates and enables access to a growing amount of utilities that you may find helpful.
Finally. If you have access to Windows Subsystem for Linux (WSL2), I'd probably go in that direction.

Related

PowerShell cannot open shim file for read

I have installed scoop in my Windows PowerShell for ability to install some apps.
When I install app and then try to run it I get an error that there is no possibility to find shim file. 'C:\Windows\System32\apps\scoop\new' from my logs actually really doesn't exist. Maybe somebody had the same problem. I have found a clue that scoop could be out of date. I checked it and it really is but I cannot update it because i have still the same problem that it cannot read shim file.'scoop config rm SCOOP_REPO' also doesn't help. Any idea how to solve this problem?
PS C:\Windows\System32\apps\railway\current> scoop update
Updating Scoop...
Cannot open shim file for read.
Could not read shim file.
Remove-Item : Cannot find path 'C:\Windows\System32\apps\scoop\new' because it does not exist.
At C:\Windows\System32\apps\scoop\current\libexec\scoop-update.ps1:79 char:13
+ Remove-Item $newdir -Force -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Windows\System32\apps\scoop\new:String) [Remove-Item], ItemNotFoun
dException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
Scoop download failed. If this appears several times, try removing SCOOP_REPO by 'scoop config rm SCOOP_REPO'

How to run IoTCorePShell.cmd

I try to port Prolific USB to COM converter for solve my other problem: List UART -> COM converter in Windows Device Portal
I found this manual: https://learn.microsoft.com/en-us/windows/iot-core/learn-about-hardware/peripheraldrivers and copied all necessary files to separate folder:
oem6.inf
ser2pl64.sys
serenum.sys
I installed:
Windows 10 IoT Core Packages
Windows Assessment and Deployment Kit including Windows PE add-on
Now I try to launch IoTCorePShell.cmd for run New-IoTInf2Cab as mentioned in the manual.
I tried both cmd and Power Shell, both with administrator rights and without.
In Power Shell I get:
PS C:\Users\olga\Desktop\COMDriver> New-IoTInf2Cab
New-IoTInf2Cab : The term 'New-IoTInf2Cab' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ New-IoTInf2Cab
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-IoTInf2Cab:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
How can I run New-IoTInf2Cab?
OK, it was necessary to clone the repository.
The IoTCorePShell.cmd stay in the root.
https://github.com/ms-iot/iot-adk-addonkit

file cannot be loaded because the execution of scripts is disabled on this system

File C:\Users\Acer\Desktop\Projelerim\BEM_CANLI\BEM\packages\EntityFramework.5.
0.0\tools\init.ps1 cannot be loaded because its execution is blocked by softwar
e restriction policies. For more information, contact your system administrator.
At line:1 char:44
+ $__pc_args=#(); $input|%{$__pc_args+=$_}; & <<<< 'C:\Users\Acer\Desktop\Proj
elerim\BEM_CANLI\BEM\packages\EntityFramework.5.0.0\tools\init.ps1' $__pc_args[
0] $__pc_args[1] $__pc_args[2]; Remove-Variable __pc_args -Scope 0
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
I get above error in package manager console. I found some solution, but I cant fix it. I tried followings
PowerShell says "execution of scripts is disabled on this system."
http://sqlish.com/file-ps1-cannot-be-loaded-because-the-execution-of-scripts-is-disabled-on-this-system-please-see-get-help-about_signing-for-more-details/
I changed execution policy,
But I allways get the same error.
It's possible that you changed the execution policy for 64-bit powershell and the package manager is running 32-bit (or vice versa).
I'd try opening 32-bit console (PowerShell (x86)) and setting the execution policy there, as the error is definitely pointing to that kind of resolution.
Make sure you restart visual studio after changing execution policy so that changes can take effect. Also make sure you changed execution policy globally with administrator username and password.
We have been facing the same issue today with Visual Studio 2017 and Entity Framework 6, and none of the solutions proposed here has worked. As a workaround, this is the temporary solution we found to be able to use Entity Framework commands in the Package Manager Console:
Execute the following commands in the Package Manager Console
Set-ExecutionPolicy -Scope Process Bypass
Import-Module "your-solution-directory/packages/EntityFramework<your EF version>/EntityFramework.psd1"
Actually, the Import-Module command is what the init1.ps1 script does.

Test to check if Cmdlet is Supported

I have a powershell script that keeps throwing this error
Get-ComputerRestorePoint : This functionality is not supported on this operating system.
At line:1 char:25
+ Get-ComputerRestorePoint <<<<
+ CategoryInfo : InvalidOperation: (:) [Get-ComputerRestorePoint], ArgumentException
+ FullyQualifiedErrorId : GetComputerRestorePointNotSupported,Microsoft.PowerShell.Commands.GetComputerRestorePoin
tCommand
Is there a simple way to test to see if a cmdlet is supported before running it? I know I can throw a try catch around the cmdlet, but it this approach seems rather expensive compare to a simple check.
Thanks
You can easily check if a cmdlet is available in your session (using Get-Command) but there is not a direct way to test if an available cmdlet supports the current OS. The help notes section for this cmdlet says:
NOTES
To run a Get-ComputerRestorePoint command on Windows Vista and later versions
of Windows, open Windows PowerShell with the "Run as administrator" option.
This cmdlet uses the Windows Management Instrumentation (WMI) SystemRestore
class.
However I wouldn't rely on the Notes being accurate. The best I can think of is what you suggest, use try/catch.

msbuild calling powershell script under windows 7 gets signing error

We have a powershell build script that calls out to other scripts that is giving me trouble under Windows 7 64 bit. It works fine under XP. I've run set-executionpolicy to RemoteSigned (and also tried it with Bypass and Unrestricted). I can pull the command line from the error message and run it myself and it all runs fine.
Build errors look terrible here; but I'm including them anyway for completeness.
Project "C:\dev7\Source\DashPortal\DashboardGenerator\DashboardGenerator.csproj" (2) is building "C:\dev7\Source\DashPo
rtal\DashboardController\DashboardController.csproj" (15) on node 0 (default targets).
File C:\Users\pmckinney.NA\Documents\WindowsPowerShell\profile.ps1 cannot be lo
aded because the execution of scripts is disabled on this system. Please see "g
et-help about_signing" for more details.
At line:1 char:2
+ . <<<< 'C:\Users\pmckinney.NA\Documents\WindowsPowerShell\profile.ps1'
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
File C:\dev7\Source\DashPortal\DashboardController\..\..\..\Build\createReportI
nstallScript.ps1 cannot be loaded because the execution of scripts is disabled
on this system. Please see "get-help about_signing" for more details.
At line:1 char:87
+ C:\dev7\Source\DashPortal\DashboardController\..\..\..\Build\createReportInst
allScript <<<< -t C:\dev7\Source\DashPortal\DashboardController\..\..\..\Sourc
e\DashPortal\DashboardReports\ReportSetupScriptTemplate.sql -l C:\dev7\Source\D
ashPortal\DashboardController\..\..\..\Source\DashPortal\DashboardReports\Repor
tSetupReportList.xml -c C:\dev7\Source\DashPortal\DashboardController\..\..\..\
Source\DashPortal\Config
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
C:\dev7\Source\DashPortal\DashboardController\DashboardController.csproj(265,5): error MSB3073: The command "powershell
C:\dev7\Source\DashPortal\DashboardController\..\..\..\Build\createReportInstallScript -t C:\dev7\Source\DashPortal\Da
shboardController\..\..\..\Source\DashPortal\DashboardReports\ReportSetupScriptTemplate.sql -l C:\dev7\Source\DashPorta
l\DashboardController\..\..\..\Source\DashPortal\DashboardReports\ReportSetupReportList.xml -c C:\dev7\Source\DashPorta
l\DashboardController\..\..\..\Source\DashPortal\Config" exited with code 1.
Just guessing: You did run Set-ExecutionPolicy in your x64 PowerShell and the build runs the x86 PowerShell?
Maybe try Get-ExcutionPolicy in both shells.
Edit: oops, I see you already enabled scripts. It's possibly something to do with the context under which MSBuild is running. Are you running MSBuild as a local service account of some kind?
Edit2: It's clear the error message is deceptive. There's something else going on and the execution policy error is being thrown but not for the expected reason. Perhaps as a way to isolate, try creating another MSBuild task that runs the same line but with shorter, hardcoded paths instead of the /../../../ bonanza above?