Installing Pik in Windows 7 PATH variable naming error - ruby

On installation of Pik, it seems that the directory naming conventions utilized in the program are erroneous, as can be seen below where C: is not reconciled as C:\ for the install directory. I suspect this my be the culprit. My PATH definitely does contain C:\cygwin64 as a variable, but it isn't recognized by Pik.
I have tried altering the name of the directory as C:\\cygwin64 during installation as a workaround and other similar variations just for the sake of trial and error, but to no avail. Interestingly, the Github directory shows a similar double backslash naming convention for this component, but I'm not sure how this might solve the problem.
The version of Pik I am using is 0.2.8.
$ pik_install C:\cygwin64
Thank you for using pik.
mkdir -p C:cygwin64
mkdir -p C:\Users\Adam/.pik
Installing to C:cygwin64
cp /home/Name/.gem/ruby/gems/pik-0.2.8/tools/pik_runner.exe C:cygwin64
cp /home/Name/.gem/ruby/gems/pik-0.2.8/tools/pik.bat C:cygwin64
cp /home/Name/.gem/ruby/gems/pik-0.2.8/tools/pik.ps1 C:cygwin64
creating C:\Users\Name/.pik/.pikrc
pik is installed
The directory you installed to is not in the sytem path.
C:cygwin64
You will need to add it.
if you want to use pik with git bash, add the following line to your ~/.bashrc:
[[ -s $USERPROFILE/.pik/.pikrc ]] && source $USERPROFILE/.pik/.pikrc

Related

Installing javacc on mac with terminal

I have downloaded javacc-5.0 and tried to follow various different guides to no avail.
I unzipped the package, modified the PATH variable to contain ../javacc-5.0/bin/lib/javacc.jar directory and ensured that all the correct files are executable. However, a which javacc command gives no output and trying to run the javacc exec has also given the error Could not find or load main class javacc (the jar file is definitely there in the lib directory).
In the ...../javacc-5.0/bin directory, there should be a file called javacc that should looks something like this
#!/bin/sh
JAR="`dirname $0`/lib/javacc.jar"
case "`uname`" in
CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;;
esac
java -classpath "$JAR" javacc "$#"
If so, edit your PATH variable to include /....../javacc-5.0/bin, i.e. the absolute path of that bin directory. There is no need for the PATH variable to include /....../javacc-5.0/bin/lib/javacc.jar; so take that out.
Start a new terminal. In the new terminal, check the PATH variable with echo $PATH. Try which javacc. Try javacc.
javacc can easily be installed using Homebrew:
brew install javacc
https://formulae.brew.sh/formula/javacc

How to add man and zip to "git bash" installation on Windows

