I know this is already solved but I was stuck on this for some time and I think a little more detailed steps could help someone.
I was able to fix the same problem by downgrading to msf5 so if you’re on msf6, then try following what I did. The thing is that msf5 is more stable than msf6 and that’s why I recommend downgrading. I can give out some steps:
Uninstall metasploit 6. I did: sudo apt-get --auto-remove metasploit-framework (just type meta and press tab key to autocomplete)
I downloaded the msf5.tar.gz which can be found here: Release 5.0.101 · rapid7/metasploit-framework · GitHub
and extracted it with tar command: tar xvzf filename.tar.gz
go to home directory with cd ~
Then do: gem install bundle
The command above is be required to install the different gems(dependencies) which are required in metasploit
Then go back into the extracted folder and use this command to get all the gems for metasploit: bundle install
**Keep in mind you might have to do bundle install a few times later on so make sure you go into the metasploit extracted folder before you do bundle install
These gems are the dependencies that OP was talking about and how he fixed his issue. Now here’s the kicker, when you try to do bundle install, it will say some error. Try reading through that error line by line and it will give a command saying make sure something is installed before bundling.
Use that command inside the quotations that it says and then it will give you another error which will say something like check log file and it will give the path to that file.
‘cat’ the output of that log file that the error shares and you’ll see the error there. It will say something like this directory/file does not exist. Now just google that error and some stack overflow like websites should show up with the answer. The basic issue here is that those dependencies that you are installing for metasploit have their own dependencies and its a simple matter of using apt to install them (sudo apt-get install packagename). I had to install these dependencies and then do bundle install in the extracted folder. Then it would give another error and it carried on for a few more times. After a while when you do bundle install, it should say something like bundle is complete and it should not give any more errors.
You’re technically done (to run metasploit, just go in the extracted folder and do ./msfconsole) but here’s what you could do to make it a little bit easier to start metasploit.
I used an alias so you can access metasploit from anywhere instead having to type in the directory each time you want to use metasploit
to create an alias, I kept the command similar to the original which is msfconsole.
Just keep in mind if you keep msf6 installed or install it later, then this alias command might intervene so either don’t use msfconsole as the alias command or just replace the msfconsole before the = to something else like msfconsole5 or msf5console.
I used: alias msfconsole=‘cd “path to metasploit extracted folder”/ && ./msfconsole -q’
the -q runs metasploit faster.
I was stuck on this for a while and I hope this helps someone.