Installing perl module without sudo access - linux

The module in question is Geo::IP::PurePerl and this is what I'm doing:
wget http://search.cpan.org/CPAN/authors/id/B/BO/BORISZ/Geo-IP-PurePerl-1.24.tar.gz
tar -zxf Geo-IP-PurePerl-1.24.tar.gz
cd Geo-IP-PurePerl-1.24
perl Makefile.PL
make
make test
sudo make install
However, I don't have sudo access and just make install results in the following error:
[~/perl/Geo-IP-PurePerl-1.24]# make install
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/usr/bin'
Do not have write permissions on '/usr/bin'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1
make: *** [pure_site_install] Error 13
Is there any way to get around this?

I doubt there is any way to install a Perl module to the native system installation of Perl.
In the past I have had to install a new, completely independent version of perl in a directory that I do have write permission over and then ensure that my .profile file links my path to that location. Then whenever I call perl I'm accessing the local install area where I have full write access to.

Try:
perl Makefile.PL PREFIX=~/perllib
of course then you will have to add that path to your #INC include path...

Related

Cant install Net::SSH2 perl module

I'm trying to install a perl module: Net::SSH2 with cpan but doesn't actually works.
cpan -f install Net::SSH2
Output:
CPAN: Storable loaded ok (v2.20) 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, 22 May 2017 22:29:03 GMT HTTP::Date
not available ............. New CPAN.pm version (v2.16) available.
[Currently running version is v1.9402] You might want to try
install CPAN
reload cpan to both upgrade CPAN.pm and run the new version without leaving the current session.
...............................................................DONE
Going to read '/root/.cpan/sources/modules/03modlist.data.gz' Can't
locate object method "data" via package "CPAN::Modulelist" (perhaps
you forgot to load "CPAN::Modulelist"?) at (eval 16) line 1. at
/usr/share/perl5/CPAN/Index.pm line 518
CPAN::Index::rd_modlist('CPAN::Index', '/root/.cpan/sources/modules/03modlist.data.gz') called at
/usr/share/perl5/CPAN/Index.pm line 85
CPAN::Index::reload('CPAN::Index') called at /usr/share/perl5/CPAN.pm line 955
CPAN::exists('CPAN=HASH(0x21fd2f0)', 'CPAN::Module', 'install') called at /usr/share/perl5/CPAN/Shell.pm line 1243
CPAN::Shell::expandany('CPAN::Shell', 'install') called at /usr/share/perl5/CPAN/Shell.pm line 1639
CPAN::Shell::rematein('CPAN::Shell', 'force', 'install', 'install') called at /usr/share/perl5/CPAN/Shell.pm line 1935
CPAN::Shell::ANON('CPAN::Shell', 'install', 'install') called at /usr/bin/cpan line 318
main::_default('ARRAY(0x1938f18)') called at /usr/bin/cpan line 278
It seems that your installation of CPAN is incomplete or otherwise corrupted. OS and Perl version could be helpful. On many current Linux distributions, Perl modules and their dependencies can be installed using the normal system software utilities like yum (RHEL/CentOS), apt (Debian/Ubuntu) and yast (SuSE). Drawback is that versions may not be the most current.
This PerlMonks thread has someone else with a similar problem. It looks like this answer worked in that case:
It looks to me like you have some corrupt data in your .cpan directory. I'd blow it away and try again:
$ rm -rf /home/user/.cpan
Try it at your own risk. In your case, you would need to delete /root/.cpan.
In addition, the correct use of cpan is to list the module names after the command. So, instead of cpan install Net::SSH2, you should use cpan Net::SSH2. If you use the -f option, you must specify -i: cpan -f -i Net::SSH2, but try without forcing things first. You do not want to willy-nilly install broken modules in the system's perl.
In fact, in general, you do not want to mess with the system's perl at all. Build your own perl and mess with it as much as you want.
PS: install is a dummy module created precisely because many people make this mistake.
The safest and most convenient way to install Perl modules can depend on distribution. For example, the recommended method on Fedora is:
$ sudo dnf install 'perl(Net::SSH2)'
As shown in that example, installing Perl modules on your system usually requires sudo or the root user. So you might want to try your command with sudo if you're a sudoer.
If you don't have that kind of power, you may need to install it locally. That usually means downloading it to a Perl library directory you create in your home directory, and including the path in #INC somehow, such as updating your $PERL5LIB to include the /home/user/perl/modules/Net-SSH2/lib/ or whatever your path to the module lib directory is.

