how to make cygwin build program in windows use windows path - cygwin

I built and installed a program with cygwin in windows, but the program can not find windows style paths and must use /cygdrive
I just want to know how to spare this burden
The problem is this:
C:\Documents and Settings\Administrator>protoc -If:
f: warning: directory does not exist.
Missing input file.
C:\Documents and Settings\Administrator>protoc -I/cygdrive/f
Missing input file.

This is the common problem with windows stuff, it always uses spaces in paths. Two solutions:
1st. Open your cygwin (black one) terminal and type (I suppose you will be in your home directory):
cp /etc/dev/etc/skel/.bash* .
this will copy all the bash files you need to your current directory to "handle" your cygwin system. To know where you are in your cygwin (ie. the path to your current directory) type "pwd" (without the quotes) and press Enter (or Return for some people).
2nd. Open the .bashrc file already copied and type (I use "vi" editor for this but you can use "pico" which is a bit easier):
alias C="C:\Documents\ and\ Settings\Administrator"
save the .bashrc ("Ctrl+X" in pico I think, and :wq in "vi") and close the terminal. After restarting this console, typing "C" and pressing enter will send you automatically to "C:\Documents and Settings\Administrator"
To know which alias you have, just type "alias" in your terminal and all your alias will show up.
HTH,

Related

Anaconda fedora install: conda: command not found

I've installed Anaconda and have added the environment variable export PATH="~/anaconda/bin:$PATH" to my .zshrc but still can't run any 'conda' commands in my terminal. I have followed these commands(source) to install anaconda.
# Go to home directory
cd ~
# You can change what anaconda version you want at
# https://repo.continuum.io/archive/
wget https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh
zsh Anaconda3-4.2.0-Linux-x86_64.sh -b -p ~/anaconda
rm Anaconda3-4.2.0-Linux-x86_64.sh
echo 'export PATH="~/anaconda/bin:$PATH"' >> ~/.zshrc
# Refresh basically
source ~/.zshrc
Am I missing anything?
This kind of issue often arise due to incorrect paths to your Python distribution. Basically, your computer does not know where to look for the correct file or program and you need to tell it where to look using your system's $PATH variable. You will thus need to manually set the paths by editing your .profile or .rc file. The most commonly used shell is bash. Both Anaconda and Canopy assume you're running the Bash shell and will put the path to your install there.
The steps below worked for me on Mac, it should work on Linux as well:
1. Go to your home directory by typing cd ~ from the prompt, or by open that same directory in Finder.
2. Now get a list of all the files in this folder, including the hidden ones:
ls -la
or, directly in Finder (without the "+"):
CMD + SHIFT + .
Now, you probably have (a) both the .profile and .bash_profile, or (b) just one of them, or (c) none of them:
3.a If you are using Bash, you're looking for files called .profile and .bash_profile. Which you have will depend on your system configuration. If you have both, this is probably the root cause of your problem; .bash_profile overrides .profile if both are present. In this case, open .profile and copy everything you find inside across to .bash_profile.
3.b If you only have one of .bash_profile or .profile, open it in an editor and have a look. You're looking for any obvious references to Python or your distribution (Anaconda, Canopy) on any of the uncommented-out lines. You'll probably see several lines that look something like:
PATH="Users/<your user name>/Library/...:${PATH}"
export PATH
In the rare case that you don't see any reference to Anaconda at all, you will need to add the lines yourself. Add, for example, the following to the file:
export PATH=~/anaconda/bin:$PATH
3.c If it turns out that you don't have any of the files, you would have to create one by yourself. Do this by entering touch .bash_profile in the prompt, or, simply right click and create a new file directly in Finder. Add the following to the file (same as in (b)):
export PATH=~/anaconda/bin:$PATH
4. Save the file. Quit and restart any program that use Python (including the Terminal window), and you should be good to go.
More detailed info here (including for Windows):
https://github.com/landlab/landlab/wiki/Correcting-Install-Paths

Location of .bashrc for "Bash on Ubuntu on Windows" in Windows 10

