How to update CPAN perl module - linux

I'm trying to install some perl module but everytime this message is shown
New CPAN.pm version (v2.00) available.
[Currently running version is v1.960001]
You might want to try
install CPAN
reload cpan
to both upgrade CPAN.pm and run the new version without leaving
the current session.
I've tried to do
install CPAN
reload cpan
With
pi#raspbmc:~$ sudo perl -MCPAN -e shell
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v1.960001)
Enter 'h' for help.
cpan[1]> install CPAN
But the result is
Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Going to read '/root/.cpan/sources/modules/02packages.details.txt.gz'
Database was generated on Mon, 28 Oct 2013 23:41:06 GMT
HTTP::Date not available
..............
New CPAN.pm version (v2.00) available.
[Currently running version is v1.960001]
You might want to try
install CPAN
reload cpan
to both upgrade CPAN.pm and run the new version without leaving
the current session.
...............pi#raspbmc:~$
The version is still 1.960001.

The following procedure
kuz1#banana:~$ sudo perl -MCPAN -e shell
cpan[1]> install CPAN
cpan[2]> reload cpan
works for me on the BANANA Pi Single-Board Computer with Ubuntu 14.04.

download CPAN module from this page http://metacpan.org/pod/CPAN
untar it (tar zxf CPAN-2.00.tar.gz), cd into the directory and run
perl Makefile.PL
make test
sudo make install
edit: if it breaks making a path with :: in it then perhaps your filesystem type does not support these characters in a filename
To see the filesystem type, run mount without any parameters and all the mounted filesystems with their types will be shown
The error Can't write-open blib/man3/CPAN::Admin.3pm seems to suggest a filesystem problem, but ext4 in rw mode sounds alright. Try this from the CPAN-2.00 directory
perl -e 'open($f,">blib/man3/CPAN::thisisatest") || die $!;'

Related

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

Problems installing Pycharm

I am trying to install pycharm on my linux OS.
following the instructions pycharm/dowload.
Since I run a linux machine I made sure the pychrarm files in the current directory:
ietX220:~$ ls
Desktop pycharm-community-4.0.1
Documents Music
pycharm-community- 4.0.1.tar.gz
Downloads New Folder Templates
Dropbox octave-workspace Videos
examples.desktop Pictures VirtualBox VMs
jdk1.8.0_25 Public Win7-PV2hh-6c3HY-
QJHM9-8RJJH-P86W8.iso
ietX220:~$ pycharm-*.tar.gz
pycharm-community-4.0.1.tar.gz: command not found
As you can see the pycharm file is in the current(home) directory but is not found.
Then I opened the tar file made pycharm.sh executable:
chmod +x pycharm.sh
And then ran:
~/pycharm-community-4.0.1/bin$ ./pycharm.sh
Startup Error: Application cannot start in headless mode
What am I doing wrong?
I am having the same issue. It looks like maybe you and I both have a minimal (headless) Java install on our systems. Use your system's method for finding installed packages and search for Java, and i'll bet you find only openjdk-headless
yum list installed | grep openjdk
# or on debian-based systems
# dpkg --get-selections | grep openjdk
# =>java-1.7.0-openjdk-headless
Solution then is to install the same package without the "-headless" suffix.
Here's where I am getting my information for the solution: https://bugzilla.redhat.com/show_bug.cgi?id=1177379
I had the same problem and as mentioned before the error was that openjdk was headless. What i did is i installed from the begining openjdk using the command apt-get install default-jdk (for ubuntu). I know it's not the best way to do it, however it is rather quick and simple.
If you have already all the prerequisites (such as Java) installed, try out charmy (PyCharm installer for Linux).
virtualenv charmy-env
source charmy-env/bin/activate
pip install charmy
charmy install
That will install PyCharm into your home directory. It will also simplify your feature PyCharm upgrades. To upgrade you would just have to type
charmy install
instead of downloading distribution manually, unpacking it, etc.
See https://pypi.python.org/pypi/charmy for more.
PYcharm is now available as a snap. Can be easily installed as below
sudo apt update && sudo apt install snapd
Then the community edition can be installed by
sudo snap install pycharm-community --classic
The classic escape is to get snaps that have been published with classic confinements
220:~$ pycharm-*.tar.gz
pycharm-community-4.0.1.tar.gz: command not found
gz files are not executable files. I think the current directory is not in your PATH variable. To get around that you would do "./pycharm-community-3.0.1.tar.gz" and you should see the message "Permission denied" as the gz file would not have execute permission. And if you gave it execute permission it would say "cannot execute binary file: Exec format error".
These are the instructions from the JetBrains website:
Copy the pycharm-*.tar.gz to the desired installation location
(make sure you have rw permissions for that directory)
Unpack the pycharm-*.tar.gz using the following command:
tar xfz pycharm-*.tar.gz
Remove the pycharm-*.tar.gz to save disk space (optional)
Run pycharm.sh from the bin subdirectory
NOTE: PyCharm on Linux doesn't need special installation or running
any installation script. It runs out of the pycharm-*.tar.gz
If you run the command "tar xfz pycharm-*.tar.gz" you should end up with a directory in your current directory named "pycharm-community-4.0.3".
If you cd pycharm-community-4.0.3/bin, "ls -al" should show that pycharm.sh is already executable. Run pycharm.sh and you should be done. The script will prompt for a password at the end so it can put a startup script in a system directory. You must have admin privileges for that part to work. But if you don't, you can still start PyCharm by executing "[path to pycharm directory]/bin/pycharm.sh &" at the command prompt.
I am not sure what the "NOTE:" is saying, but I would ignore it as you get a working PyCharm by doing what it says above the NOTE: .
Setup the newest stable jdk(like jdk1.7 or jdk 1.8) in your system, and set it is the default jdk.
1.download JDK8
2.SET JAVA HOME
sudo gedit /etc/environment
export JAVA_HOME=/home/username/Java/jdk1.8
export JRE_HOME=/home/username/Java/jdk1.8
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
sudo gedit /etc/profile
//before umask xxx adde
export JAVA_HOME=/home/username/Java/jdk1.8
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$JAVA_HOME/bin
3. run pycharm
./pycharm.sh

