1

I am new to perl and CPAN. I see that perl is installed in my system.

However, I would like to install DBI package to run a script called INSTALL.PL.

When I type CPAN, I get the below error message

Loading internal null logger. Install Log::Log4perl for logging messages
Terminal does not support AddHistory.

There seems to be running another CPAN process (pid 3986).  Contacting...
Other job not responding. Shall I overwrite the lockfile '/home/abcd/.cpan/.lock'? (Y/n) [y]

If I give no, I don't get the CPAN command prompt. Whereas if I give yes, I get the below command prompt

nolockcpan[1]

May I know what does the error message mean and what are the steps to follow to avoid this message again?

Can't I enter into cpan mode and press CTRL+Z exit and again get into cpan mode?

How can I avoid this error message and when can this happen?

The Great
  • 7,215
  • 7
  • 40
  • 128
  • Re "*May I know what does the error message mean*", It means it didn't exit cleanly the last time you used it. – ikegami Sep 07 '20 at 11:32
  • 2
    Re "*Can't I enter into cpan mode and press CTRL+Z exit and again get into cpan mode?*", Yes, by entering `fg` as normal. – ikegami Sep 07 '20 at 11:33
  • @ikegami - May I know how can I exit cpan mode? When I type `fg` in the cpan prompt, I get the below message `Unknown shell command 'fg'. Type ? for help.` – The Great Sep 07 '20 at 11:59
  • 1
    `exit` or `quit`, can't remember which. Ctrl-D surely also works. /// `fg` is the *shell* command to get back *into* `cpan` after suspending it using Ctrl-Z – ikegami Sep 07 '20 at 12:01
  • Sure, thanks. You can write as an answer and I can accept it. – The Great Sep 07 '20 at 12:09
  • FWIW, I install packages from [CPAN](https://www.cpan.org/) by running `cpanm -i PackageName` on the command line. That uses [cpanm](https://metacpan.org/pod/distribution/App-cpanminus/bin/cpanm), which is much simpler than [cpan](https://www.cpan.org/modules/INSTALL.html). I find a good summary of differences [here](https://stackoverflow.com/q/5861292/4653379), and also see a note on the `cpan` page itself. The `cpanm` need be installed, with `curl -L https://cpanmin.us | perl - --sudo App::cpanminus` for instance (taken from [App::cpanminus](https://metacpan.org/pod/App::cpanminus)). – zdim Sep 07 '20 at 18:59
  • @zdim, `cpan -i PackageName` works just as well with `cpan`. The lock is only used when using the shell. // The only benefit listed on the linked page is that `cpanm` uses less memory, which isn't relevant here. – ikegami Sep 07 '20 at 23:04
  • @ikegami Sure, my "fwiw" comment doesn't address their issue here, true. I was commenting more in general, as they seem unaware of `cpanm`. (Its advantage is also that there is no configuration to deal with, literally install and use, with all "instructions" in that one comment. But then of course a disadvantage may be that one can't configure and tweak it as one can with `cpan`.) It's good to know for such an option. – zdim Sep 07 '20 at 23:32
  • @zdim, Re "*Its advantage is also that there is no configuration to deal with*", My point is that this is true for `cpan` too. You don't have to deal with configuring `cpan` either. By default, it "just works" like `cpanm`. (Note that some aspects of the build process can be configured even when using `cpanm`. You just have to use env vars to do it. But that's the preferred way for `cpan` too.) – ikegami Sep 08 '20 at 00:14
  • @ikegami Right, good point -- my experiences with `cpan` (kinda long ago by now) were always more verbose and involved more work, and I forgot that that isn't _necessary_. – zdim Sep 08 '20 at 20:50

1 Answers1

5

It means that cpan wasn't properly exited the last time it was run. This could happen if you close your terminal while it's still running, for example.

You can use exit or quit to exit cpan. It will also exit when its STDIN reaches EOF (which can be done using Ctrl-D on unix).

You talk of Ctrl-Z, which stops (suspends) it, but doesn't exit it. Use fg to return to cpan after stopping it. That said, launching cpan while it's stopped or otherwise still running results in a different message (Other job is running. Shall I try to run in downgraded mode?).

ikegami
  • 367,544
  • 15
  • 269
  • 518