I am using git bash on Windows - that is git for Windows via the integrated bash. Apparently it uses the MINGW/MSYS underpinning. (Update from #VonC: It now uses msys2 since msysgit is obsolete since Q4 2015.)
So there are already a lot of MSYS tools installed - from awk to zcat. However I miss the man command and zip to compress multiple files into a zip file (unzip exists!).
Where from can I install them? I do not want to install another copy of the MINGW system! Any way just to add some pre-compiled tools to the git bash installation?
Here's another, slightly different, set of instructions to install zip for git bash on windows:
Navigate to this sourceforge page
Download zip-3.0-bin.zip
In the zipped file, in the bin folder, find the file zip.exe.
Extract the file zip.exe to your mingw64 bin folder (for me: C:\Program Files\Git\mingw64\bin)
Navigate to to this sourceforge page
Download bzip2-1.0.5-bin.zip
In the zipped file, in the bin folder, find the file bzip2.dll
Extract bzip2.dll to your mingw64\bin folder (same folder as above: C:\Program Files\Git\mingw64\bin)
7-zip can be added to gitbash as follows:
Install 7-zip on windows.
add 7-zip folder (C:\Program Files\7-Zip) to PATH
On gitbash exp: export PATH=$PATH:"C:\Program Files\7-Zip" (temporary)
On Windows, adding PATH like image below (permanent)
duplicate a copy of 7z.exe to be zip.exe
reopen gitbash again. done!
This way, it works on my laptop.
If you skip step 3. you still can call zip command as 7z instead of zip
Conclusion: Gitbash is running base on windows Path, I think you can run any command that you have added to your Windows PATH.
2016: The zip command can be installed from GoW (Gnu On Windows). man is not provided (too big).
It is to note, however, that if you only want to add the zip command from GoW, still the whole GoW system has to be downloaded and installed. Then you can delete the other commands from the bin directory, however make sure to keep the needed dlls in the directory.
Update 2021: tar/zip are by default installed on Windows 10.
7-zip based solutions are available below.
git-archive, is prepared without any installation, can create zip-archive.
mkdir workrepo
cd workrepo
git init
cp -r [target_file_or_dir] .
git add .
git commit -m commit
git archive -o ../myarchive.zip #
cd ..
rm -rf workrepo
Following script may be usable:
zip.sh foo.zip target_file_or_dir
#!/usr/bin/bash
set -eu
unset workdir
onexit() {
if [ -n ${workdir-} ]; then
rm -rf "$workdir"
fi
}
trap onexit EXIT
workdir=$(mktemp --tmpdir -d gitzip.XXXXXX)
cp -r "$2" "$workdir"
pushd "$workdir"
git init
git config --local user.email "zip#example.com"
git config --local user.name "zip"
git add .
git commit -m "commit for zip"
popd
git archive --format=zip -o "$1" --remote="$workdir" HEAD
I am so glad to share my experience on this issue that I haven't known for two years since the first day I played with Groovy. My method needs to have git for Windows installed in Windows OS.
These steps are for installing 7z command-line utility, which behaves a bit differently from zip:
Download and install 7-Zip from its official website. By default, it is installed under the directory /c/Program Files/7-Zip in Windows 10 as my case.
Run git Bash under Administrator privilege and navigate to the directory /c/Program Files/Git/mingw64/bin, you can run the command ln -s "/c/Program Files/7-Zip/7z.exe" 7z.exe
I am pretty sure it could help you a lot. Trust me!
On Windows, you can use tar instead of zip.
tar -a -c -f output.zip myfile.txt
which is same as,
zip output.zip myfile.txt
no need to install any external zip tool.
I use choco as my Windows Package Manager.
I install 7zip with choco using PowerShell (you must be admin to use Choco)
PS > choco install 7zip.install
Open another gitbash Terminal and locate the 7z.exe executable
$ which 7z
/c/ProgramData/chocolatey/bin/7z
Do a straight copy of 7z.exe to zip.exe and voila
$ cp /c/ProgramData/chocolatey/bin/7z.exe /c/ProgramData/chocolatey/bin/zip.exe
You can mimic a small subset of man behavior in the shell by mapping man <command> to <command> --help | less
Unfortunately, on my machine bash aliases won't add flags to positional arguments, it will try to run the flag as a command and fail (alias man="$1 --help" doesn't work).
And a function called man() is not allowed!
Luckily a combination of bash functions and aliases can achieve this mapping. Put the code below in your ~/.bashrc (create one if it is not there). Don't forget to source ~/.bashrc.
# man command workaround: alias can't pass flags, but can't name function man
m() {
"$1" --help | less
}
alias man="m"
It doesn't get you the full man page, but if all you're looking for is basic info on a command and its flags, this might be all you need.
You can install individual GNU tools from http://gnuwin32.sourceforge.net/packages.html such as zip.
Then add "/c/Program Files (x86)/GnuWin32/bin" to PATH in your startup script like .profile, .bash_profile, .bashrc, etc.
Here are the steps you can follow.
Go to the following link
https://sourceforge.net/projects/gnuwin32/files/
Find out whatever command you are missing
Here I need zip and bzip2 for zip command. Because zip command relies on bzip2.dll to run. Otherwise you will get error “error while loading shared libraries: ?: cannot open shared object file: No such file or directory”.
Unzip the downloaded files
Here I am downloading “zip-3.0-bin.zip” for “zip.exe” and “bzip2-1.0.5-bin.zip” for “bzip2.dll” in the bin folder. /bin/.exe
Copy the command exe file into git-bash folder
Here I am copying “zip.exe” and “bzip2.dll” to \Git\usr\bin.
Reference Link
https://ranxing.wordpress.com/2016/12/13/add-zip-into-git-bash-on-windows/
ln -s /mingw64/bin/ziptool.exe /usr/bin/zip
steps to install SDKMAN on windows
Run Windows Terminal in Admin rights. open git bash inside. (Ctrl + Shift + 4)
winget install -e --id GnuWin32.Zip
mkdir ~/bin
cp /usr/bin/unzip ~/bin/zip
curl -s "https://beta.sdkman.io" | bash
source "/c/Users/ajink/.sdkman/bin/sdkman-init.sh"
sdk selfupdate force
After you can install Java like this.
sdk install java 17.0.2-open
Done ! :)
In msys2, I restored the functionality of git help <command> by installing man-db:
|prompt> pacman -Syu man-db
|prompt> git help archive
For zip functionality, I also use git archive (similar to yukihane's answer).
Here's yet another 7-Zip option that I didn't notice:
Create a script named zip:
$ vi ~/bin/zip
Reference 7z specifying the add command followed by the args:
#!/bin/bash
/c/Progra~1/7-Zip/7z.exe a "$#"
Finally make it executable
$ chmod ugo+x ~/bin/zip
This helped to make a ytt build script happy.
+ zip ytt-lambda-website.zip main ytt
7-Zip 18.01 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-01-28
Scanning the drive:
2 files, 29035805 bytes (28 MiB)
Creating archive: ytt-lambda-website.zip
Add new data to archive: 2 files, 29035805 bytes (28 MiB)
Though this question as been answered quite thoroughly in regards to man there is one alternative to zipping that has not been highlighted here yet. #Zartc brought to my attention that there is a zip compression utility built-in: ziptool. In trying to use it however I found out it is no where near a drop-in replacement and you need to specify each individual file and folder. So I dug into the docs and experimented until I had a bash-function that can do all the heavy lifting and can be used very similar to a basic zip -qrf name * compression call:
zipWithZiptool() {
# Docs: https://libzip.org/documentation/ziptool.html
targetFilePath="$1"
shift
args=() # collect all args in an array so spaces are handled correctly
while IFS=$'\n\r' read -r line; do
if [[ -d "$line" ]]; then
args+=("add_dir" "$line") # Add a single directory by name
else
# add_file <pathInZip> <pathToFile> <startIndex> <length>
args+=("add_file" "$line" "$line" 0 -1)
fi
done <<< "$(find "$#")" # call find with every arg to return a recursive list of files and dirs
ziptool $targetFilePath "${args[#]}" # quotation is important for handling file names with spaces
}
You can then for example zip the contents of the current directory by calling it like this:
zipWithZiptool "my.zip" *
If you are willing to install CygWin also, you can add the CygWin path to your GitBash path, and if zip is there, it will work. e.g. add
PATH=$PATH:/c/cygwin/bin
export PATH
to your .bashrc; NOTE: I would put it at the end of the path as shown, not the beginning.
Since CygWin has a UI-based installer, it's easy to add or remove applications like zip or man.
You can figure out the windows paths of each by saying
`cygpath -w /bin`
in each respective shell.
Regarding zip, you can use a following perl script to pack files:
#!/usr/bin/perl
use IO::Compress::Zip qw(:all);
$z = shift;
zip [ #ARGV ] => $z or die "Cannot create zip file: $ZipError\n";
If you make it executable, name it zip, and put it in your $PATH, you can run it like this:
zip archive.zip files...
however it will not work for directories. There is no need to install anything, as perl and all required modules are already there in the Git for Windows installation.
Regarding man, at least for git there is a documentation invoked like this:
git option --help
it will open in your default browser.
Here is my experience, I cant run and exe or .msi files in my laptop. so downloaded filed from https://github.com/bmatzelle/gow/wiki > go to download Now and Downloaded Source Code (Zip) and unzipped this file in a folder and updated path variable with folder name.
This worked out for me.
If you want to zip files without needing to install any additional tools on Windows, in a way that works both on git bash and on other *nix systems, you might be able to use perl.
Per Josip Medved's blog, the following script creates an .epub (which is a zip file), and includes a filter for stripping src/ from the files added to the zip:
perl -e '
use strict;
use warnings;
use autodie;
use IO::Compress::Zip qw(:all);
zip [
"src/mimetype",
<"src/META-INF/*.*">,
<"src/OEBPS/*.*">,
<"src/OEBPS/chapters/*.*">
] => "bin/book.epub",
FilterName => sub { s[^src/][] },
Zip64 => 0,
or die "Zip failed: $ZipError\n";
'
install zip
https://gnuwin32.sourceforge.net/packages/zip.htm
copy zip.exe and bzip2.dll from C:\Program Files (x86)\GnuWin32\bin to C:\Program Files\Git\mingw64\bin
reopen git-bash
Solutions for me were just to install zip on my terminal(bash):
$ sudo apt-get update
$ sudo apt-get install zip unzip

Unable to install modman, .profile is missing

https://github.com/colinmollenhour/modman/blob/master/README.md
I am trying to install modman.
First I install via:
bash < <(curl -s -L https://raw.github.com/colinmollenhour/modman/master/modman-installer)
modman is created at User/Username/bin/modman
I got lost on the next part:
source ~/.profile
I don't have .profile in my directory, so i created one in my user root and I added
export PATH=$PATH:/Users/Username/bin/modman
I am not sure if that is correct, when I cd to my project directory and
do modman init it returns modman: command not found
Why am I getting this message?
You add directories to PATH, not individual binaries.
export PATH=$PATH:/Users/Username/bin
Note the line from the installer that would have updated .profile for you:
echo -e '\nPATH="$HOME/bin:$PATH"' >> $HOME/.profile
(Typically, you might add $HOME/bin to the beginning of the path so that you can override system binaries, but in your case, it doesn't matter since you don't have modman installed outside your home directory.)

Issue while navigating to a directory "C/Program Files (x86)" with cygwin?

I am trying to navigate to this below path in cygwin,
C/Program Files (x86)/temp/lfc/utilities
but unfortunately, it shows the below error
$ cd C/Program Files (x86)/temp/lfc/utilities
bash: syntax error near unexpected token `('
Could you please let me know, what is wrong here..
The command:
cd C/Program Files (x86)/temp/lfc/utilities
is trying to call cd with three arguments rather than the correct one:
C/Program
Files
(x86)/temp/lfc/utilities
and the third of those arguments contains characters that cause bash some grief - they're actually defined as metacharacters and, as per the bash doco:
Each of the metacharacters listed above under DEFINITIONS has special meaning to the shell and must be quoted if it is to represent itself.
Just surround the whole lot in quotes, like:
cd '/cygdrive/C/Program Files (x86)/temp/lfc/utilities'
You'll notice I've also prefixed it with the CygWin cygdrive mount point. I'm fairly certain that's still needed, at least from the version I installed a couple of months back.
Cygwin uses POSIX path nomenclature. To easily convert a Windows path into a Cygwin path you can use the cygpath tool:
$ cygpath 'C:\Program Files\foo'
/cygdrive/c/Program Files/foo
Also this tool can convert POSIX path to Windows:
$ cygpath -w '/cygdrive/c/Program Files/foo'
C:\Program Files\foo
A third solution is to drag and drop a file or folder from the Windows explorer directly into your mintty terminal. You will get you Windows path directly converted into the Cygwin's format.
You could also use PROGRA~1, PROGRA~2 and PROGRA~3 like this :
cd /cygdrive/c/PROGRA~1 is equivalent to cd
/cygdrive/c/Programmes
cd /cygdrive/c/PROGRA~2 is equivalent to cd
/cygdrive/c/Program\ Files\ \(x86\)
cd /cygdrive/c/PROGRA~3 is equivalent to cd
/cygdrive/c/ProgramData
You can directly use windows paths with:
cd $(cygpath -u "C:\Program Files (x86)\temp\lfc\utilities")
This is useful for environment variables like:
cd $(cygpath -u "$USERPROFILE")/Downloads
cd "$(cygpath -u "$PROGRAMFILES")/Program Name"
You can know more about cygpath on https://cygwin.com/cygwin-ug-net/cygpath.html

How to set path to ruby on win 7

I am using git-bash in win7. I have installed c:/ruby/bin/ruby.exe. I've added c:/ruby/bin/ to my PATH environmental variable and restarted. however when I do:
$ which ruby
/c/opscode/chef/embedded/bin/ruby
$ echo $PATH
/c/ruby/bin:/c/st:/c/Users/Bill/bin:.:/usr/local/bin:/mingw/bin:/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/c/Program Files (x86)/QuickTime/QTSystem:/c/python27:/c/Python27/Lib/sitepackages/django/bin:/c/Python27/Scripts:/c/MinGW/bin:/d/opscode/chef/bin:/d/opscode/chef/embedded/bin:/d/VirtualBox/VBoxManage:/d/HashiCorp/Vagrant/bin:/c/opscode/chef/bin:/c/opscode/chef/embedded/bin:/c/ProgramData/Composer/bin:/c/Program Files (x86)/git/cmd:/c/nodejs/:/c/Users/Bill/AppData/Roaming/npm:/c/Ruby193/bin
How do I change this to "c:/ruby/bin/" ?
Add following line to /c/Users/your-username/.bashrc file to make the /c/ruby/bin placed before any other directory in the PATH:
export PATH=/c/ruby/bin:$PATH
Or, start git bash, and issue the following command:
echo 'export PATH=/c/ruby/bin:$PATH' >> ~/.bashrc
UPDATE
If above still does not work, check whether the directory /c/ruby does exists. If it does, check whethere ruby.exe file is in the directory /c/ruby/bin.
If the directory does not exist, replace /c/ruby/... with the one really exists.

Resources