Unable to locate DBI.pm module in Perl

I am using CentOS, and I have installed Perl 5.20 and Perl 5.10 was present by default.
I am using the Perl 5.20 version to execute the Perl code
I am trying to use the DBI module and get this error
[root#localhost ~]#perl -e 'use DBI;'
Can't locate DBI.pm in #INC (you may need to install the DBI module) (#INC contains: /usr/local/lib/perl5/site_perl/5.20.1/i686-linux /usr/local/lib/perl5/site_perl/5.20.1 /usr/local/lib/perl5/5.20.1/i686-linux /usr/local/lib/perl5/5.20.1 .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
How to check for all installed versions of Perl?
How do I check whether the DBI or any module is installed?
How to resolve this error so that I can use DBI module?
How to check for all installed versions of perl?
As Sobrique suggested in comments, you should never touch system perl. I'd suggest using perlbrew. With perlbrew you can install different versions of perl from local user, and to check all installed versions of perl using perlbrew just do $ perlbrew -l.
how to switch between them while executing a program?
Install multiple perls
$ perlbrew -v install perl-5.20.0
$ perlbrew -v install perl-5.13.4
Switch between them
$ perlbrew switch perl-5.20.0
$ perlbrew switch perl-5.13.4
See this article for more details: Installing Multiple Perls with App::perlbrew and App::cpanminus
How do I check if DBI or any module is installed?
How can I check if a Perl module is installed on my system from the command line?
How to resolve this error so that I can use DBI module?
What's the easiest way to install a missing Perl module?
A Guide to Installing Modules

Get the Perl rename utility instead of the built-in rename

Many sites (including various SO articles) talk about using "rename" using Perl expressions to rename files.
This would be perfect, but apparently this is not the rename utility I have, and none of these articles seem to comprehend that there are multiple versions of "rename" and I can't seem to find where to get version that accepts Perl expressions.
How can I get my hands on the more powerful rename utility mentioned here, here, and here?
I'm running Fedora 20. My current rename command is from the util-linux package and apparently I need the Perl version, which is better.
I can only speak for Debian. The two programs are called
/usr/bin/rename.ul from the util-linux package (hence the .ul suffix)
/usr/bin/prename from the perl package
The actual rename command works via the /etc/alternatives mechanism, whereby
/usr/bin/rename is a symlink to /etc/alternatives/rename
/etc/alternatives/rename is a symlink to /usr/bin/prename
The same problem has been bugging me on Cygwin, which is a Red Hat product, so should be more similar to Fedora. I'll have a look on my company laptop on Monday. And I remember the Perl-rename having worked there sometimes. Probably before I installed util-linux.
If you install the Perl-rename to /usr/local/bin it will have precedence over rename from util-linux. Same goes for the manpage when installed to /usr/local/share/man/man1/.
I've just created a separate Perl-rename package on Github: https://github.com/subogero/rename
You can install it using cpan, which is the perl repository similar to pip for python.
Here is a tutorial on using cpan.
If you try to run rename it it looks like this
rename --help
call: rename from to files...
To install the perl rename you can do the following. You might need to install a few dependencies, you can generally just push enter
cpan
cpan1> install File::Rename
CPAN: Storable loaded ok (v2.20)
Going to read '/root/.cpan/Metadata'
Database was generated on Wed, 30 Sep 2015 08:17:02 GMT
Running install for module 'File::Rename'
....
Running Build install
Installing /usr/local/share/man/man1/rename.1
Installing /usr/local/share/perl5/File/Rename.pm
Installing /usr/local/share/man/man3/File::Rename.3pm
Installing /usr/local/bin/rename
Writing /usr/local/lib64/perl5/auto/File/Rename/.packlist
RMBARKER/File-Rename-0.20.tar.gz
./Build install -- OK
That is how you would install the rename from cpan.
Next is to get it working on your system. As you might have more then one rename installed.
which rename
/usr/bin/rename
When you actually want this one.
/usr/local/bin/rename --help
Usage:
rename [ -h|-m|-V ] [ -v ] [ -n ] [ -f ] [ -e|-E *perlexpr*]*|*perlexpr*
[ *files* ]
Options:
-v, -verbose
Verbose: print names of files successfully renamed.
-n, -nono
No action: print names of files to be renamed, but don't rename.
-f, -force
Over write: allow existing files to be over-written.
-h, -help
Help: print SYNOPSIS and OPTIONS.
-m, -man
Manual: print manual page.
-V, -version
Version: show version number.
-e Expression: code to act on files name.
May be repeated to build up code (like "perl -e"). If no -e, the
first argument is used as code.
-E Statement: code to act on files name, as -e but terminated by
';'.
I just put it into /usr/bin/ but with a slight different name to make sure I did not break any existing scripts / programs the depend on the old one.
ln -s /usr/local/bin/rename /usr/bin/rename.pl
I had to do the following:
# In bash
sudo yum install perl-CPAN
sudo cpan
# In CPAN shell
install Module::Build
install File::Rename
On RedHat 8.4
sudo yum install perl-CPAN
sudo cpan
install module::Build
install File::Rename
than you can create an alias:
alias prename='/usr/local/bin/rename'
an use:
touch pic.jpeg
prename 's/\.jpeg$/.jpg/' *.jpeg
For Debian-family (.deb) distros, I recommend #SzG's answer.
For RedHat-family (.rpm) distros (e.g. Fedora), if your time is precious (like mine), you can download, compile, and install, from source via cpan in one, terse command:
# Install (replace `rename-1.9` below with another version if desired)
curl -L "http://search.cpan.org/CPAN/authors/id/P/PE/PEDERST/rename-1.9.tar.gz" | tar -xz && ( cd "rename-1.9"; perl "Makefile.PL"; make && make install )
# Cleanup
rm -rf "rename-1.9"
Note:
INSTALL_BASE can be set to modify the base installation directory.
e.g. perl "Makefile.PL" INSTALL_BASE=/usr/local
source
For Arch Linux, its
sudo pacman -S perl-rename
I created a post about Perl's rename for many distro:
https://unix.stackexchange.com/a/727288/12574
rpm based distros:
dnf install prename
archlinux:
pacman -S perl-rename
*BSD:
pkg install p5-File-Rename
Debian like/Ubuntu
apt install rename
slackware:
slackbuild
I recently had to install the glorious Perl rename package to Alpine Linux in a Docker container for a Gitlab CI/CD operation:
apk update
apk add --no-cache make perl-utils
cpan File::Rename

when using CPAN in linux ubuntu should I run it using sudo / as root or as my default user

I get errors like this
Running make install
Prepending blib/arch and blib/lib of 17 build dirs to PERL5LIB; for 'install'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/usr/local/man/man3'
Do not have write permissions on '/usr/local/man/man3'
You may have to su to root to install the package
(Or you may want to run something like
o conf make_install_make_command 'sudo make'
Will I still be able to run the software / library's that perl / CPAN installs as a my default user.
What is the best practice when working with CPAN / Perl on Debian like systems.
You should run the cpan command as your normal user. You have two choices:
Install modules into a directory under your home dir. local::lib will help you set that up.
Configure cpan to use sudo during the install phase. You do that by starting the cpan shell and typing:
o conf make_install_make_command 'sudo make'
o conf mbuild_install_build_command 'sudo ./Build'
o conf commit
The first line configures MakeMaker to use sudo. The second line does the same for Module::Build. The third line saves the changes.
If you want to install your modules for your own use, then you should be running it as yourself. Use local::lib to set up your environment variables so that this works nicely. You may wish to look at cpan minus as an alternative to the default cpan installer.
You may also wish to consider using perlbrew to install a newer version of perl that is completely independent from the system perl.
If you want to install them system wide, then I recommend (since you have tagged this ubuntu) looking at dh-make-perl to produce .deb files that you can install and uninstall with dpkg.
If you want to install modules as a non-root user, you can configure your cpan to use an install base:
makepl_arg [INSTALL_BASE=/home/nelaar/perl]
mbuildpl_arg [--install_base=/home/nelaar/perl]
And set PERL5LIB accordingly to /home/nelaar/perl/lib/perl5.

Resources