Can I install Mercurial in my home directory? - linux

I would like to install Mercurial on a Linux system where I don't have root access.
How can I do this in a way so that I can easily uninstall Mercurial again and upgrade it when new versions are released?
Also, can I get a package for Windows that does not require admin rights to install?

Mercurial in home directory, how?
It is very easy to compile and install Mercurial in your home directory, I've done so myself.
This linked wiki-post will certainly provide some aid if you have questions;
UnixInstall
Use make install-home to install hg to your home directory, it'll put the binary file in ~/bin and associative files in ~/lib.
When uninstalling or upgrading to a new version you could either delete the files that the makefile have put in, or let make install-home (if upgrading) overwrite the existing files.
Make sure to update your $PATH after installation so that it includes ~/bin.
Install Mercurial on windows without being admin, how?
Following the link below will lead you to the download section of Mercurial. There you'll be able to find installation bundles for Windows that doesn't require administration rights.
Download

I'm aware that this question is already answered but someone could be in the situation I was and that is to have to install without C compiler and make.
Install without C compiler and make
Full description of the solution can be found on following link.
List of commands, without using make
wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg
mkdir -p ~/software/lib/python2.5/site-packages
export PYTHONPATH=~/software/lib/python2.5/site-packages
sh setuptools-0.6c11-py2.5.egg --prefix=~/software
export PATH=${PATH}:~/software/bin
easy_install --prefix=~/software docutils
cd ~/software
wget https://www.mercurial-scm.org/release/mercurial-2.5.2.tar.gz
tar xzvf mercurial-2.5.2.tar.gz
cd mercurial-2.5.2.tar.gz
python setup.py --pure install --home="~/software" --force
cd ~/software/lib/python
mv hgext/ ../python2.5/site-packages/
mv mercurial ../python2.5/site-packages/
mv mercurial-2.5.2.egg-info ../python2.5/site-packages/
Append following lines to .bashrc:
export PYTHONPATH=~/software/lib/python2.5/site-packages
export PATH=${PATH}:~/software/bin
Check:
~$ hg
Mercurial Distributed SCM
etc...

Linux
The Mercurial source comes with a Makefile that has a local target. If you run this, then you'll build the C extensions in-place:
$ make local
... (lots of output) ...
python hg version
Mercurial Distributed SCM (version 5b66e55c0d93+20111216)
(see https://www.mercurial-scm.org for more information)
Copyright (C) 2005-2011 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You will need the Python header files, they typically come in a python-dev package. You can then symlink the hg script into a directory in your PATH. I use ~/bin for this:
$ cd ~/bin
$ ln -s ../src/mercurial/hg
You can now run hg from any directory.
If you want to uninstall Mercurial, it's as simple as deleting the directory where you did the compile. Upgrading is also easy: unpack a new release in the directory and run make local again. You can also use the newly install Mercurial to clone the Mercurial repository itself:
$ hg clone https://www.mercurial-scm.org/repo/hg
$ cd hg
$ make local
This gives you a version of Mercurial from the default branch. Use hg update stable before compiling if you want a build from the stable branch instead. That branch is only updated with bugfixes.
Windows
On that platform, you can use a the Inno setup installers. They do not require admin rights. You can couple that with a portable version of TortoiseHg if you like.

Related

how to install git without sudo on linux server

I tried the following to install git without sudo permissions
wget https://github.com/git/git/archive/v2.1.2.tar.gz -O git.tar.gz
tar -zxf git.tar.gz
cd git-2.1.2/
make configure
./configure --prefix=/usr/local
make install
Can anyone help me how to install git with out sudo?
As with most autoconf-ed software, you could decide to configure it with --prefix=$HOME/soft/ (or some other prefix belonging to you)
Then, since $HOME/soft/ is a directory belonging to you, you won't need any sudo for installation
Of course you'll want to add $HOME/soft/bin/ to your $PATH
You may also want to pass --sysconfdir=$HOME/etc and you might pass --program-suffix=-mine (to later run git-mine instead of git)
I strongly recommend to run configure with --help at first, and to read the INSTALL file of your particular software (before compilation time), e.g. this for git
You may also need to deal with dependencies (be aware of the dependency hell), so you might need to install other libraries (and perhaps even adjust your $LD_LIBRARY_PATH to add $HOME/soft/lib/ to it, etc).
See also GNU stow
Read the Installing GIT chapter (notably Installing from Source)
In some cases having a discussion with your sysadmin could be easier.
Simply choose a prefix that you have permission on, e.g. a folder inside your user's home:
./configure --prefix=$HOME/opt/
make install
Then you will have to add $HOME/opt/bin/ into your PATH env-var.

How to install smlnj in arch linux?

Earlier I was in Ubuntu & it was easy to install smlnj using
apt-get install smlnj
but now I shifted to Arch & I'm finding it difficult to install smlnj.
I tried to find smlnj package through yaourt but I didn't found any.
Then I tried to install it by steps given in official site by downloading tar file. I followed given steps and extracted tar file in /usr/local/sml & then compiled by running command
config/install.sh.
After doing all this I tried to run sml but was not successful. I tried setting environment variable but again was not successful.
Please tell me whether I'm missing any steps or doing it wrong way. What is correct way to install smlnj in Arch Linux?
Update: As Alexander (xyproto) points out, pacman -S smlnj should work again now that SML/NJ is in the [multilib] repository. The solution below would still work, but credit for making installation more convenient should go to him. :-)
Before: It seems that the package became unavailable for x86_64 in Feb 2017, but it doesn't look like it should have happened. I've asked Alexander who maintains the package in [community].
The AUR doesn't contain an smlnj package because it's against AUR policy to overlap with official packages, unless the AUR package is compiled with some tweak that is clearly visible in the package name.
You can still build an Arch package and install that by finding the PKGBUILD and accompanying files at: https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/smlnj (or by cloning the git repo below with those four files in it):
~ $ git clone https://github.com/sshine/smlnj-arch.git
~ $ cd smlnj-arch
~/smlnj-arch $ makepkg
~/smlnj-arch $ sudo pacman -U smlnj-110.80-3-x86_64.pkg.tar.xz