Do not have write permissions on '/usr/local/share/man/man3'

I am using Linux machine and getting YAML not installed error while installing JSON Perl module from Cpan. Any help is highly appreciable.
cpan[1]>install JSON
anifying blib/man3/JSON::backportPP::Boolean.3pm
Manifying blib/man3/JSON::backportPP.3pm
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/usr/local/share/man/man3'
Do not have write permissions on '/usr/local/share/man/man3'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1
make: *** [pure_site_install] Error 13
MAKAMAKA/JSON-2.90.tar.gz
/usr/bin/make install -- NOT OK
----
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'
to raise your permissions.Warning (usually harmless): 'YAML' not installed, will not store persistent state
and when I try to install YAMl, I get this error .
cpan[1]>install YAML
ERROR: Can't create '/usr/local/share/man/man3'
Do not have write permissions on '/usr/local/share/man/man3'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1
make: *** [pure_site_install] Error 13
INGY/YAML-1.15.tar.gz
/usr/bin/make install -- NOT OK
----
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'
to raise your permissions.Warning (usually harmless): 'YAML' not installed, will not store persistent state
Failed during this command:
TYEMQ/Algorithm-Diff-1.1903.tar.gz : install NO
NEILB/Text-Diff-1.43.tar.gz : install NO
INGY/Spiffy-0.46.tar.gz : install NO
INGY/Test-Base-0.88.tar.gz : install NO
INGY/Test-YAML-1.06.tar.gz : install NO
INGY/YAML-1.15.tar.gz
Thanks in advance
'YAML' not installed, will not store persistent state is harmless.
As for not having permission to writing to /usr/local/share/man/man3, any reason to believe that's incorrect?
If you do have root access, did you follow the instructions in the error message? Launch cpan, and execute the following commands:
o conf make_install_make_command 'sudo make'
o conf commit
If you don't have root access, are you asking how to install modules to an arbitrary directory? I'd use perlbrew to install a perl in your home directory instead.
Are you running cpan as a regular user? No sudo or root access? That's probably why.
I have a similar problem. I add the following in the ~/.bashrc file.
vi ~/.bashrc
Then add these right after the definition of "PERL5LIB":
PERL_MB_OPT="--install_base "/home/usrname/perl5""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/usrname/perl5"; export PERL_MM_OPT;
Save, quit, and source the file:
source ~/.bashrc
Maybe you can use the below command to get the above information in terminal:
perl -I ~/perl5/lib/perl5 -Mlocal::lib

make: Nothing to be done for `STAR'

I want to test rna-star code. I have Ubuntu 12.04 on my machine.I have downloaded all the packages necessary:
sudo apt-get update
sudo apt-get install g++
sudo apt-get install make
But in the installation step I have problem running make command on STAR executable file.on the installation manual I see it says:
Unzip/tar STAR_x.x.x.tgz file into a directory of your choice <
STARsource >, cd < STARsource > and run make. The source code will be
compiled and the STAR executable will be generated.
when I run 'make STAR' it says:
make: Nothing to be done for `STAR'.
any suggestion?
This means that the "STAR" target does not exist. In a makefile, you define targets (implicit or explicit) and make takes care of building in the correct orders the dependencies for your target.
You should read documentation on this project or glance at the makefile : it's likely you need to run "make" without parameters (which is stated in your documentation excerpt), something like :
tar zxvf star...tgz
cd star...
make
So I just ran into the same problem.
Apparently the following solved it:
Redirect to source map: cd STAR-2.5.3a/source
The Makefile is in this location, after this just enter the command make.
It should start running. If you work in a cluster do not forget to edit your shell configuration before using;
export PATH=$HOME/STAR-2.5.3a/source:$PATH

Net-SNMP perl module won't make

Firstly, I am using a Beaglebone Black with the Angstrom distribution.
My mib2c program for net-snmp won't work and give the following error:
ERROR: You don't have the SNMP perl module installed. Please obtain
this by getting the latest source release of the net-snmp toolkit from
http://www.net-snmp.org/download/ . Once you download the source and
unpack it, the perl module is contained in the perl/SNMP directory.
See the README file there for instructions.
So I go to /net-snmp/perl/SNMP and run
perl Makefile.PL
make
Now it gives me this error:
make: *** No rule to make target `/usr/lib/perl/5.14.2/ExtUtils/typemap', needed by `SNMP.c'. Stop.
Ok, so I know that the ExtUtils module must be installed (which it is), but all that I have in that folder are .pm files. When I run them using perl nothing happens. I've also tried to look for the files online (after I create a typemap file there it asks for a xsubpp file aswell), but to no avail.
How do I install those modules so that the correct files will be there?
On Ubuntu 14.04, I needed to sudo apt-get install libsnmp-perl
Install Perl Net::SNMP
perl -MCPAN -e 'install Net::SNMP'
You could try to install it using CPAN:
perl -MCPAN -e 'install HTML::Template'

