I'm tryng to instruct my system to permanently use perlbrew version of perl in my shells as per perlbrew documentation with:
perlbrew switch perl-5.26.0
which should use ~/perl5/perlbrew/perls/perl-5.26.0/bin/perl in every new open shell.
But when I close and reopen iTerm2 and ask
perl -v
the answer is
This is perl 5, version 24, subversion 1 (v5.24.1) built for darwin-thread-multi-2level
which is system perl, in the path
/usr/local/Cellar/perl/5.24.1/bin/perl
No chances to swith to different perl release other than current shell.
I have in my .bash_profile:
source ~/perl5/perlbrew/etc/bashrc
as per perlbrew instructions
What am I missing to have permanently perl switched to desired version?
Thank you
Ok, after googling and struggling, I got to a solution at last.
I started all it over again from Perlbrew documentation, and I did:
perlbrew init
Next, from what it replied to me,
I added
source ~/perl5/perlbrew/etc/bashrc
to my .bash_profile file.
Now, at last, every new shell opens with desired perlbrew switched perl version.
Thank you all, hope this can be useful.
Related
I'm trying to install perlbrew in my mac OSX and this error keeps popping in my terminal, not really sure what this means
Download the latest perlbrew
curl: (18) transfer closed with ###### bytes remaining to read
I understand vaguely that this error is related to poor network service, am I right?
Can anyone help me how to install perlbrew offline and how to install modules after perlbrew is done!
Your help is appreciated
I'm trying to install perlbrew in my mac OSX
There are lots of OSX versions. Can you narrow it down a bit?
I understand vaguely that this error is related to poor network
service, am I right?
If the command you issued was:
$ \curl -L http://install.perlbrew.pl | bash
then that tells a program called curl to download the file install.perlbrew.pl from the internet, then execute the file with a program called bash. You can view that file by entering the url specified in the command in your browser:
http://install.perlbrew.pl
As you can see, the file is very short.
The error means that for some reason curl couldn't download the entirety of a file it was trying to download. That could be because the server(where the file resides) dropped your connection, or the internet connection on your side was disrupted.
Can anyone help me how to install perlbrew offline
You could go to the url and copy the text and paste it into a local file called, say, install_perlbrew.pl. Then you could execute that file offline like this:
$ bash install_perlbrew.pl
That file is a program and when you execute the program with bash, the program uses curl yet again to retrieve another file, namely perlbrew, from the internet. You could also copy the perlbrew file to your computer and modify the install script to use the local perlbrew file, but then when you execute the perlbrew file, it also uses curl to retrieve even more files from the internet, and so on and so on.
So unless you know bash scripting and you can modify the install script to use all local files, and you have the patience to track down all the files required and copy them to local files, you are not going to be able to install perlbrew offline.
Can anyone help me how to ... install modules after perlbrew is done!
If the module name is File::Monitor, you would install it like this:
$ cpan File::Monitor
If it's your first time using the cpan command, you will see this:
$ cpan File::Monitor
CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.
Would you like to configure as much as possible automatically? [yes]
Hit return to use the default answer (which is specified in brackets). After cpan automatically configures itself, it will install the module, and if everything went okay with the installation you will see something like this:
...
...
ANDYA/File-Monitor-1.00.tar.gz
./Build install -- OK
$
Response to comments:
Preamble: Your system has perl installed on it, however it is out of date. But, your system needs perl to perform certain tasks, so you should NEVER delete or update the system perl. In fact, you should leave the system perl alone, so that you don't screw it up and render your OS inoperable. perlbrew to the rescue.
In your Applications folder, look for a Utilities folder, and inside the Utilities folder find Terminal.app. Click on Terminal.app to launch a terminal window.
Here are the steps for installing and using perlbrew:
1) Install perlbrew:
~$ \curl -L http://install.perlbrew.pl | bash
2) Install a perl with perlbrew:
~$ perlbrew install perl-5.23.6
Prior to installing a perl, you can see what versions of perl are available by doing this:
~$ perlbrew available
perl-5.23.6
perl-5.22.1
perl-5.20.3
perl-5.18.4
perl-5.16.3
...
...
Pick whatever version of perl you want to install and specify it in the install command above.
3) Tell perlbrew which perl version to use. Because you will only have one version of perl installed at this point, write:
~$ perlbrew switch perl-5.23.6
perlbrew allows you to install multiple versions of perl, so if you have multiple versions of perl installed, and you want to switch to another version, you can do:
~$ perlbrew list
perl-5.23.6
*perl-5.20.2
perl-5.16.3
~$ perlbrew use perl-5.16.3
~$ perlbrew list
perl-5.23.6
perl-5.20.2
*perl-5.16.3
The asterisk lets you know which version of perl you are currently using.
4) Install modules in the current version of perl:
~$ cpan Path::Class !!DO NOT EVER USE SUDO!!
5) To see a list of all the modules installed in the current perl:
~$ perlbrew list-modules
CPAN::Meta
Date::Parse
File::Monitor
HTTP::CookieJar
HTTP::Date
...
...
...
6) perlbrew has a lot of other commands, so if you need to do something else, try searching through the output of:
~$ perlbrew --help
I want to use perlbrew and cpanm on my machine. I installed perlbrew like this
curl -L http://install.perlbrew.pl | bash
and sourced ~/perl5/perlbrew/etc/bashrc in my .bashrc. Next I installed perl v5.21.5 and switched to this version.The which perl command points to my perlbrew installation. The same is true for cpanm.
But when I install a perl module like cpanm Mojo Neither the binaries are installed nor the includes can be located. But all tests pass. I looked under ~/perl5/ and could not find the sources. Does anyone had the same issue before? I may have used cpan on my Ubuntu 14.04 before. May this cause any problems? How can I figure out where cpanm put the module?
BTW: I'm using perlbrew version 0.71
I solved the problem by deleting everything perl-related in my home directory. The folder ~/.cpan had write-proteced files. Only the sudo user could delete them. I assume I used cpan as root in the past. In addition I deleted ~/.cpanm and ~/perl5. After reinstalling perlbrew, perl and mojolicious, everything worked out of the box.
In my case I was just trying to get some perl code running. Many thanks to the #perl channel on irc.freenode.net.
I first used local::lib but may not have fully cleaned up after using it. The modules I needed for the code I was trying to get running would not run with the system perl. It was just too old.
Then I tried perlbrew install perl-5.20.1 and perlbrew install-cpanm. It felt great to start fresh with a known quantity. Yet I found that modules were passing tests and said they were installing but not getting found and used. Dependencies were trying to be continuously reinstalled. Installing the dependencies one at a time didn't even work. It was baffling. Somewhere along the way I read to set PERL_MB_OPT and PERL_MM_OPT though I think I should have also set PERL5LIB with those.
So I started over with perlbrew after rm -rf ~/.cpan ~/.cpanm ~/perl5. Everything just works now. Hurray!
Are you running the cpanm command in a new terminal window by chance, if so it might not use the new perl you brewed.
"perlbrew use" only makes the current shell use the brewed perl whereas "perlbrew switch" makes all new shells of the current user use the selected perl.
You should provide the output of "perl -V" and "perlbrew info"
Here is a tip how you can find where cpanm installed a module:
1) install locate (sudo aptitude install locate)
2) run "sudo updatedb" (creates the index used by locate)
3) run "locate Mojo" to see where the files have been created.
Also interesting would be to know which cpanm binary you are using. "which cpanm"
You can install a perlbrew-wide cpanm with "perlbrew install-cpanm"
[ I'm going to assume you started a fresh shell (e.g. reopened your terminal or executed exec bash) or sourced ~/perl5/perlbrew/etc/bashrc in your current shell after installing perlbrew ]
Which Perl did you use to install cpanm? cpanm will install modules for the Perl that runs it, which will be the one mentioned on the first line of cpanm if you run it as cpanm ....
Options:
Use cpan instead of cpanm.
Install cpanm using your newly installed Perl.
Use perl -S cpanm ... as a workaround.
I installed perlbrew on Linux backtrack on my virtual machine. and I have perl 5.10.1 installed on my backtrack. but when I write perlbrew command in the terminal it shows the following message:
perlbrew: command not found
What is wrong with my system?
When you installed perlbrew, you were instructed to add something like
source ~/perl5/perlbrew/etc/bashrc
to your shell startup script (.bashrc). It appears that you did not do this, or that you did not restart your shell after doing this.
The standard sudo apt install perlbrew on a fresh Ubuntu18 install appears to be borken (and Ubuntu20 too if my memory isn't malfunctioning). And has been so for some time. I couldn't get it to work even if I appended source ~/perl5/perlbrew/etc/bashrc to ~/.bash_profile and/or ~/.bashrc and started a new bash. And also did perlbrew init.
What eventually worked for me is curl -L https://install.perlbrew.pl | bash taken from https://perlbrew.pl/ After this which perlbrew shows the correct /home/me/perl5/perlbrew/bin/perlbrew instead of /usr/bin/perlbrew. And now I can see the whole list of available perl5 versions with perlbrew available.
I installed perl5.14 via macports.
By typing
which perl
I get
/usr/bin/perl
How do I change the perl to point the macports one.
My .profile is:
# MacPorts Installer addition on 2012-02-02_at_14:42:32: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
Maybe the perl port isn't active? try:
$ sudo port activate perl5
sudo port install perl5 +perl5_14
You need to re-launch terminal for the export to take effect. As a quick but messy workaround you can always invoke perl like this:
/opt/local/bin/perl Remember to put that in your Perl scripts as well. Also, unlike unix I find I always have to use sudo when installing to a local directory.
Macports is great for installing all those non-Perl libraries that aren't installed on the Mac, however it is not so great for installing Perl modules as it is dependant on there being a port of it, you can't really use CPAN to install. perlbrew does work on the Mac and is a much better solution. But if you still want to use Macports to install non-Perl libraries you hit a problem. I solved it with a .profile like this:
source ~/perl5/perlbrew/etc/bashrc
# export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Note the comment. The first line gives me my perlbrew Perl when I open terminal. When I want to use Macports to install libraries I swap the comment around and re-launch terminal and I then have Macports Perl. Of course this means I need two Perls on my machine, and they both need to be the same version but I don't have any problems with this.
Not being on a Mac, I cannot answer your exact question. However, many Perl users/developers now use perlbrew to install newer versions of Perl and manage choosing between them. I am fairly confident that it works on Mac. Read more at the website or CPAN.
I'm using perlbrew to switch between perl versions. I also use Eclipse to write perl scripts.
It seems that Eclipse does not recognize the switches between perl versions, and keeps working with the base version installed out of perlbrew. I tried restarting Eclipse but this doen't help.
So, How can I make Eclipse work with perlbrew?
If you are using EPIC, this will work: Click through to Window->Preferences->Perl EPIC and set the Perl executable to perl5/perlbrew/bin/perl. This always points to the current set version of perl. The path is relative to your $HOME on Linux.
I haven't tried this as I usually just use a text editor for Perl, but I have taken to using the shebang line #!/usr/bin/env perl so that I get the perl for the user that runs the script (ie. perlbrew if me, system perl if root). If Eclipse executes the script (./myscript.pl) this should work, if instead it callsperl myscript.pl` then this will not help you.