How to install packages in Linux (CentOS) without root user with automatic dependency handling?

Is it possible to use RPM or YUM or any other package manager in Linux, specifically CentOS, to install a package either already downloaded or from repo to a custom location without admin/root access?
I tried building from sources, using cmake, configure, make, make install etc, but, it ended up having so many dependencies one after other.
Or are there any better alternatives?
It is possible to use yum and rpm to install any package in the repository of the distribution. Here is the recipe:
Find the package name
Use yum search.
Download
Download the package and all of its dependencies using yumdownloader (which is available on CentOS by default). You'll need to pass it --resolve to get dependency resolution. yumdownloader downloads to the current directory unless you specify a --destdir.
mkdir -p ~/rpm
yumdownloader --destdir ~/rpm --resolve vim-common
Choose a prefix location
It might be ~, ~/centos, or ~/y. If your home is slow because it is on a network file system, you can put it in /var/tmp/....
mkdir ~/centos
Extract all .rpm packages
Extract all .rpm packages to your chosen prefix location.
cd ~/centos && rpm2cpio ~/rpm/x.rpm | cpio -id
rpm2cpio outputs the .rpm file as a .cpio archive on stdout.
cpio reads it from from stdin
-i means extract (to the current directory)
-d means create missing directory
You can optionally use -v: verbose
Configure the environment
You will need to configure the environment variable PATH and LD_LIBRARY_PATH for the installed packages to work correctly. Here is the corresponding sample from my ~/.bashrc:
export PATH="$HOME/centos/usr/sbin:$HOME/centos/usr/bin:$HOME/centos/bin:$PATH"
export MANPATH="$HOME/centos/usr/share/man:$MANPATH"
L='/lib:/lib64:/usr/lib:/usr/lib64'
export LD_LIBRARY_PATH="$HOME/centos/usr/lib:$HOME/centos/usr/lib64:$L"
Edited note (thanks to #AmitNaidu for pointing out my mistake):
According to bash documentation about startup files, when connecting to a server via ssh, only .bashrc is sourced:
Invoked by remote shell daemon
Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by the remote shell daemon, usually rshd, or the secure shell daemon sshd. If Bash determines it is being run in this fashion, it reads and executes commands from ~/.bashrc, if that file exists and is readable.
Now if you want to install a lot of packages that way, you might want to automate the process. If so, have a look at this repository.
Extra note: if you are trying to install any of gcc, zlib, make, cmake, git, fish, zsh or tmux , you should really consider using conda, see my other answer.
TL;DR Use Miniconda, conda-forge is amazing.
curl "https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh" | sh
Or, alternatively:
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > Miniconda.sh
bash Miniconda.sh -b -p ~/conda
# -b is used to specify that this is done "in batch", so skip the EULA prompt
# -p lets you specify where you want conda installed
Commonly wanted packages:
gcc conda install gcc
zlib conda install zlib
make conda install make
cmake conda install cmake
git conda install git
fish conda install -c conda-forge fish
zsh conda install -c ActivisionGameScience zsh
tmux conda install -c conda-forge tmux
This tmux has a bug with the name of the ncurse library it uses. You can work around it by going to your da/lib folder and symlinking ln -sT libtinfow.so.6.1 libtinfo.so.6
For the rest, you can try https://anaconda.org/search?q=.
I've tried for a long time to get a package manager to work well on CentOS/RedHat but without success. The best I could do was to install a Gentoo Prefix at the correct location on another CentOS with root access, then scp a .tar.xz of the whole installation to the target server (only way to get a proper gcc for Gentoo Prefix). I could emerge (build & install) packages on the target server but kept hitting problems with locals and permissions.
I recently achieved a user installation of some interesting packages using conda. Here is how to install it from the command line:
curl "https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh" | sh
If like me, your home folder is hosted on a remote drive (a network file system), you might not want to install it in your home folder, so you might want to use something like mkdir /var/tmp/lo then specify an installation folder like /var/tmp/lo/da during the installation.
You'll then be able to install quite a lot of packages, though maybe not all those you wanted. Most of the time, if it is not in the default channel, it will be in conda-forge. You can check for existing packages at https://anaconda.org/search?q=
Other package managers I've tried to use after conda:
Linuxbrew
I thought that with that it would be easy to install homebrew (linuxbrew) but their sources are messy and use hard-coded absolute path to ruby interpreter, which fails because it isn't the last version and so on and so on and I gave up.
Nix
Nix still requires you to use the /nix folder. They hard-coded it too and it's hard to sed it correctly from every download it has to do during the installation (let alone updates).
Gentoo Prefix
I expect Gentoo Prefix to be easier to install directly now that we gcc can be used on the target server. -- Ok, I tried but met permissions bugs during installation (2018-09-28):
portage.exception.OperationNotPermitted: chown(b'~/gentoo/tmp/var/tmp/portage/sys-apps/gentoo-functions-0.12/image/var', 2000, 2000)
PkgSrc
I'm going to try pkgsrc now. -- Use (older) version 64-bit EL 6.x if on CentOS 6 or if encountering (G)LibC version issues with the 7.x one. -- No luck, pkgsrc hard codes /usr/pkg/sbin and /usr/pkg/bin. So it can't be used as user, unless maybe setting up a fakechroot environment. But I've never done that and I expect usability issues.
Please comment/answer if you succeed in installing any other package manager.
Download the packages, and indicate to include dependencies with the --resolve flag.
yumdownloader --resolve openslide-tools
Iterate over all downloaded rpm files.
for i in *.rpm; do rpm2cpio $i | cpio -idv; done
the output will be stored in your present working directory $PWD/usr/*
This answer by goldilocks sounds like what you are looking for.
https://unix.stackexchange.com/a/61295
It's still not a pretty process, but seems easier than building from source.
Otherwise you might want to look into non-root package managers as an alternative to yum.
Yes it is. If the software is packaged in repos. And admin installed
PackageKit-command-not-found package.
See:
https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound

How do I completely uninstall git from my Linux Machine

I had installed git by downloading the tar ball and then doing the following steps
./configure --prefix=/scratch/custom/git
make
make install
But after running these commands, I still see that git is created under /usr/local as below
bash-4.1$ whereis git
git: /usr/bin/git /usr/local/git /usr/share/man/man1/git.1.gz
I would like to remove and reinstall again how do i do the same?
If make unistall doesn't work, as mentioned here, uninstalling on linux, try make install again, capturing the output.
Then go through all of the install commands and manually remove the installed files.
Also, 'make -n` may help to determine all of the installed files.

Installing Git with non-root user account

I've already set up a Git repository on GitHub and committed a few changes from my Windows machine.
But tomorrow I'll have to work in this repository from a machine running Ubuntu with limited privilege (i.e. no sudo).
Is there a portable version of Git for Linux? Or some source that allows me to compile and install Git only for the current user?
You can download the git source and do ./configure --prefix=/home/user/myroot && make && make install to install git to your home directory provided you have the build tools. If you don't have the build-essential package installed (dpkg --list|grep build-essential), you will need to install those to your home directory as well.
I don't like link-only answers, but this link I followed step-by-step on a Fedora machine and it worked without modification. Very, very easy. The binaries end up in your ~/bin directory. You download a tarball, extract the sources, run make and run make install and that is it.
As the author states, the 2 prerequisites are gcc and ssh and if you meet these git should work for you as a non-root user.
To install git and dependencies from source the following maybe useful.
Replace with the location you are installing your non-root apps and consider checking for latest versions of source code.
wget https://curl.haxx.se/download/curl-7.47.1.tar.gz
tar -xf curl-7.47.1.tar.gz
mkdir <local_curl_dir>
cd curl-7.47.1
./configure --prefix=<local_curl_dir>
make
make install
wget http://downloads.sourceforge.net/expat/expat-2.1.0.tar.gz
tar -xf expat-2.1.0.tar.gz
mkdir <local_expat_dir>
cd expat-2.1.0
./configure --prefix=<local_expat_dir>
make
make install
wget https://github.com/git/git/archive/v2.6.4.tar.gz
tar -xf v2.6.4
mkdir <local_git_dir>
cd git-2.6.4
make configure
./configure --prefix=<local_git_dir>/git --with-curl=<local_curl_dir>/curl --with-expat=<local_expat_dir>/expat
make
make install
This is what I ended up doing, the main trick being the make flags:
wget -O git.tar.gz https://github.com/git/git/archive/v2.17.0.tar.gz
tar zxf git.tar.gz
mv git-2.17.0 git
cd git
make configure
./configure --prefix=`pwd` --with-curl --with-expat
# ./configure --prefix=`pwd`
# Make flags from https://public-inbox.org/git/CAP8UFD2gKTourXUdB_9_FZ3AEECTDc1Fx1NFKzeaTZDWHC3jxA#mail.gmail.com/
make NO_GETTEXT=Nope NO_TCLTK=Nope
make install NO_GETTEXT=Nope NO_TCLTK=Nope
Credits:
79E09796's answer above was a good tip, but didn't work for my case on Cloudways and did not require compiling curl and expat.
A random email record I found on the internet: https://public-inbox.org/git/CAP8UFD2gKTourXUdB_9_FZ3AEECTDc1Fx1NFKzeaTZDWHC3jxA#mail.gmail.com/
A related answer is https://askubuntu.com/a/350.
I could get it work with the third method proposed:
apt-get source git
cd git_vXXX
./configure --prefix=$HOME
make
make install
I don't know why, but when I had tried to install from the source download from github instead, I had a lot of problems with missing dependencies
Overkill workaround
Install Anaconda as a user and install git with conda.
Advantages
Anaconda can be installed as user, and a conda environment can be created which can help you to install other packages. This way you don't need to compile git from source, nor you need to install libcurl and perl, so you won't get the error
git: 'remote-https' is not a git command. See 'git --help'
after successfully compiling git.
Steps to install Anaconda, then git
read the Anaconda installation manual which points to the download page's shell script file.
Download the script file:
copy to your local machine and then copy with scp (e.g. winscp) to the Linux machine or
use a terminal on the Linux machine and issue wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh.
add executable rights to yourself on the file by issuing chmod +x Anaconda3-2020.11-Linux-x86_64.sh
follow the installation instructions where you can also specify into which folder you want to install anaconda
after installation, chose one of the possibilities below to successfully invoke git later:
you either activate a conda environment, which is useful e.g. if you need to create different conda environments (it is common if you work with python). To activate an environment, you need to ask the installer (at the end of the installation) to add the conda initialization code into your ~/.bashrc file [see below]. Using this method, your path won't be polluted, and you will see if conda-related binaries are also in your current path. Or you can
add the installed bin's folder to your path, e.g. if you installed anaconda into /home/myusername/anaconda3, it will be in /home/myusername/anaconda3/bin. Your new executable file conda will be also there which will help you to install packages like git, python or pandoc, or
cd into the binary folder of anaconda, e.g. cd /home/myusername/anaconda3/bin, and execute the commands below.
don't forget to take into effect the new settings by, e.g., closing and opening the terminal again if you selected method 1. or 2. in point 5. If you selected 1, you will see something like (base) myusername#servername indicating you are using the base conda environment.
Now you can install git using conda by issuing conda install -c anaconda git.
Your .bashrc will contain likes like this if you told the Anaconda installer to initialize conda for you:
# content of your .bashrc in your home dir
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/myusername/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/myusername/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/myusername/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/myusername/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
for the latest version(which i mean git-2.25.0-rc1 or upper), you need to
wget https://github.com/git/git/releases/tag/v2.25.0-rc1 -O git.zip
unzip git.zip
cd git-2.25.0-rc1
export PATH=`pwd`:$PATH
and of course, you can add the last line into your .bashrc or .zshrc or something else for more convenience.

Resources