Microsoft just introduced a Linux subsystem in its Windows 10 Anniversary Edition. The installation is pretty straight forward, but I could not locate bash files on Windows.
How does it work? What does ~ refer to in Windows? Where to find .bashrc?
Since the Windows 10 Fall Creators Update, the location changed to:
C:\Users\USERNAME\AppData\Local\Packages\{DIST}\LocalState\rootfs\home\{LINUXUSER}\
Where:
{DIST} is equal to CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
{LINUXUSER} is the user for which you are looking for the .bashrc file
Just for anyone wondering that came here from Google.
Sorry for the misunderstanding, I check on google and it will be at C:\Users\USERNAME\AppData\Local\Lxss\home\USERNAME .
I tried and it works, in the cmd just type cd\ && dir *bashrc* /s it will locate the file, and in my case i see the line C:\Users\USERNAME\AppData\Local\Lxss\home\USERNAME but when I want to navigate it with the window browser it doesn't work, but if you copy paste it, it works :-)
I found it here.
Considering that you need to know where a file is located you can use the find command.
The syntax of the command is find {search-path} {file-names-to-search} {action-to-take}by default the action to take is printing the file name.
So if you are finding .bashrc file you can use find / -name .bashrc the bash will return you /home/yourusername/.bashrc
Also, if you want to access to your home directory you can use cd ~
Hope my answer will be helpful :-)
just type
vi ~/.bashrc
and that should put you into the file where ever it is.
You can navigate there simply by doing cd ~
List all files with ls -a and you should be able to see it.
~ means that is user home folder, way like /home/%username%/
you can list files like ls -al and see .bashrc file.
Right now on WSL 2 you can find it under /home/{user_name} and the file is hidden.
You can access it from Ubuntu console by {text_editor} .bashrc
If you want to edit that in Windows just type in ubuntu console explorer.exe . and it opens the current folder and shows all hidden files.
It's weird but works fine.
Other answers doesn't work for me using WSL 2.
The LocalState folder contains a virtual disk so rootfs does not exist,
and AppData\Local folder does not have the Lxss folder.
The solution for me is surprisingly simple:
wsl -u root
This will allow you to get into wsl as root.
From here, you have access to the whole linux.
Fix the .bashrc or anything you want.
Don't screw up the root user. :)
I find my .bashrc file in:
/home/your_user_name
you can run cd /home/your_user_name or cd ~ should work as well
If you previously installed git bash for window, you may also find .bashrc file in your window user profile folder. In Linux subsystem, you may local the file under /mnt/c/Users/your_window_user_name/.bashrc However, modifying that file only works for git bash in window but not for the shell terminal of the Linux subsystem.
Note: my installation of the Ubuntu is 20.04 LTS straight from window store.

Cygwin bash files

About a year ago, I created a couple text files called "compile" and "pull." When I go into a cygwin prompt and type those names and hit enter (basically use them as a command), the cygwin terminal runs what is in those text files. For instance here is the contents of one:
git checkout master
git checkout -- .
I don't even remember how I did this. I'm pretty sure this is not a bash script.
I do remember that I had to not just create the file in notepad but also perform some linux command line operation on it, in order to use it. Once I did that I could basically use the file as a command.
In *nix, you have to make a file executable in order to be able to run it:
chmod u+x file
You also need to add the path to the file to the PATH variable
PATH=$PATH:/path/to/the/file
or, add . to always scan the current directory for commands (it's considered unsecure, though):
PATH=$PATH:.

Change vim's current directory upon starting from command line

Vim (actually, gvim is in question, but I believe it works both ways) upon starting has its current directory in its runtime directory.
I would like to upon starting, to have its cd in let's say, c:\pro
I know I can just do :cd c:\pro, but is there a way to change it upon starting it, with
something alike gvim c:\pro (only that doesn't work :-| ?
You can use
gvim -c "cd C:/pro"
-c allows you to run commands just after Vim has finished loading.
Vim's working directory is initially set to the working directory of the process that invokes Vim.
If you're double-clicking on the .exe in Explorer, that's why it's the runtime directory.
If you're using the Start Menu shortcut, then it has the Start in path set to the runtime directory. You could change the Start in path of the shortcut.
If you use the run dialog, then vim's initial working directory is likely your Documents and Settings directcory.
Can't you put cd path in your .vimrc ?

How can I make cygwin autocomplete windows paths?

I don't want to type /cygdrive/c/path/to/stuff, especially when using tools that don't know anything about cygwin. Is there a way to configure cygwin to autocomplete "c:\path\to\stuff" or even "c:/path/to/stuff"?
For tools that can't understand cygwin paths, you'll need to convert them to windows paths. The cygpath utility can do this for you:
notepad $(cygpath -w /cygdrive/c/path/to/stuff)
You can probably create aliases or wrapper scripts for commonly-used windows executables.
Autocomplete should be working after the /cygdrive/c bit. Make a symlink for "/cygdrive/c/" to something else, like "ln -s /cygdrive/c /c". Also, make sure your inputrc is set up correctly.
Windows itself can autocomplete paths, with some minor registry tweaks. Or am I missing something in this question?
use alias:
Open the .bashrc file already copied in your home directory and type (I use "vi" editor for this but you can use "pico" which is a bit easier):
alias C="C:\Documents\ and\ Settings\Administrator"
you can use any path here. Save the .bashrc ("Ctrl+X" in pico I think, and :wq in "vi") and close the terminal. After restarting this console, typing "C" and pressing enter will send you automatically to "C:\Documents and Settings\Administrator"
To know which alias you have, just type "alias" in your terminal and all your alias will show up.

Resources