Composer & Cygwin

Composer doesn't run correctly in Cygwin if you try to install it "globally".
Putting composer.phar into /usr/local/bin/composer, then trying to run it will result in the error:
Could not open input file: /usr/local/bin/composer
Just tripped over the same problem and found a solution. Posting it here, just in case I'll ever have to look it up again.
Set up a bin directory right under /home/my-username:
cd ~
mkdir bin
Move the composer.phar (or any other of those nifty new PHP imps that are on the rise)
into the ~/bindirectory and make sure to set it's execution bit:
# Notice how I got rid of the superfluous `.phar` extension
mv /path/to/composer.phar ~/bin/composer
chmod +x ~/bin/composer
Tell cygwin to include your ~/bin directory in the search path:
Open up the file ~/.bash_profile and uncomment the following paragraph ...
# Set PATH so it includes user's private bin if it exists
if [ -d "${HOME}/bin" ] ; then
PATH="${HOME}/bin:${PATH}"
fi
Now, for the most important part:
A wrapper script that helps Win's native PHP resolve Unix style paths (which is causing
the problem after all as Windows doesn't know how to handle /cygdrive/... paths).
cd ~/bin
touch php
chmod +x php
After editing the wrapper script ~/bin/php should read:
#!/bin/bash
# e.g. php="/cygdrive/c/Program Files (x86)/php/php.exe"
php="/path/to/php.exe"
for ((n=1; n <= $#; n++)); do
if [ -e "${!n}" ]; then
# Converts Unix style paths to Windows equivalents
path="$(cygpath --mixed ${!n} | xargs)"
case 1 in
$(( n == 1 )) )
set -- "$path" "${#:$(($n+1))}";;
$(( n < $# )) )
set -- "${#:1:$((n-1))}" "$path" ${#:$((n+1)):$#};;
*)
set -- "${#:1:$(($#-1))}" "$path";;
esac
fi
done
"$php" "$#"
Now restart your shell and it should correctly invoke the PHP interpreter whenever it
stumbles upon a #!/usr/bin/env php shebang. Simply issue a:
composer --help
How about this one?
In ~/.bashrc, add: alias composer='php c:\\your\\path\\to\\composer.phar'
Restart cygwin or reload the bashrc by running source ~/.bashrc
Works for me using both Cygwin's native php.exe and XAMPP's Windows-specific one.
I think what might work is to build a proxy instead:
Put composer.phar in /usr/local/bin/composer.phar
Create a bash proxy as /usr/local/bin/composer with the following:
#!/bin/sh
c:/path/to/php c:/path/to/composer.phar $#
chmod +x /usr/local/bin/composer
Try this:
Install Cygwin PHP and use it to run composer in Cygwin.
You can choose one of two ways to work fine with PHP+Composer in Cygwin:
Install Cygwin PHP and install composer.phar in Cygwin.
Install Windows PHP and install Winodows Composer, then call then from Cygwin. (Windows XAMMP+Composer with alias in cmd)
Your problem is caused by that Cygwin Composer is ruining by Windows PHP on Cygwin, so it can not recognize the file path.
After install Cygwin PHP, the composer will integrates with Cygwin PHP then fit to Cygwin's filepath.
Cygwin PHP extensions for composer usage:
php
php-json
php-mbstring
php-phar
php-zip
php-posix
You can install other PHP extension when composer's package is needed such as php-xmlwriter, php-tokenizer, php-ctype.
Installation commands guide:
If you have already installed apt-cyg, there are installation command above:
apt-cyg install php php-json php-mbstring php-phar php-zip php-posix
apt-cyg install php-xmlwriter php-tokenizer php-ctype
Then install Composer via Cygwin PHP:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
chmod +x ./composer.phar
mv ./composer.phar /usr/bin/composer
composer -v
Conclusion
I recommend using Windows PHP + Windows Composer, and call then in Cygwin, it because the Cygwin PHP is not much stable than Windows PHP.
I had the same problem. After reading the final instruction from composer installer, it says that the $PATH variable should be reloaded. I rebooted my computer and then linked the Composer bin to /usr/local/bin.
First locate the composer bin :
/cygdrive/c/ProgramData/ComposerSetup/bin/composer
Then according to Seldaek answer, after trying a non-working symlink, I did :
nano /usr/local/bin/composer
#!/bin/sh
/cygdrive/c/ProgramData/ComposerSetup/bin/composer $#
chmod +x /usr/local/bin/composer
And it's working.
What I did (very simple):
Install Composer normally with the Windows installer
Open a Cygwin console an type composer you will see something like Could not open input file: /c/route/to/your/composer/installation/bin
Create an alias composer='composer.bat' on your bash profile or bashrc or whatever
Done
I'm running Windows 8.1
I was having this issue. Most of the responses were over my head but I fixed it with no problems.
Step 1) Reinstall Composer globally as per https://getcomposer.org/download/
Step 2) Leave it alone. All the special stuff you want to do, don't do that.
Step 3) Download the latest setup-xxx.exe from https://cygwin.com/
Step 4) Click it with your mouse.
NOTE: During step 5 you will feel a sudden urge to read instructions, browse the web for info and start checking little boxes on the menu. Don't do that.
Step 5) Click 'next' until it stops asking. It will look at your existing
settings, fix things up and add any missing dependencies.
This worked for me.
Getting composer to work globally inside Cygwin is a pain in the butt...
The solutions I have come up with:
Don't use it globally. If you are using the PHP CLI from a Windows installation, it won't recognize the Linux paths that Cygwin uses.
What I have done is put it in the base directory of all the projects I use composer with, and do ../composer.phar to run it.
It works fine this way, and it's almost globally available...
Download, and compile your own PHP binaries within Cygwin... Yea, kind of a overkill.
I solved the problem like this in a Cygwin/XAMPP setup:
Install composer.phar to XAMPP's php directory
Create an executable Bash script named composer in XAMPP's php directory:
#!/bin/bash
script_dir=$(cygpath -w $(dirname $0))
php "$script_dir/composer.phar" $#
It's important to use cygpath -w to convert the path to a path in Windows form.
Make sure XAMPP's php directory is accessible in Cygwin's $PATH:
$ export PATH=$PATH:/cygdrive/i/dev/server/xampp/php
Now it's possible to call composer from anywhere you like without problems:
$ composer -V
Composer version 264f433ca3f007d39568b3722b4bf418f58ba15b
I fixed it by adding a /usr/local/bin/composer file:
nano /usr/local/bin/composer
with the following content:
#!/bin/bash
/cygdrive/c/wamp/bin/php/php5.4.3/php "C:\wamp\bin\php\php5.4.3\composer"
Basically, you have to call PHP with a Windows style path, not a cygwin path.
The easiest way is to install composer using the Windows installer from their website and then copy the two files 'composer' and 'composer.phar' from "C:\ProgramData\Composer" into a directory which is in the PATH variable. E.g. you could copy the files into the /bin/ directory of cygwin. Afterwards you can again uninstall the "Windows version" of composer.
Update! This is what I did:
Install PHP and needed modules from the Cygwin Ports project
Download the latest composer snapshot
Rename 'composer.phar' to 'composer' and save it to /usr/local/bin
Open /bin/dash.exe and run '/usr/bin/rebaseall'
Also if 4. gives you an error, composer should run now
I suggest you use babun, it is based cygwin, but you can install package by pact, you can do this:
pact install php php-json php-phar
php -r "readfile('https://getcomposer.org/installer');" | php
then enjoy yourself.
I was having trouble getting Composer to work in Cygwin and none of the solutions above were resolving my problem. Eventually I stumbled across this comment in the Composer github bugs discussion:
Yeah TBH using php from cygwin isn't a great idea, cygwin is just too different an environment. Too many hacks that create failures.. In any case closing here as there isn't much we can do I'm afraid :)
I don't know precisely where composer/Cygwin/php was tripping up, but, broadly, my problem was that I had two conflicting installations of PHP in environmental variables, one from an installation of WAMP, and another installed with Cygwin. The Cygwin PHP installation seemed to be struggling with some sort of path issue. I removed it, using only the WAMP PHP, and composer ran in Cygwin just fine.

Resources