I know this will seem like a duplicate question but I haven't found an answer besides check your path, and I could use some help. I am new to developing on Windows.
Path from PowerShell return:
$Env:PATH
...C:\Users\USERNAME\AppData\Roaming\npm;...
npm config return:
$npm config list
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc
prefix = "C:\\Users\\USERNAME\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\USERNAME\AppData\Roaming\npm\node_modules
; HOME = C:\Users\USERNAME
; Run `npm config ls -l` to show all defaults.
when I try to run git (or any module)
$git
git : The term 'git' 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
+ git
+ ~~~
+ CategoryInfo : ObjectNotFound: (git:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Here is a photo of the git module in my npm directory
What am I missing here?
Related
Cannot use the ls -la command in JupterNotebook's Terminal.
I am using the following command on JupterNotebook's Terminal to get all hidden files within the folder:
ls- la
Then this error popped up
Get-ChildItem : A parameter cannot be found that matches parameter name 'la'. At line:1 char:4
Can someone please explain the problem with my terminal? Is there any alternative for me to get the list of all files within the folder including the hidden files, specifically in JupterNotebook'sTerminal?
Thank you in advance.
If I start a PowerShell as a regular user (not admin) and run
cd Desktop
mkdir test
cd test
git init
cd ..
I then cant delete the folder via PowerShell. I have tried the following commands as admin and as the current user.
rm -r test # -> no access permission
rmdir test # -> no access permission
del -r test # -> no access permission
del test # -> no access permission
It prints
+ CategoryInfo : PermissionDenied: (.git:DirectoryInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
But I don't understand why I can't remove folders with a .git folder in them.
In order to remove [a directory that contains] hidden items, PowerShell's Remove-Item cmdlet requires passing the -Force switch:
Remove-Item -Recurse -Force test
The shortest form of this command (for interactive rather than scripting use), using the platform-neutral ri alias and PowerShell's so-called elastic syntax, where it is sufficient to specify a prefix of a parameter name (such as -r for -Recurse), as long as that prefix is unambiguous):
ri -r -fo test
Note how a two-letter prefix is required for -Force, because -f alone is ambiguous: it could also refer to the -Filter parameter.
git init creates a .git subdirectory that is assigned the Hidden attribute on Windows (on Unix-like platforms, the fact that the name starts with . alone makes the directory a hidden one).
On Windows, rm, del, rmdir are simply built-in aliases of Remove-Item, the single cmdlet used to remove both files and directories (removal of the latter requiring -Recurse if the directory is not empty).
(On Unix-like platforms, only del is defined as an aliases, so as not to shadow the platform-native rm and rmdir utilities.)
ri is a platform-neutral alias derived from the name Remove-Item, and therefore preferable.
To see all aliases defined for a given command use Get-Alias -Definition $name; e.g.:
Get-Alias -Definition Remove-Item
Note: While it is arguably beneficial for PowerShell to require explicit opt-in via -Force in order to delete hidden items - so that you don't accidentally delete items whose existence you may not be aware of - the error message is suboptimal, in that the problem isn't one of permissions.
I created a file by mistake, and for the life of me, I cannot remove it. If you have 7-Zip installed, you can produce it. If not, it is easy to install.
Here is how the file gets created:
PS C:\temp> mkdir abc
PS C:\temp> cd abc
PS C:\temp\abc> & 'C:\Program Files\7-Zip\7z.exe' a -spf .\DuoWindowsLogon.admx,.\en-us\DuoWindowsLogon.adml
Creating archive: .\DuoWindowsLogon.admx,.\en-us\DuoWindowsLogon.adml
Later, I learned the correct command I should type is:
& 'C:\Program Files\7-Zip\7z.exe' a abc.7z -spf DuoWindowsLogon.admx en-us\DuoWindowsLogon.adml
After realizing the error, I tried to remove the directory erroneously created:
PS C:\temp\abc> ls
d----- 11/15/2020 11:09 PM DuoWindowsLogon.admx,.
PS C:\temp\abc> ls D*
ls : Could not find item C:\temp\abc\DuoWindowsLogon.admx,..
PS C:\temp\abc> ls | rm
rm : Cannot find path 'C:\temp\abc\DuoWindowsLogon.admx,.' because it does not exist.
PS C:\temp\abc> rm *
rm : An object at the specified path C:\temp\abc\DuoWindowsLogon.admx,. does not exist.
PS C:\temp\abc> cd ..
PS C:\temp> rm -recurse abc
rm : Could not find a part of the path 'C:\temp\abc\DuoWindowsLogon.admx,'.
As you see, nothing worked. I also tried the file explorer (GUI), it does not work either. How can I have the directory deleted?
PS:
I tried "del /s" on CMD prompt, it did not produce an error but the file is not deleted:
c:\>del /s c:\temp\abc
c:\temp\abc\*, Are you sure (Y/N)? Y
c:\>dir c:\temp\abc
11/15/2020 11:09 PM <DIR> DuoWindowsLogon.admx,.
You can remove the directory that ends with a "." by prefixing it with \\?\
So, in your case you can use:
Remove-Item `\\?\C:\temp\abc\DuoWindowsLogon.admx,.` -Recurse
This is documented here: You can't delete a file or a folder on an NTFS file system volume
You may not be able to delete a file if the file name includes an
invalid name (for example, the file name has a trailing space or a
trailing period or the file name is made up of a space only). To
resolve this issue, use a tool that uses the appropriate internal
syntax to delete the file. You can use the "\\?\" syntax with some
tools to operate on these files, for example:
del "\\?\c:\<path_to_file_that contains a trailing space.txt>"
The cause of this issue is similar to Cause 4. However, if you use
typical Win32 syntax to open a file that has trailing spaces or
trailing periods in its name, the trailing spaces or periods are
stripped before the actual file is opened.
I had the same problem, plus an error 0x80004005.
Under Windows10, this worked for me:
rd /s "\\?\D:\Folder_1\Folder_2\File_Ending_with_dot."
As usually,we can use git status.But under some reasons,the cmd can't recognize git.So I need to use full path.Run where git,I got this:
C:\Program Files\Git\cmd\git.exe
How to use git full path?
If you just want to run git and do not have it in your PATH, just use:
"C:\Program Files\Git\cmd\git.exe" status
Like I stated in your other questions, you can handle everything like before.
C:\Program Files\Git\cmd\git.exe status
Creates the same output as
git status
Ofc when you run it in the cmd you have to use " since the Path to the .exe contains whitespace:
"C:\Program Files\Git\cmd\git.exe" status
Just replace git status with C:\Program Files\Git\cmd\git.exe status
Or in general replace git ... with C:\Program Files\Git\cmd\git.exe ...
I am trying to install the vsbuildtools in a docker container for windows. Unfortunately, even with the installPath the installer installs stuff everywhere.
I, therefore, have to do
Step 27/32 : COPY --from=SetupPhase C:\Windows C:\Windows
but it gives me this error:
docker : COPY failed: copy from c:\ or c:\windows is not allowed on
windows At line:1 char:1
+ docker build -m 2GB -t monamimani/msbuild .
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (COPY failed: co...owed on windows:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError Command executed with exception: COPY failed: copy from c:\ or c:\windows is not allowed on windows
Is there a way to solve this?
I found a workaround, where this doesn't work
COPY --from=SetupPhase ["C:\\Windows", "C:\\Windows"]
but this works
COPY --from=SetupPhase ["C:\\Windows\\assembly", "C:\\Windows\\assembly"]
So I just need to run a copy operation for each subfolder of c:\windows that I want to copy.
Check if this is a permission issue by trying another path, just for testing.
But do consider also "Dockerfile on Windows", which specifies, for the COPY command:
Windows Considerations
On Windows, the destination format must use forward slashes.
For example, these are valid COPY instructions.
COPY test1.txt /temp/
COPY test1.txt c:/temp/
However, the following will not work.
COPY test1.txt c:\temp\