I installed cygwin on Windows10 and it works fine. Then I install apt-cyg package manager. The problem is apt-cyg is not recognized when running it from command prompt, but it works when I run it from cygwin terminal. All other basic cygwin command is working fine in windows command prompt except apt-cyg.
What is wrong ?
$ file apt-cyg
apt-cyg: Bourne-Again shell script, ASCII text executable
As it is a bash script, CMD does not know how to handle it; CMD only knows how to handles .exe cygwin programs.
Cygwin terminal runs bash shell interpreter, that of course knows how to manage a bash script. Also the other cygwin shell interpreters know how to rise bash for the execution of cyg-apt following the #! mechanism
$ head -n 1 apt-cyg
#!/bin/bash
Related
I am working in WSL Ubuntu
When i execute command directly, show wrong path
C:\Users\Administrator>bash -c 'pwd'
/
Expected output :
C:\Users\Administrator>bash -c 'pwd'
/mnt/c/Users/Administrator/
How to fix this
I'm not able to reproduce this on any of my systems. Is it possible that you have a cd / (or equivalent) somewhere in one of your startup scripts?
First, let's change that to use wsl.exe command in place of the deprecated bash.exe command:
wsl pwd
That should give you the same (wrong) result that you are already seeing, but let's confirm that.
Then, to start WSL and tell Bash to not execute your startup scripts, try:
wsl -e bash --noprofile --norc -c pwd
Then try the shorter:
wsl -e pwd
The -e/--exec argument tells WSL to run the command in place of the shell, so Bash (and its startup files) should never get called in the first place.
I have kotlin script (but it can be any Linux command with arguments) for example:
#!/usr/bin/env kotlinc -script
println("hello world")
When I run it in Ubuntu I get:
/usr/bin/env: ‘kotlinc -script’: No such file or directory
but when I run in command line:
/usr/bin/env kotlinc -script
It works. It is no problem with finding path because script:
#!/usr/bin/env kotlinc
println("hello world")
works
For some reason under Ubuntu "#!/usr/bin/env kotlinc -script" treats "kotlinc -script" as single argument. But only in shell script header.
I need explicitly to run my script "#!/usr/bin/env kotlinc -script" because I want it to run properly on other distributions end environments where "kotlin" is in $PATH.
Is there a bug in Ubuntu coreutils or sth? Is there a way to fix it?
On Linux, you can't pass more than one argument via the shebang line. All arguments will be passed as a single string to the executable:
#!/bin/foo -a -b -c
will pass one option "-a -b -c" to /bin/foo, plus the contents of the file. Like if you would call:
/bin/foo '-a -b -c' contents-of-file.txt
The behaviour should be the same on most unix derivates nowadays, but it can differ, I haven't tested them all :)
It's hard to find proper documentation for this, the best I could quickly find was this: https://www.in-ulm.de/~mascheck/various/shebang/#splitting
As a workaround you would normally create a shell wrapper:
#!/bin/bash
exec kotlin --arg1 --arg2 ... /path/to/kotlin-script
Check your coreutils version:
apt-cache policy coreutils
Starting with coreutils 8.30 you will be able to use:
#!/usr/bin/env -S command arg1 arg2 ...
You may want to upgrade your coreutils
For me the solution was to install kotlin, since I did not yet have installed it and just downloaded https://github.com/bernaferrari/GradleKotlinConverter
and thought it should work.
sudo snap install kotlin --classic
I add the bin of git bash into my path in windows7 for the purpose of using linux command in windows. Other commands like ls, mkdir work fine but when I run "pwd" windows can't execute it. I found there is no pwd.exe in the bin directory. So I want to ask where I could download this file or if there is any better way to fix it? Thanks.
in windows de equivalent command for pwd is path. Change pwd with path
A better way of using linux commands on windows is using Cygwin. It will not only allow you to run pwd and other linux commands but it will also make your windows command line as powerful as the linux terminal.
Check out the link below:
https://www.cygwin.com
For Command Prompt in windows which is equivalent of Terminal, you can use cd , instead of pwd... and dir instead of ls.
I am not sure I understand correctly from the readme file how to install vim onto my mac. After installation, I still cannot seem to open files while typing gvim HelloWorld.c into terminal. How can I permanently fix the gvim command for terminal to recognize all the time?
Mac OS X already ships with a slightly underpowered but perfectly working vim build so you only have to issue that command in your terminal:
$ vim filename
MacVim is a more featureful version that comes with a GUI and a CLI executable. Is that what you installed?
The archive you downloaded contains MacVim.app and a shell script called mvim.
If you don't plan to use Vim in or from your terminal, you don't need that mvim script at all.
If you do, the simplest solution is to put that script somewhere in your $PATH. To do so, check the value of $PATH with the following command:
$ echo $PATH
and copy the script into one of the listed directories:
$ cp /path/to/mvim /some/directory/mvim
After that's done, you can call the MacVim GUI from your terminal with:
$ mvim filename
or the MacVim CLI with:
$ mvim -v filename
I just installed cygwin and zsh from the cygwin installer.
I launch C:\cygwin\bin\zsh.exe from the file explorer.
When zsh is launch for the first time, a small configutation is prompted.
I choose the minimal config by choosing : "Exit, creating the file ~/.zshrc containing just a comment. That will prevent this function being run again."
Now trying to use zsh, but I always have the "command not found" error
$ ls
zsh: command not found: ls
I don't understand why zsh can't do anything directly after the first launch.
How configure zsh to use all the cygwin bin commands located in the same folder C:\cygwin\bin ?
You need to invoke zsh as a login shell, by passing the --login or -l option. This tells it to source /etc/zprofile, which is where the search PATH is configured. You can do that by creating an Explorer shortcut to zsh.exe and adding the option to the target field.