When I run ruby -v in cygwin, it shows me the ruby which I have installed in windows. FYI - I never installed any ruby as a part of my cygwin installation.
But when I run gem list, I get the error:
/cygdrive/c/ruby/bin/gem:
C:/dev/ruby/bin/ruby.exe^M: bad interpreter: Permission denied
I Googled and found this problem a lot. But there is no one who explained what it means and why it happens. Can someone please answer those questions for me and help me to fix this problem?
Thank you very much !
Under cygwin, your best bet is to run the cygwin version of ruby, installed using the cygwin setup tool.
You can use regular ruby, but you will have interoperability issues like this.
What you are seeing here is the shell complaining about a ^M at the end of the "shebang" line of the gem script (first line that tells it what interpreter to use). This ^M is an artefact of the windows environment where all lines end with this character as well as just the newline character that unix uses on its own.
You could solve this problem by removing the newlines e.g. by using dos2unix command on gem but it won't be long before you run into further issues ...
Related
Can someone help me out?
So I installed Ruby 2.4 on my PC via the RubyInstaller from https://rubyinstaller.org/downloads/. I have Windows 10.
I've used Ruby 2.2 and this 2.4 version seems very different.
When I installed it, it created an MSYS2.exe and it now opens a bash shell.
I've not used a bash shell in a very long time (14+ years). I can navigate fine in it. But I receive the following error message when I try to run a ruby file:
$ ruby r1.rb
bash: ruby: command not found
I'm not sure how to run a ruby script on the bash shell from MSYS. I have added the C:\Ruby24-x64\bin to my environment variables. But I still get the same message.
I'd appreciate some assistance if possible. Thanks.
I'm using cygwin installed on Windows 10 and trying to access awscli from it.
I used pip install awscli to install awscli. This installed awscli. I then tried to run only aws to see if it is installed and I get the following error:
-bash: /cygdrive/c/Program Files/Anaconda2/Scripts/aws: C:\Program: bad interpreter: No such file or directory
I'm not sure why this is happening. Any help in this regard would be highly apreciated.
This is still an issue even with the latest version of AWS cli. So after some trial and error I found a pretty good workaround that will not make you switch your favorite shell.
First, make sure python is on your PATH. That is from anywhere in the system you can just run python and it work.
Find the aws script and open it for editing (for me it was located in c:\Program Files\Python36\Scripts\aws) and change the hashbang (that would be the first line in the script) to #!python.exe. For me it was set to #!c:\Program Files\Python36\python.exe. That space in the middle of Program Files caused the issue when that path got converted to Linux like path. Changing it to #!python.exe sidesteps the issue.
When you update AWS cli, repeat the workaround.
PS. You could also avoid this issue by installing python somewhere in a folder without spaces in path. That requires to reconfigure your system, so I did not do that myself.
I would install the standard python and ensure it is coming up first in your path with which python and which pip. Path issues like this are due to mixing and matching executables targeting different platforms in my experience. Certain commands do not implement functionality to convert paths from Windows to Linux and back (it appears your specific commands are failing on spaces).
Since you say you are on Windows 10, if you have the anniversary edition, I would recommend Windows Subsystem for Linux over cygwin. You will likely see less Windows issues on WSL since it uses the exact same ubuntu packages you would use on Linux instead of the cygwin port and maps them low level to the NT Kernel.
The Problem comes from "Program Files" having a space. This is something that is related to cygwin (I encountered the same error with git bash on windows). In a script I had something like this:
#!/c/Program Files/some_program/executable.exe
Escaping the space with a backslash or using quotes didn't work.
The solution is to use the DOS' short filename:
Progra~1 for "Program Files"
Progra~2 for "Program Files (x86)"
So my line would turn into:
#!/c/Progra~1/some_program/executable.exe
In Windows:
cd .. to go to home directory which shows pwd as /.
Now, cd to /cygdrive/c/Program\ Files/Anaconda2/Scripts
Now, run: python aws configure
Example:
user#user /cygdrive/c/Program Files/Anaconda2/Scripts
$python aws configure
Before I start, let me say that I looked at all the similar questions and it appears that no one had this particular problem:
I installed git.
Next I ran this from the command line:
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
My result is
bash: line 151: git: command not found
bash: line 153: git: command not found
ERROR: Unable to clone the RVM repository, attempted both git:// and https://
What did I do wrong here? I am attempting to install this on osx Lion.
Additionally, can someone explain to me what the beginning of the bash command does? bash < <(...)
Just for my own curiosity :)
Thanks!
You need to have git installed first. The command executes the script downloaded with curl from the given url using bash. The <(...) is apparently used to provide a list of commands as per http://tldp.org/LDP/abs/html/process-sub.html.
You either installed git wrong, or it's not in your path. Have you installed XCode? It should automatically install git 1.7.4 and put it in your path. You'll also need to have XCode installed to be able to compile any ruby versions using RVM.
I would like to install ruby from the command line. I don't mind where it gets installed from but I guess Here would probably be the best place.
The aim is to use ocra to provide a one click installer that runs a ruby script through the command line. Using the backsticks `` arguments method in ruby to install a list of gems along with it. This way, should I decide to change computer, I can run the ruby install as a .exe file and it will do it all for me.
Will this method work? What do you think? What would the command be to actually download and run the rubyinstaller" from the command line?
I am running windows XP.
For automatically pulling down from the web, you can try wget for windows. Then you can point it at the installer url.
Edit: (thanks to excellent suggestion by Ninjaxor)
You can then invoke installer via either the /silent or /verysilent command line options.
On my Mac OSX 10.6 machine, I started to use MacVIM for vim. Then I noticed my terminal version was different to the MacVIM version (MacVIM was 7.3 and my terminal version 7.2)... I thought they used the same vim?
I need 7.3 for some of the features. So I set about wanting to update the terminal version. I basically cloned it using Mercurial (the perferred way according to the official site) and then did the usual to compile it. This did work and I now have 7.3 in my terminal. But, on some commands when exiting, I can this error:
/bin/bash: q: command not found
shell returned 127
Press ENTER or type command to continue
...I've tried my hardest to try and fix this problem, but trying to reinstall MacVIM, deleting the vim in my /usr/local/bin and compiling again and I just can't get rid of this annoying error.
Can anyone possibly help me? Am I doing this all wrong? ...most of the time I will be using MacVIM, but it'd be nice for me to have it in the Terminal - exactly how I'd have it on my Ubuntu servers.
Any help would be fantastic!
:!q is not :q!. This is probably not a bug.
The error message you're seeing is is most likely the result of accidentally typing :!q instead of :q!, which would be user error, not a bug. :!q shells out to run q, and your shell (bash) is not finding such a command and bails with 127. (For comparison, you might try :!true, :!false, :!vim %, to get a feel of this.)
There isn't really a “fix” for this, and ! is really useful for other purposes; maybe with more practice you'll make the typo less often. You could also try using ZQ instead of :q!; this has other disadvantages (a typo ZZ will instead save the file if it's edited, and ZQ specifically is a vim extension), but at least you see this error again.
The upshot here is basically check to make sure you typed in your commands right, I guess.
I'm not sure on the exact path, but somewhere a few folders deep into the Applications/MacVim.app folder is the vim executable that will also run in a terminal (Use the -g option to launch it in GUI mode).
You should be able to throw this in your .bashrc:
alias vim=/Applications/MacVim.app/Contents/MacOS/vim
This is the homebrew formula for vim. Try these settings for "configure" or just install homebrew and install vim from there.
system "./configure", "--prefix=#{prefix}",
"--mandir=#{man}",
"--enable-gui=no",
"--without-x",
"--disable-nls",
"--enable-multibyte",
"--with-tlib=ncurses",
"--enable-pythoninterp",
"--enable-rubyinterp",
"--with-features=huge"
system "make"
system "make install"